CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/CondCore/ORA/src/OraDatabaseSchema.h

Go to the documentation of this file.
00001 #ifndef INCLUDE_ORA_ORADATABASESCHEMA_H
00002 #define INCLUDE_ORA_ORADATABASESCHEMA_H
00003 
00004 #include "IDatabaseSchema.h"
00005 // externals
00006 #include "CoralBase/AttributeList.h"
00007 
00008 namespace ora {
00009 
00010   class OraMainTable: public IMainTable {
00011     public:
00012     static std::string version();
00013     static std::string tableName();
00014     static std::string parameterNameColumn();
00015     static std::string parameterValueColumn();
00016     public:
00017     explicit OraMainTable( coral::ISchema& dbSchema );
00018     virtual ~OraMainTable();
00019     bool getParameters( std::map<std::string,std::string>& destination );
00020     std::string schemaVersion();
00021     public:
00022     bool exists();
00023     void create();
00024     void drop();
00025     private:
00026     coral::ISchema& m_schema;
00027   };
00028 
00029   
00030   class OraSequenceTable : public ISequenceTable{
00031     public:
00032     static std::string tableName();
00033     static std::string sequenceNameColumn();
00034     static std::string sequenceValueColumn();    
00035     public:
00036     explicit OraSequenceTable( coral::ISchema& dbSchema );
00037     virtual ~OraSequenceTable();
00038     bool add( const std::string& sequenceName );
00039     bool getLastId( const std::string& sequenceName, int& lastId );
00040     void sinchronize( const std::string& sequenceName, int lastValue );
00041     void erase( const std::string& sequenceName );
00042     public:
00043     bool exists();
00044     void create();
00045     void drop();    
00046     private:
00047     coral::ISchema& m_schema;
00048   };
00049 
00050   class OraMappingVersionTable: public IDatabaseTable {
00051     public:
00052     static std::string tableName();
00053     static std::string mappingVersionColumn();
00054     public:
00055     explicit OraMappingVersionTable( coral::ISchema& dbSchema  );
00056     virtual ~OraMappingVersionTable();
00057     public:
00058     bool exists();
00059     void create();
00060     void drop();
00061     private:
00062     coral::ISchema& m_schema;
00063   };
00064   
00065   class OraMappingElementTable: public IDatabaseTable {
00066     public:
00067     static std::string tableName();
00068     static std::string mappingVersionColumn();
00069     static std::string elementIdColumn();
00070     static std::string elementTypeColumn();
00071     static std::string scopeNameColumn();
00072     static std::string variableNameColumn();
00073     static std::string variableParIndexColumn();
00074     static std::string variableTypeColumn();
00075     static std::string tableNameColumn();
00076     static std::string columnNameColumn();
00077     public:
00078     explicit OraMappingElementTable( coral::ISchema& dbSchema  );
00079     virtual ~OraMappingElementTable();
00080     public:
00081     bool exists();
00082     void create();
00083     void drop();
00084     private:
00085     coral::ISchema& m_schema;
00086   };
00087 
00088   class OraContainerHeaderTable: public IContainerHeaderTable {
00089     public:
00090     static std::string tableName();
00091     static std::string containerIdColumn();
00092     static std::string containerNameColumn();
00093     static std::string classNameColumn();
00094     static std::string numberOfObjectsColumn();
00095     public:
00096     explicit OraContainerHeaderTable( coral::ISchema& dbSchema );
00097     virtual ~OraContainerHeaderTable();
00098     bool getContainerData( std::map<std::string, ContainerHeaderData>& destination );
00099     void addContainer( int id, const std::string& containerName, const std::string& className );
00100     void removeContainer( int id );
00101     void incrementNumberOfObjects( int id  );
00102     void decrementNumberOfObjects( int id  );
00103     void updateNumberOfObjects( const std::map<int,unsigned int>& numberOfObjectsForContainerIds );
00104     public:
00105     //std::string name();
00106     bool exists();
00107     void create();
00108     void drop();
00109     private:
00110     void updateContainer( int id, const std::string& setClause );
00111     private:
00112     coral::ISchema& m_schema;
00113   };
00114 
00115   class OraClassVersionTable: public IDatabaseTable {
00116     public:
00117     static std::string tableName();
00118     static std::string classNameColumn();
00119     static std::string classVersionColumn();
00120     static std::string classIdColumn();
00121     static std::string dependencyIndexColumn();
00122     static std::string containerIdColumn();
00123     static std::string mappingVersionColumn();
00124     public:
00125     explicit OraClassVersionTable( coral::ISchema& dbSchema  );
00126     virtual ~OraClassVersionTable();
00127     public:
00128     bool exists();
00129     void create();
00130     void drop();
00131     private:
00132     coral::ISchema& m_schema;
00133   };
00134 
00135   class OraMappingSchema: public IMappingSchema {
00136     public:
00137     explicit OraMappingSchema( coral::ISchema& dbSchema  );
00138     virtual ~OraMappingSchema();
00139    public:
00140     bool getVersionList( std::set<std::string>& destination );
00141     bool getMapping( const std::string& version, MappingRawData& destination );
00142     void storeMapping( const MappingRawData& mapping );
00143     void removeMapping( const std::string& version );
00144     bool getContainerTableMap( std::map<std::string, int>& destination );
00145     bool getMappingVersionListForContainer( int containerId, std::set<std::string>& destination, bool onlyDependency=false );
00146     bool getDependentClassesInContainerMapping( int containerId, std::set<std::string>& destination );
00147     bool getClassVersionListForMappingVersion( const std::string& mappingVersion, std::set<std::string>& destination );
00148     bool getClassVersionListForContainer( int containerId, std::map<std::string,std::string>& versionMap );
00149     bool getMappingVersionListForTable( const std::string& tableName, std::set<std::string>& destination );
00150     bool selectMappingVersion( const std::string& classId, int containerId, std::string& destination );
00151     bool containerForMappingVersion( const std::string& mappingVersion, int& destination );
00152     void insertClassVersion( const std::string& className, const std::string& classVersion, const std::string& classId,
00153                              int dependencyIndex, int containerId, const std::string& mappingVersion );
00154     void setMappingVersion( const std::string& classId, int containerId, const std::string& mappingVersion );
00155     private:
00156     coral::ISchema& m_schema;
00157   };  
00158 
00159   class OraNamingServiceTable : public INamingServiceTable {
00160     public:
00161     static std::string& tableName();
00162     static std::string& objectNameColumn();
00163     static std::string& containerIdColumn();
00164     static std::string& itemIdColumn();
00165    public: 
00166     explicit OraNamingServiceTable( coral::ISchema& dbSchema );
00167     virtual ~OraNamingServiceTable();
00168     void setObjectName( const std::string& name, int contId, int itemId );
00169     bool eraseObjectName( const std::string& name );
00170     bool eraseAllNames();
00171     bool getObjectByName( const std::string& name, std::pair<int,int>& destination );
00172     bool getNamesForObject( int contId, int itemId, std::vector<std::string>& destination );
00173     bool getNamesForContainer( int contId, std::vector<std::string>& destination );
00174     bool getAllNames( std::vector<std::string>& destination );
00175 
00176    public:
00177     bool exists();
00178     void create();
00179     void drop();    
00180   private:
00181     coral::ISchema& m_schema; 
00182   };
00183 
00184   class OraDatabaseSchema: public IDatabaseSchema {
00185     public:
00186     static bool existsMainTable( coral::ISchema& dbSchema );
00187     
00188     public:
00189     explicit OraDatabaseSchema( coral::ISchema& dbSchema );
00190     virtual ~OraDatabaseSchema();
00191     
00192     bool exists();
00193     void create();
00194     void drop();
00195 
00196     IMainTable& mainTable();
00197     ISequenceTable& sequenceTable();
00198     IDatabaseTable& mappingVersionTable();
00199     IDatabaseTable& mappingElementTable();
00200     IContainerHeaderTable& containerHeaderTable();
00201     IDatabaseTable& classVersionTable();
00202     IMappingSchema& mappingSchema();
00203     INamingServiceTable& namingServiceTable();
00204 
00205     private:
00206     coral::ISchema& m_schema;
00207     OraMainTable m_mainTable;
00208     OraSequenceTable m_sequenceTable;
00209     OraMappingVersionTable m_mappingVersionTable;
00210     OraMappingElementTable m_mappingElementTable;
00211     OraContainerHeaderTable m_containerHeaderTable;
00212     OraClassVersionTable m_classVersionTable;
00213     OraMappingSchema m_mappingSchema;
00214     OraNamingServiceTable m_namingServiceTable;
00215   };  
00216   
00217 }
00218 
00219 #endif
00220   
00221