test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PoolDatabaseSchema.h
Go to the documentation of this file.
1 #ifndef INCLUDE_ORA_POOLDATABASESCHEMA_H
2 #define INCLUDE_ORA_POOLDATABASESCHEMA_H
3 
4 #include "IDatabaseSchema.h"
5 // externals
6 #include "CoralBase/AttributeList.h"
7 
8 namespace ora {
9 
10  struct PoolDbCacheData {
12 
13  PoolDbCacheData( int id, const std::string& name, const std::string& className,
14  const std::string& mappingVersion, unsigned int nobjWritten );
15 
17 
18  PoolDbCacheData( const PoolDbCacheData& rhs );
19 
21 
22  int m_id;
26  unsigned int m_nobjWr;
27  };
28 
29  class PoolDbCache {
30  public:
31  PoolDbCache();
32  ~PoolDbCache();
33  void add( int id, const PoolDbCacheData& data );
34  const std::string& nameById( int id );
35  int idByName( const std::string& name );
36  PoolDbCacheData& find( int id );
37  void remove( int id );
38  std::map<std::string,PoolDbCacheData* >& sequences();
39  void clear();
40 
41  private:
44  std::map<int,PoolDbCacheData > m_idMap;
45  std::map<std::string,PoolDbCacheData* > m_sequences;
46  };
47 
48  class PoolMainTable: public IMainTable {
49  public:
50  static std::string version();
51  static std::string tableName();
52  public:
53  explicit PoolMainTable( coral::ISchema& dbSchema );
54  virtual ~PoolMainTable();
55  void setParameter( const std::string& paramName, const std::string& paramValue );
56  bool getParameters( std::map<std::string,std::string>& destination );
58  public:
59  std::string name();
60  bool exists();
61  void create();
62  void drop();
63  };
64 
65 
67  public:
68  static std::string tableName();
71  public:
72  explicit PoolSequenceTable( coral::ISchema& dbSchema );
73  virtual ~PoolSequenceTable();
74  void init( PoolDbCache& dbCache );
75  bool add( const std::string& sequenceName );
76  bool getLastId( const std::string& sequenceName, int& lastId );
77  void sinchronize( const std::string& sequenceName, int lastValue );
78  void erase( const std::string& sequenceName );
79  public:
80  std::string name();
81  bool exists();
82  void create();
83  void drop();
84  private:
86  };
87 
89  public:
90  static std::string tableName();
93  public:
94  explicit PoolMappingVersionTable( coral::ISchema& dbSchema );
95  virtual ~PoolMappingVersionTable();
96  public:
97  std::string name();
98  bool exists();
99  void create();
100  void drop();
101  };
102 
104  public:
105  static std::string tableName();
107  static std::string elementIdColumn();
109  static std::string scopeNameColumn();
113  static std::string tableNameColumn();
114  static std::string columnNameColumn();
115  public:
116  explicit PoolMappingElementTable( coral::ISchema& dbSchema );
117  virtual ~PoolMappingElementTable();
118  public:
119  std::string name();
120  bool exists();
121  void create();
122  void drop();
123  };
124 
126  public:
127  static std::string tableName();
131  static std::string tableNameColumn();
132  static std::string classNameColumn();
137  public:
138  explicit PoolContainerHeaderTable( coral::ISchema& dbSchema );
139  virtual ~PoolContainerHeaderTable();
140  void init( PoolDbCache& dbCache );
141  bool getContainerData( std::map<std::string, ContainerHeaderData>& destination );
142  void addContainer( int id, const std::string& containerName, const std::string& className );
143  void removeContainer( int id );
144  bool lockContainer( int id, ContainerHeaderData& destination );
145  void incrementNumberOfObjects( int id );
146  void decrementNumberOfObjects( int id );
147  void updateNumberOfObjects( const std::map<int,unsigned int>& numberOfObjectsForContainerIds );
148  public:
149  std::string name();
150  bool exists();
151  void create();
152  void drop();
153  private:
155  };
156 
158  public:
159  static std::string tableName();
163  public:
164  explicit PoolClassVersionTable( coral::ISchema& dbSchema );
165  virtual ~PoolClassVersionTable();
166  public:
167  std::string name();
168  bool exists();
169  void create();
170  void drop();
171  };
172 
174  public:
175  static std::string emptyScope();
176  public:
177  explicit PoolMappingSchema( coral::ISchema& dbSchema );
178  virtual ~PoolMappingSchema();
179  void init( PoolDbCache& dbCache );
180  public:
181  bool getVersionList( std::set<std::string>& destination );
182  bool getMapping( const std::string& version, MappingRawData& destination );
183  void storeMapping( const MappingRawData& mapping );
184  void removeMapping( const std::string& version );
185  bool getContainerTableMap( std::map<std::string, int>& destination );
186  bool getMappingVersionListForContainer( int containerId, std::set<std::string>& destination, bool onlyDependency=false );
187  bool getMappingVersionListForTable( const std::string& tableName, std::set<std::string>& destination );
188  bool getDependentClassesInContainerMapping( int containerId, std::set<std::string>& destination );
189  bool getClassVersionListForMappingVersion( const std::string& mappingVersion, std::set<std::string>& destination );
190  bool getClassVersionListForContainer( int containerId, std::map<std::string,std::string>& versionMap );
191  bool selectMappingVersion( const std::string& classId, int containerId, std::string& destination );
192  bool containerForMappingVersion( const std::string& mappingVersion, int& destination );
193  void insertClassVersion( const std::string& className, const std::string& classVersion, const std::string& classId,
194  int dependencyIndex, int containerId, const std::string& mappingVersion );
195  void setMappingVersion( const std::string& classId, int containerId, const std::string& mappingVersion );
196  private:
197  coral::ISchema& m_schema;
199  };
200 
202  public:
203  static std::string tableName();
204  static std::string objectNameColumn();
205  static std::string tokenColumn();
206  static std::string timetypeColumn();
207  public:
208  CondMetadataTable( coral::ISchema& dbSchema, PoolDbCache& dbCache );
209  virtual ~CondMetadataTable();
210  void setObjectName( const std::string& name, int contId, int itemId );
211  bool eraseObjectName( const std::string& name );
212  bool eraseAllNames();
213  bool getObjectByName( const std::string& name, std::pair<int,int>& destination );
214  bool getNamesForObject( int contId, int itemId, std::vector<std::string>& destination );
215  bool getNamesForContainer( int contId, std::vector<std::string>& destination );
216  bool getAllNames( std::vector<std::string>& destination );
217  public:
218  std::string name();
219  bool exists();
220  void create();
221  void drop();
222  private:
224  };
225 
227  public:
228  static bool existsMainTable( coral::ISchema& dbSchema );
229  public:
230  explicit PoolDatabaseSchema( coral::ISchema& dbSchema );
231  virtual ~PoolDatabaseSchema();
232 
233  bool exists();
234  void create( const std::string& userSchemaVersion );
235  void drop();
236  void setAccessPermission( const std::string& principal, bool forWrite );
237 
247  return false;
248  }
249 
250  private:
251  coral::ISchema& m_schema;
261  };
262 
263 }
264 
265 #endif
266 
267 
IDatabaseTable & mappingElementTable()
IMappingSchema & mappingSchema()
void init(PoolDbCache &dbCache)
static std::string numberOfWrittenObjectsColumn()
static std::string tableName()
bool getNamesForObject(int contId, int itemId, std::vector< std::string > &destination)
static std::string tableNameColumn()
static std::string tableName()
static std::string variableTypeColumn()
PoolDbCacheData m_mappingData
PoolMappingSchema m_mappingSchema
static std::string containerNameColumn()
std::map< std::string, PoolDbCacheData * > & sequences()
PoolSequenceTable(coral::ISchema &dbSchema)
static std::string containerTypeColumn()
void setObjectName(const std::string &name, int contId, int itemId)
PoolDbCacheData m_databaseData
static std::string columnNameColumn()
static std::string baseMappingVersionColumn()
PoolClassVersionTable m_classVersionTable
PoolMappingSchema(coral::ISchema &dbSchema)
int idByName(const std::string &name)
static std::string mappingVersionColumn()
void init(PoolDbCache &dbCache)
void updateNumberOfObjects(const std::map< int, unsigned int > &numberOfObjectsForContainerIds)
std::map< std::string, PoolDbCacheData * > m_sequences
void setAccessPermission(const std::string &principal, bool forWrite)
static std::string tableNameColumn()
INamingServiceTable & namingServiceTable()
void removeMapping(const std::string &version)
static std::string containerIdColumn()
PoolMappingElementTable m_mappingElementTable
bool getContainerData(std::map< std::string, ContainerHeaderData > &destination)
void sinchronize(const std::string &sequenceName, int lastValue)
bool getClassVersionListForContainer(int containerId, std::map< std::string, std::string > &versionMap)
void add(int id, const PoolDbCacheData &data)
PoolSequenceTable m_sequenceTable
bool getContainerTableMap(std::map< std::string, int > &destination)
static std::string variableParIndexColumn()
CondMetadataTable m_metadataTable
static std::string tokenColumn()
static std::string emptyScope()
std::map< int, PoolDbCacheData > m_idMap
static std::string classVersionColumn()
IDatabaseTable & mappingVersionTable()
void create(const std::string &userSchemaVersion)
bool selectMappingVersion(const std::string &classId, int containerId, std::string &destination)
PoolMappingElementTable(coral::ISchema &dbSchema)
void setMappingVersion(const std::string &classId, int containerId, const std::string &mappingVersion)
static std::string elementIdColumn()
bool eraseObjectName(const std::string &name)
bool getMappingVersionListForContainer(int containerId, std::set< std::string > &destination, bool onlyDependency=false)
bool getMapping(const std::string &version, MappingRawData &destination)
static std::string numberOfDeletedObjectsColumn()
void setParameter(const std::string &paramName, const std::string &paramValue)
bool containerForMappingVersion(const std::string &mappingVersion, int &destination)
static bool existsMainTable(coral::ISchema &dbSchema)
static std::string version()
static std::string objectNameColumn()
PoolDbCacheData & find(int id)
bool getParameters(std::map< std::string, std::string > &destination)
PoolClassVersionTable(coral::ISchema &dbSchema)
static std::string timetypeColumn()
bool getLastId(const std::string &sequenceName, int &lastId)
static std::string homogeneousContainerType()
PoolContainerHeaderTable(coral::ISchema &dbSchema)
static std::string sequenceNameColumn()
PoolDbCacheData & operator=(const PoolDbCacheData &rhs)
static std::string classNameColumn()
static std::string sequenceValueColumn()
IContainerHeaderTable & containerHeaderTable()
void init(PoolDbCache &dbCache)
PoolMappingVersionTable(coral::ISchema &dbSchema)
bool getAllNames(std::vector< std::string > &destination)
bool lockContainer(int id, ContainerHeaderData &destination)
bool getClassVersionListForMappingVersion(const std::string &mappingVersion, std::set< std::string > &destination)
const std::string & nameById(int id)
PoolDatabaseSchema(coral::ISchema &dbSchema)
static std::string mappingVersionColumn()
PoolMainTable(coral::ISchema &dbSchema)
PoolMappingVersionTable m_mappingVersionTable
void addContainer(int id, const std::string &containerName, const std::string &className)
static std::string containerNameColumn()
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
static std::string scopeNameColumn()
PoolContainerHeaderTable m_containerHeaderTable
void storeMapping(const MappingRawData &mapping)
static std::string variableNameColumn()
bool getMappingVersionListForTable(const std::string &tableName, std::set< std::string > &destination)
void insertClassVersion(const std::string &className, const std::string &classVersion, const std::string &classId, int dependencyIndex, int containerId, const std::string &mappingVersion)
bool getVersionList(std::set< std::string > &destination)
static std::string tableName()
bool add(const std::string &sequenceName)
static std::string mappingVersionColumn()
static std::string containerNameColumn()
IDatabaseTable & classVersionTable()
bool getNamesForContainer(int contId, std::vector< std::string > &destination)
ISequenceTable & sequenceTable()
static std::string elementTypeColumn()
CondMetadataTable(coral::ISchema &dbSchema, PoolDbCache &dbCache)
bool getObjectByName(const std::string &name, std::pair< int, int > &destination)
std::string className(const T &t)
Definition: ClassName.h:30
std::string schemaVersion()
bool getDependentClassesInContainerMapping(int containerId, std::set< std::string > &destination)
void erase(const std::string &sequenceName)
static std::string tableName()