CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DatabaseSession.h
Go to the documentation of this file.
1 #ifndef INCLUDE_ORA_DATABASESESSION_H
2 #define INCLUDE_ORA_DATABASESESSION_H
3 
9 //
10 #include <string>
11 #include <memory>
12 #include <map>
13 
14 namespace edm {
15  class TypeWithDict;
16 }
17 namespace coral {
18  class ISessionProxy;
19 }
20 
21 namespace ora {
22 
23  class Configuration;
24  class ConnectionPool;
25  class NamedSequence;
26  class MappingDatabase;
27  class IDatabaseSchema;
28  class TransactionCache;
29  class DatabaseContainer;
30  class DatabaseUtilitySession;
31  class SessionMonitoringData;
32 
34  public:
37  void takeNote( int contId, unsigned int size );
38  void remove( int contId );
39  const std::map<int, unsigned int>& table();
40  void clear();
41  private:
42  std::map<int, unsigned int> m_table;
43  };
44 
46 
47  public:
49 
50  explicit DatabaseSession( boost::shared_ptr<ConnectionPool>& connectionPool );
51 
52  virtual ~DatabaseSession();
53 
54  bool connect( const std::string& connectionString, bool readOnly );
55  bool connect( const std::string& connectionString, const std::string& asRole, bool readOnly );
56  bool connect( boost::shared_ptr<coral::ISessionProxy>& coralSession, const std::string& connectionString, const std::string& schemaName );
57 
58  void disconnect();
59 
60  bool isConnected();
61 
63 
64  void startTransaction( bool readOnly );
65 
66  void commitTransaction();
67 
68  void rollbackTransaction();
69 
70  bool isTransactionActive( bool checkIfReadOnly=false );
71 
72  bool exists();
73 
74  void create( const std::string& userSchemaVersion = std::string("") );
75 
76  void drop();
77 
78  void setAccessPermission( const std::string& principal, bool forWrite );
79 
80  bool testDropPermission();
81 
82  void open();
83 
84  std::string schemaVersion( bool userSchema );
85 
87 
89 
90  void dropContainer( const std::string& name );
91 
93 
95 
96  const std::map<int, Handle<DatabaseContainer> >& containers();
97 
98  void setObjectName( const std::string& name, int containerId, int itemId );
99 
100  bool eraseObjectName( const std::string& name );
101 
102  bool eraseAllNames();
103 
104  bool getItemId( const std::string& name, OId& destination );
105 
106  Object fetchObjectByName( const std::string& name );
107 
108  boost::shared_ptr<void> fetchTypedObjectByName( const std::string& name, const edm::TypeWithDict& asType );
109 
110  bool getNamesForContainer( int containerId, std::vector<std::string>& destination );
111 
112  bool getNamesForObject( int containerId, int itemId, std::vector<std::string>& destination );
113 
114  bool listObjectNames( std::vector<std::string>& destination );
115 
117 
118  public:
120 
122 
124 
126 
128 
129  public:
131  boost::shared_ptr<ConnectionPool>& connectionPool();
132 
133  private:
134  void clearTransaction();
135 
136  private:
137  boost::shared_ptr<ConnectionPool> m_connectionPool;
139  bool m_ownedTransaction = true;
142  std::auto_ptr<IDatabaseSchema> m_schema;
143  std::auto_ptr<NamedSequence> m_contIdSequence;
144  std::auto_ptr<MappingDatabase> m_mappingDb;
145  std::auto_ptr<TransactionCache> m_transactionCache;
149  };
150 
151 
152 }
153 
154 #endif
Handle< DatabaseContainer > containerHandle(const std::string &name)
const std::string & connectionString()
type
Definition: HCALResponse.h:21
SessionMonitoringData * m_monitoring
Object fetchObjectByName(const std::string &name)
bool listObjectNames(std::vector< std::string > &destination)
std::auto_ptr< TransactionCache > m_transactionCache
void takeNote(int contId, unsigned int size)
SharedSession & storageAccessSession()
boost::shared_ptr< ConnectionPool > & connectionPool()
bool getItemId(const std::string &name, OId &destination)
void dropContainer(const std::string &name)
Definition: OId.h:8
const std::map< int, unsigned int > & table()
SharedSession m_dbSession
std::string schemaVersion(bool userSchema)
bool eraseObjectName(const std::string &name)
Configuration m_configuration
void setAccessPermission(const std::string &principal, bool forWrite)
bool connect(const std::string &connectionString, bool readOnly)
IDatabaseSchema & schema()
bool getNamesForContainer(int containerId, std::vector< std::string > &destination)
Handle< DatabaseUtilitySession > utility()
std::auto_ptr< IDatabaseSchema > m_schema
ContainerUpdateTable & containerUpdateTable()
ContainerUpdateTable m_containerUpdateTable
std::string m_connectionString
void setObjectName(const std::string &name, int containerId, int itemId)
bool getNamesForObject(int containerId, int itemId, std::vector< std::string > &destination)
const std::map< int, Handle< DatabaseContainer > > & containers()
void startTransaction(bool readOnly)
NamedSequence & containerIdSequence()
MappingDatabase & mappingDatabase()
void create(const std::string &userSchemaVersion=std::string(""))
std::map< int, unsigned int > m_table
bool isTransactionActive(bool checkIfReadOnly=false)
std::auto_ptr< MappingDatabase > m_mappingDb
Handle< DatabaseContainer > createContainer(const std::string &containerName, const edm::TypeWithDict &type)
std::auto_ptr< NamedSequence > m_contIdSequence
Configuration & configuration()
boost::shared_ptr< void > fetchTypedObjectByName(const std::string &name, const edm::TypeWithDict &asType)
tuple size
Write out results.
std::string className(const T &t)
Definition: ClassName.h:30
boost::shared_ptr< ConnectionPool > m_connectionPool
Handle< ora::DatabaseContainer > addContainer(const std::string &containerName, const std::string &className)