CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/CondCore/ORA/src/MappingTree.h

Go to the documentation of this file.
00001 #ifndef INCLUDE_ORA_MAPPINGTREE_H
00002 #define INCLUDE_ORA_MAPPINGTREE_H
00003 
00004 #include "MappingElement.h"
00005 //
00006 #include <set>
00007 
00008 namespace ora {
00009 
00010   struct TableInfo {
00011       TableInfo():
00012         m_dependency( false ),
00013         m_tableName(""),
00014         m_idColumns(),
00015         m_dataColumns(),
00016         m_parentTableName(""),
00017         m_refColumns(),
00018         m_nullableColumns(){
00019       }
00020       TableInfo( const TableInfo& rhs ):
00021         m_dependency( rhs.m_dependency ),
00022         m_tableName( rhs.m_tableName ),
00023         m_idColumns( rhs.m_idColumns ),
00024         m_dataColumns( rhs.m_dataColumns ),
00025         m_parentTableName(rhs.m_parentTableName),
00026         m_refColumns(rhs.m_refColumns),
00027         m_nullableColumns(rhs.m_nullableColumns){
00028       }
00029       TableInfo& operator=( const TableInfo& rhs ){
00030         m_dependency = rhs.m_dependency;
00031         m_tableName = rhs.m_tableName;
00032         m_idColumns = rhs.m_idColumns;
00033         m_dataColumns = rhs.m_dataColumns;
00034         m_parentTableName = rhs.m_parentTableName;
00035         m_refColumns = rhs.m_refColumns;
00036         m_nullableColumns = rhs.m_nullableColumns;
00037         return *this;
00038       }
00039       bool m_dependency;
00040       std::string m_tableName;
00041       std::vector<std::string> m_idColumns;
00042       std::map<std::string,std::string> m_dataColumns;
00043       std::string m_parentTableName;
00044       std::vector<std::string> m_refColumns;
00045       std::set<std::string> m_nullableColumns;
00046   };
00047   
00048 
00053   class MappingTree
00054   {
00055     
00057   public:
00059     MappingTree();
00060 
00062     explicit MappingTree( const std::string& version );
00063 
00064     MappingTree( const MappingTree& rhs );
00065 
00067     ~MappingTree();
00068 
00069     MappingTree& operator=( const MappingTree& rhs );
00070     
00071     void setVersion( const std::string& version);
00072     
00076     const std::string& version() const;
00077 
00084     MappingElement& setTopElement( const std::string& className,
00085                                    const std::string& tableName,
00086                                    bool isDependent = false );
00087 
00088     void setDependency( const MappingTree& parentTree );
00089 
00093     const MappingElement& topElement() const;
00097     MappingElement& topElement();
00098     
00102     const std::string& className() const;
00103 
00105     void override(const MappingTree& source);
00106 
00107     std::vector<TableInfo> tables() const;
00108 
00109     void printXML( std::ostream& outputStream ) const;
00110     
00111   private:
00115     std::string m_version;
00116 
00120     MappingElement m_element;
00121 
00122     std::auto_ptr<TableInfo> m_parentTable;
00123 
00124   };
00125 }
00126 
00127 inline const std::string&
00128 ora::MappingTree::version() const {
00129   return m_version;
00130 }
00131 
00132 inline void
00133 ora::MappingTree::setVersion( const std::string& version ){
00134   m_version = version;
00135 }
00136 
00137 inline const std::string&
00138 ora::MappingTree::className() const {
00139   return m_element.variableName();
00140 }
00141 
00142 inline const ora::MappingElement& 
00143 ora::MappingTree::topElement() const {
00144   return m_element;
00145 }
00146 
00147 inline ora::MappingElement& 
00148 ora::MappingTree::topElement(){
00149   return m_element;
00150 }
00151 
00152 #endif