CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_4/src/CondCore/ORA/src/MappingDatabase.h

Go to the documentation of this file.
00001 #ifndef INCLUDE_ORA_MAPPINGDATABASE_H
00002 #define INCLUDE_ORA_MAPPINGDATABASE_H
00003 
00004 #include "Sequences.h"
00005 //
00006 #include <string>
00007 #include <map>
00008 #include <vector>
00009 #include <set>
00010 
00011 namespace Reflex{
00012   class Type;
00013 }
00014 
00015 namespace ora {
00016 
00017   class IDatabaseSchema;
00018   class MappingTree;
00019   class MappingElement;
00020   class MappingRawData;
00021   class MappingRawElement;
00022 
00027   class MappingDatabase {
00028 
00029     public:
00030 
00031     static std::string versionOfClass( const Reflex::Type& dictionary );
00032     public:
00034     explicit MappingDatabase( IDatabaseSchema& schema );
00035 
00037     ~MappingDatabase();
00038 
00039     void setUp();
00040 
00041     std::string newMappingVersionForContainer( const std::string& className );
00042     
00043     std::string newMappingVersionForDependentClass( const std::string& containerName, const std::string& className );
00044 
00045     bool getMappingByVersion( const std::string& version, MappingTree& destination  );
00046     
00047     void removeMapping( const std::string& version );
00048 
00049     bool getMappingForContainer( const std::string& className, const std::string& classVersion, int containerId, MappingTree& destination  );
00050 
00051     bool getBaseMappingForContainer( const std::string& className, int containerId, MappingTree& destination  );
00052 
00053     bool getDependentMappingsForContainer( int containerId, std::vector<MappingElement>& destination  );
00054 
00055     bool getDependentClassesForContainer( int containerId, std::set<std::string>& list );
00056 
00057     bool getClassVersionListForMappingVersion( const std::string& mappingVersion, std::set<std::string>& destination );
00058 
00059     bool getClassVersionListForContainer( int containerId, std::map<std::string,std::string>& versionMap );
00060 
00061     void insertClassVersion( const Reflex::Type& dictionaryEntry, int dependencyIndex, int containerId, const std::string& mappingVersion, bool asBase=false );
00062 
00063     void insertClassVersion( const std::string& className, const std::string& classVersion, int dependencyIndex, int containerId, const std::string& mappingVersion, bool asBase=false );
00064 
00065     void setMappingVersionForClass( const Reflex::Type& dictionaryEntry, int containerId, const std::string& mappingVersion , bool dependency=false);
00066 
00067     void storeMapping( const MappingTree& mappingStructure );
00068     
00069     bool getMappingVersionsForContainer( int containerId, std::set<std::string>& versionList );
00070 
00071     const std::set<std::string>& versions();
00072     
00073     void clear();
00074     
00075     private:
00076     void buildElement( MappingElement& parentElement, const std::string& scopeName,
00077                        std::map<std::string,std::vector<MappingRawElement> >& innerElements );
00078     void unfoldElement( const MappingElement& element, MappingRawData& destination );
00079 
00080     private:
00081       
00083     IDatabaseSchema& m_schema;
00084     NamedSequence m_mappingSequence;
00085     std::set<std::string> m_versions;
00086     bool m_isLoaded;
00087 
00088   };
00089 
00090 }
00091 
00092 #endif