CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
IDatabaseSchema.h
Go to the documentation of this file.
1 #ifndef INCLUDE_ORA_IDATABASESCHEMA_H
2 #define INCLUDE_ORA_IDATABASESCHEMA_H
3 
4 //
5 #include <string>
6 #include <map>
7 #include <set>
8 #include <vector>
9 
10 namespace coral {
11  class ISchema;
12  class ITable;
13 }
14 
15 namespace ora {
16 
17  std::string poolSchemaVersion();
18 
19  void setTableAccessPermission( coral::ITable& table, const std::string& principal, bool forWrite );
20 
22  public:
23  explicit IDatabaseTable( coral::ISchema& schema );
24  virtual ~IDatabaseTable(){}
25 
26  virtual std::string name() = 0;
27  virtual bool exists() = 0;
28  virtual void create( ) = 0;
29  virtual void drop() = 0;
30  virtual void setAccessPermission( const std::string& principal, bool forWrite );
31  coral::ISchema& schema();
32  private:
33  coral::ISchema& m_schema;
34 
35  };
36 
37  class IMainTable: public IDatabaseTable {
38  public:
39  static std::string versionParameterName();
40  static std::string userSchemaVersionParameterName();
41  public:
42  explicit IMainTable( coral::ISchema& schema );
43  virtual ~IMainTable(){}
44  virtual void setParameter( const std::string& paramName, const std::string& paramValue ) = 0;
45  virtual bool getParameters( std::map<std::string,std::string>& destination ) = 0;
46  virtual std::string schemaVersion() = 0;
47  };
48 
50  public:
51  explicit ISequenceTable( coral::ISchema& schema );
52  virtual ~ISequenceTable(){
53  }
54 
55  virtual bool add( const std::string& sequenceName ) = 0;
56  virtual bool getLastId( const std::string& sequenceName, int& lastId ) = 0;
57  virtual void sinchronize( const std::string& sequenceName, int lastValue ) = 0;
58  virtual void erase( const std::string& sequenceName ) = 0;
59  };
60 
62  static std::string emptyScope();
66  std::string scopeName;
67  std::string variableName;
68  std::string variableType;
69  std::string elementType;
70  std::string tableName;
71  std::vector<std::string> columns;
72  };
73 
74  struct MappingRawData {
76  explicit MappingRawData( const std::string& version );
77  MappingRawElement& addElement( int elementId );
78  std::string version;
79  std::map< int, MappingRawElement> elements;
80  };
81 
82 
85  ContainerHeaderData( int contId,
86  const std::string& classN,
87  unsigned int numberObj );
90  int id;
91  std::string className;
92  unsigned int numberOfObjects;
93  };
94 
96  public:
97  explicit IContainerHeaderTable( coral::ISchema& schema );
99  }
100  virtual bool getContainerData( std::map<std::string, ContainerHeaderData>& destination ) = 0;
101  virtual void addContainer( int id, const std::string& containerName, const std::string& className ) = 0;
102  virtual void removeContainer( int id ) = 0;
103  virtual bool lockContainer( int id, ContainerHeaderData& destination ) = 0;
104  virtual void incrementNumberOfObjects( int id ) = 0;
105  virtual void decrementNumberOfObjects( int id ) = 0;
106  virtual void updateNumberOfObjects( const std::map<int,unsigned int>& numberOfObjectsForContainerIds ) = 0;
107  };
108 
110  public:
111  virtual ~IMappingSchema(){
112  }
113  virtual bool getVersionList( std::set<std::string>& destination ) = 0;
114  virtual bool getMapping( const std::string& version, MappingRawData& destination ) = 0;
115  virtual void storeMapping( const MappingRawData& data ) = 0;
116  virtual void removeMapping( const std::string& version ) = 0;
117  virtual bool getContainerTableMap( std::map<std::string, int>& destination ) = 0;
118  virtual bool getMappingVersionListForContainer( int containerId, std::set<std::string>& destination, bool onlyDependency=false ) = 0;
119  virtual bool getDependentClassesInContainerMapping( int containerId, std::set<std::string>& destination ) = 0;
120  virtual bool getClassVersionListForMappingVersion( const std::string& mappingVersion, std::set<std::string>& destination ) = 0;
121  virtual bool getClassVersionListForContainer( int containerId, std::map<std::string,std::string>& versionMap ) = 0;
122  virtual bool getMappingVersionListForTable( const std::string& tableName, std::set<std::string>& destination ) = 0;
123  virtual bool selectMappingVersion( const std::string& classId, int containerId, std::string& destination ) = 0;
124  virtual bool containerForMappingVersion( const std::string& mappingVersion, int& destination ) = 0;
125  virtual void insertClassVersion( const std::string& className, const std::string& classVersion, const std::string& classId,
126  int dependencyIndex, int containerId, const std::string& mappingVersion )= 0;
127  virtual void setMappingVersion( const std::string& classId, int containerId, const std::string& mappingVersion ) = 0;
128  };
129 
131  public:
132  explicit INamingServiceTable( coral::ISchema& schema );
134  }
135  virtual void setObjectName( const std::string& name, int contId, int itemId ) = 0;
136  virtual bool eraseObjectName( const std::string& name ) = 0;
137  virtual bool eraseAllNames() = 0;
138  virtual bool getObjectByName( const std::string& name, std::pair<int,int>& destination ) = 0;
139  virtual bool getNamesForObject( int contId, int itemId, std::vector<std::string>& destination ) = 0;
140  virtual bool getNamesForContainer( int contId, std::vector<std::string>& destination ) = 0;
141  virtual bool getAllNames( std::vector<std::string>& destination ) = 0;
142  };
143 
145  public:
146 
147  static IDatabaseSchema* createSchemaHandle( coral::ISchema& schema );
148 
149  public:
150  IDatabaseSchema( coral::ISchema& schema );
151  virtual ~IDatabaseSchema(){
152  }
153 
154  virtual bool exists() = 0;
155  virtual void create( const std::string& userSchemaVersion ) = 0;
156  virtual void drop() = 0;
157  virtual void setAccessPermission( const std::string& userName, bool forWrite ) = 0;
158 
159  virtual IMainTable& mainTable() = 0;
160  virtual ISequenceTable& sequenceTable() = 0;
161  virtual IDatabaseTable& mappingVersionTable() = 0;
162  virtual IDatabaseTable& mappingElementTable() = 0;
164  virtual IDatabaseTable& classVersionTable() = 0;
165  virtual IMappingSchema& mappingSchema() = 0;
167  virtual bool testDropPermission() = 0;
168  coral::ISchema& storageSchema();
169 
170  private:
171  coral::ISchema& m_schema;
172  };
173 
174 }
175 
176 #endif
177 
178 
179 
static std::string versionParameterName()
list table
Definition: asciidump.py:386
virtual bool getAllNames(std::vector< std::string > &destination)=0
virtual void removeContainer(int id)=0
static std::string userSchemaVersionParameterName()
virtual bool getNamesForContainer(int contId, std::vector< std::string > &destination)=0
MappingRawElement & addElement(int elementId)
virtual void incrementNumberOfObjects(int id)=0
std::vector< std::string > columns
virtual ~IMainTable()
virtual std::string schemaVersion()=0
virtual std::string name()=0
virtual bool getMapping(const std::string &version, MappingRawData &destination)=0
virtual bool getVersionList(std::set< std::string > &destination)=0
virtual bool eraseAllNames()=0
virtual void sinchronize(const std::string &sequenceName, int lastValue)=0
virtual bool selectMappingVersion(const std::string &classId, int containerId, std::string &destination)=0
virtual bool getLastId(const std::string &sequenceName, int &lastId)=0
IContainerHeaderTable(coral::ISchema &schema)
std::map< int, MappingRawElement > elements
void setTableAccessPermission(coral::ITable &table, const std::string &principal, bool forWrite)
virtual void setParameter(const std::string &paramName, const std::string &paramValue)=0
virtual void erase(const std::string &sequenceName)=0
virtual bool getObjectByName(const std::string &name, std::pair< int, int > &destination)=0
INamingServiceTable(coral::ISchema &schema)
virtual bool testDropPermission()=0
virtual void setMappingVersion(const std::string &classId, int containerId, const std::string &mappingVersion)=0
virtual IDatabaseTable & classVersionTable()=0
std::string poolSchemaVersion()
virtual void updateNumberOfObjects(const std::map< int, unsigned int > &numberOfObjectsForContainerIds)=0
virtual bool getMappingVersionListForTable(const std::string &tableName, std::set< std::string > &destination)=0
virtual void setAccessPermission(const std::string &userName, bool forWrite)=0
virtual void addContainer(int id, const std::string &containerName, const std::string &className)=0
virtual INamingServiceTable & namingServiceTable()=0
static IDatabaseSchema * createSchemaHandle(coral::ISchema &schema)
static std::string emptyScope()
virtual bool getContainerTableMap(std::map< std::string, int > &destination)=0
virtual IDatabaseTable & mappingVersionTable()=0
coral::ISchema & m_schema
virtual void create()=0
virtual void storeMapping(const MappingRawData &data)=0
coral::ISchema & storageSchema()
virtual bool eraseObjectName(const std::string &name)=0
virtual bool add(const std::string &sequenceName)=0
IDatabaseSchema(coral::ISchema &schema)
IMainTable(coral::ISchema &schema)
virtual bool getClassVersionListForContainer(int containerId, std::map< std::string, std::string > &versionMap)=0
coral::ISchema & m_schema
virtual void create(const std::string &userSchemaVersion)=0
IDatabaseTable(coral::ISchema &schema)
virtual bool lockContainer(int id, ContainerHeaderData &destination)=0
ContainerHeaderData & operator=(const ContainerHeaderData &rhs)
coral::ISchema & schema()
virtual IMappingSchema & mappingSchema()=0
virtual void insertClassVersion(const std::string &className, const std::string &classVersion, const std::string &classId, int dependencyIndex, int containerId, const std::string &mappingVersion)=0
virtual void drop()=0
ISequenceTable(coral::ISchema &schema)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
virtual bool exists()=0
virtual bool getClassVersionListForMappingVersion(const std::string &mappingVersion, std::set< std::string > &destination)=0
virtual ISequenceTable & sequenceTable()=0
MappingRawElement & operator==(const MappingRawElement &rhs)
virtual bool containerForMappingVersion(const std::string &mappingVersion, int &destination)=0
virtual void setAccessPermission(const std::string &principal, bool forWrite)
virtual bool exists()=0
virtual bool getParameters(std::map< std::string, std::string > &destination)=0
virtual IContainerHeaderTable & containerHeaderTable()=0
virtual bool getNamesForObject(int contId, int itemId, std::vector< std::string > &destination)=0
virtual void setObjectName(const std::string &name, int contId, int itemId)=0
virtual bool getContainerData(std::map< std::string, ContainerHeaderData > &destination)=0
virtual void decrementNumberOfObjects(int id)=0
virtual bool getDependentClassesInContainerMapping(int containerId, std::set< std::string > &destination)=0
virtual IDatabaseTable & mappingElementTable()=0
virtual void removeMapping(const std::string &version)=0
std::string className(const T &t)
Definition: ClassName.h:30
virtual bool getMappingVersionListForContainer(int containerId, std::set< std::string > &destination, bool onlyDependency=false)=0
virtual void drop()=0
virtual IMainTable & mainTable()=0