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 Reflex {
15  class Type;
16 }
17 
18 namespace ora {
19 
20  class Configuration;
21  class ConnectionPool;
22  class NamedSequence;
23  class MappingDatabase;
24  class IDatabaseSchema;
25  class TransactionCache;
26  class DatabaseContainer;
27  class DatabaseUtilitySession;
28  class SessionMonitoringData;
29 
31  public:
34  void takeNote( int contId, unsigned int size );
35  void remove( int contId );
36  const std::map<int, unsigned int>& table();
37  void clear();
38  private:
39  std::map<int, unsigned int> m_table;
40  };
41 
43 
44  public:
46 
47  explicit DatabaseSession( boost::shared_ptr<ConnectionPool>& connectionPool );
48 
49  virtual ~DatabaseSession();
50 
51  bool connect( const std::string& connectionString, bool readOnly );
52  bool connect( const std::string& connectionString, const std::string& asRole, bool readOnly );
53 
54  void disconnect();
55 
56  bool isConnected();
57 
59 
60  void startTransaction( bool readOnly );
61 
62  void commitTransaction();
63 
64  void rollbackTransaction();
65 
66  bool isTransactionActive( bool checkIfReadOnly=false );
67 
68  bool exists();
69 
70  void create( const std::string& userSchemaVersion = std::string("") );
71 
72  void drop();
73 
74  void setAccessPermission( const std::string& principal, bool forWrite );
75 
76  bool testDropPermission();
77 
78  void open();
79 
80  std::string schemaVersion( bool userSchema );
81 
83 
85 
86  void dropContainer( const std::string& name );
87 
89 
91 
92  const std::map<int, Handle<DatabaseContainer> >& containers();
93 
94  void setObjectName( const std::string& name, int containerId, int itemId );
95 
96  bool eraseObjectName( const std::string& name );
97 
98  bool eraseAllNames();
99 
100  bool getItemId( const std::string& name, OId& destination );
101 
102  Object fetchObjectByName( const std::string& name );
103 
104  boost::shared_ptr<void> fetchTypedObjectByName( const std::string& name, const Reflex::Type& asType );
105 
106  bool getNamesForContainer( int containerId, std::vector<std::string>& destination );
107 
108  bool getNamesForObject( int containerId, int itemId, std::vector<std::string>& destination );
109 
110  bool listObjectNames( std::vector<std::string>& destination );
111 
113 
114  public:
116 
118 
120 
122 
124 
125  public:
127  boost::shared_ptr<ConnectionPool>& connectionPool();
128 
129  private:
130  void clearTransaction();
131 
132  private:
133  boost::shared_ptr<ConnectionPool> m_connectionPool;
136  std::auto_ptr<IDatabaseSchema> m_schema;
137  std::auto_ptr<NamedSequence> m_contIdSequence;
138  std::auto_ptr<MappingDatabase> m_mappingDb;
139  std::auto_ptr<TransactionCache> m_transactionCache;
143  };
144 
145 
146 }
147 
148 #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)
boost::shared_ptr< void > fetchTypedObjectByName(const std::string &name, const Reflex::Type &asType)
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 Reflex::Type &type)
std::auto_ptr< NamedSequence > m_contIdSequence
Configuration & configuration()
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)