CMS 3D CMS Logo

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

Go to the documentation of this file.
00001 #ifndef INCLUDE_ORA_IDATABASESCHEMA_H
00002 #define INCLUDE_ORA_IDATABASESCHEMA_H
00003 
00004 //
00005 #include <string> 
00006 #include <map> 
00007 #include <set> 
00008 #include <vector>
00009 
00010 namespace coral {
00011   class ISchema;
00012 }
00013 
00014 namespace ora {
00015 
00016   std::string poolSchemaVersion();
00017 
00018   class IDatabaseTable {
00019     public:
00020     virtual ~IDatabaseTable(){}
00021 
00022     virtual bool exists() = 0;
00023     virtual void create() = 0;
00024     virtual void drop() = 0;
00025   };
00026 
00027   class IMainTable: public IDatabaseTable {
00028     public:
00029     static std::string versionParameterName();
00030     public:
00031     virtual ~IMainTable(){}
00032     virtual bool getParameters( std::map<std::string,std::string>& destination ) = 0;
00033     virtual std::string schemaVersion() = 0;
00034   };
00035 
00036   class ISequenceTable : public IDatabaseTable{
00037     public:
00038     virtual ~ISequenceTable(){
00039     }
00040 
00041     virtual bool add( const std::string& sequenceName ) = 0;
00042     virtual bool getLastId( const std::string& sequenceName, int& lastId ) = 0;
00043     virtual void sinchronize( const std::string& sequenceName, int lastValue ) = 0;
00044     virtual void erase( const std::string& sequenceName ) = 0;
00045   };
00046 
00047   struct MappingRawElement {
00048       static std::string emptyScope();
00049       MappingRawElement();
00050       MappingRawElement(const MappingRawElement& rhs);
00051       MappingRawElement& operator==(const MappingRawElement& rhs);
00052       std::string scopeName;
00053       std::string variableName;
00054       std::string variableType;
00055       std::string elementType;
00056       std::string tableName;
00057       std::vector<std::string> columns;
00058   };
00059 
00060   struct MappingRawData {
00061       MappingRawData();
00062       explicit MappingRawData( const std::string& version );
00063       MappingRawElement& addElement( int elementId );
00064       std::string version;
00065       std::map< int, MappingRawElement> elements;
00066   };
00067 
00068 
00069   struct ContainerHeaderData {
00070       ContainerHeaderData( int contId,
00071                            const std::string& classN,
00072                            unsigned int numberObj );
00073       ContainerHeaderData( const ContainerHeaderData& rhs );
00074       ContainerHeaderData& operator=( const ContainerHeaderData& rhs );
00075       int id;
00076       std::string className;
00077       unsigned int numberOfObjects;
00078   };
00079   
00080   class IContainerHeaderTable: public IDatabaseTable  {
00081     public:
00082     virtual ~IContainerHeaderTable(){
00083     }
00084     virtual bool getContainerData( std::map<std::string, ContainerHeaderData>& destination ) = 0;
00085     virtual void addContainer( int id, const std::string& containerName, const std::string& className ) = 0;
00086     virtual void removeContainer( int id ) = 0;
00087     virtual void incrementNumberOfObjects( int id  ) = 0;
00088     virtual void decrementNumberOfObjects( int id  ) = 0;
00089     virtual void updateNumberOfObjects( const std::map<int,unsigned int>& numberOfObjectsForContainerIds ) = 0;
00090   };
00091 
00092   class IMappingSchema {
00093     public:
00094     virtual ~IMappingSchema(){
00095     }
00096     virtual bool getVersionList( std::set<std::string>& destination ) = 0;
00097     virtual bool getMapping( const std::string& version, MappingRawData& destination ) = 0;
00098     virtual void storeMapping( const MappingRawData& data ) = 0;
00099     virtual void removeMapping( const std::string& version ) = 0;
00100     virtual bool getContainerTableMap( std::map<std::string, int>& destination ) = 0;
00101     virtual bool getMappingVersionListForContainer( int containerId, std::set<std::string>& destination, bool onlyDependency=false ) = 0;
00102     virtual bool getDependentClassesInContainerMapping( int containerId, std::set<std::string>& destination ) = 0;
00103     virtual bool getClassVersionListForMappingVersion( const std::string& mappingVersion, std::set<std::string>& destination ) = 0;
00104     virtual bool getClassVersionListForContainer( int containerId, std::map<std::string,std::string>& versionMap ) = 0;
00105     virtual bool getMappingVersionListForTable( const std::string& tableName, std::set<std::string>& destination ) = 0;
00106     virtual bool selectMappingVersion( const std::string& classId, int containerId, std::string& destination ) = 0;
00107     virtual bool containerForMappingVersion( const std::string& mappingVersion, int& destination ) = 0;
00108     virtual void insertClassVersion( const std::string& className, const std::string& classVersion, const std::string& classId,
00109                                      int dependencyIndex, int containerId, const std::string& mappingVersion )= 0;
00110     virtual void setMappingVersion( const std::string& classId, int containerId, const std::string& mappingVersion ) = 0;
00111   };
00112 
00113   class INamingServiceTable: public IDatabaseTable  {
00114     public:
00115     virtual ~INamingServiceTable(){
00116     }
00117     virtual void setObjectName( const std::string& name, int contId, int itemId ) = 0;
00118     virtual bool eraseObjectName( const std::string& name ) = 0;
00119     virtual bool eraseAllNames() = 0;
00120     virtual bool getObjectByName( const std::string& name, std::pair<int,int>& destination ) = 0;
00121     virtual bool getNamesForObject( int contId, int itemId, std::vector<std::string>& destination ) = 0;
00122     virtual bool getNamesForContainer( int contId, std::vector<std::string>& destination ) = 0;
00123     virtual bool getAllNames( std::vector<std::string>& destination ) = 0;
00124   };
00125 
00126   class IDatabaseSchema {
00127     public:
00128 
00129     static IDatabaseSchema* createSchemaHandle( coral::ISchema& schema );
00130 
00131     public:
00132     IDatabaseSchema( coral::ISchema& schema );
00133     virtual ~IDatabaseSchema(){
00134     }
00135 
00136     virtual bool exists() = 0;
00137     virtual void create() = 0;
00138     virtual void drop() = 0;
00139 
00140     virtual IMainTable& mainTable() = 0;
00141     virtual ISequenceTable& sequenceTable() = 0;
00142     virtual IDatabaseTable& mappingVersionTable() = 0;
00143     virtual IDatabaseTable& mappingElementTable() = 0;
00144     virtual IContainerHeaderTable& containerHeaderTable() = 0;
00145     virtual IDatabaseTable& classVersionTable() = 0;
00146     virtual IMappingSchema& mappingSchema() = 0;
00147     virtual INamingServiceTable& namingServiceTable() = 0;
00148     coral::ISchema& storageSchema();
00149     
00150     private:
00151     coral::ISchema& m_schema;
00152   };
00153   
00154 }
00155 
00156 #endif
00157   
00158     
00159