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 
30  public:
33  void takeNote( int contId, unsigned int size );
34  const std::map<int, unsigned int>& table();
35  void clear();
36  private:
37  std::map<int, unsigned int> m_table;
38  };
39 
41 
42  public:
44 
45  explicit DatabaseSession( boost::shared_ptr<ConnectionPool>& connectionPool );
46 
47  virtual ~DatabaseSession();
48 
49  bool connect( const std::string& connectionString, bool readOnly );
50 
51  void disconnect();
52 
53  bool isConnected();
54 
55  const std::string& connectionString();
56 
57  void startTransaction( bool readOnly );
58 
59  void commitTransaction();
60 
61  void rollbackTransaction();
62 
63  bool isTransactionActive( bool checkIfReadOnly=false );
64 
65  bool exists();
66 
67  void create();
68 
69  void drop();
70 
71  void open();
72 
73  Handle<DatabaseContainer> createContainer( const std::string& containerName, const Reflex::Type& type );
74 
75  Handle<ora::DatabaseContainer> addContainer( const std::string& containerName, const std::string& className );
76 
77  void dropContainer( const std::string& name );
78 
79  Handle<DatabaseContainer> containerHandle( const std::string& name );
80 
82 
83  const std::map<int, Handle<DatabaseContainer> >& containers();
84 
85  void setObjectName( const std::string& name, int containerId, int itemId );
86 
87  bool eraseObjectName( const std::string& name );
88 
89  bool eraseAllNames();
90 
91  bool getItemId( const std::string& name, OId& destination );
92 
93  Object fetchObjectByName( const std::string& name );
94 
95  boost::shared_ptr<void> fetchTypedObjectByName( const std::string& name, const Reflex::Type& asType );
96 
97  bool getNamesForContainer( int containerId, std::vector<std::string>& destination );
98 
99  bool getNamesForObject( int containerId, int itemId, std::vector<std::string>& destination );
100 
101  bool listObjectNames( std::vector<std::string>& destination );
102 
104 
105  public:
107 
109 
111 
113 
115 
116  public:
118  boost::shared_ptr<ConnectionPool>& connectionPool();
119 
120  private:
121  void clearTransaction();
122 
123  private:
124  boost::shared_ptr<ConnectionPool> m_connectionPool;
126  std::string m_connectionString;
127  std::auto_ptr<IDatabaseSchema> m_schema;
128  std::auto_ptr<NamedSequence> m_contIdSequence;
129  std::auto_ptr<MappingDatabase> m_mappingDb;
130  std::auto_ptr<TransactionCache> m_transactionCache;
133  };
134 
135 
136 }
137 
138 #endif
Handle< DatabaseContainer > containerHandle(const std::string &name)
const std::string & connectionString()
type
Definition: HCALResponse.h:22
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
bool eraseObjectName(const std::string &name)
Configuration m_configuration
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()
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)