38 return contType.Name( Reflex::SCOPED );
48 throwException(
"Container \""+name+
"\" does not exist in the database.",
49 "Database::insertItem");
83 if(
this != &rhs ) m_impl = rhs.
m_impl;
88 return m_impl->m_session->configuration();
93 return m_impl->m_session->connect( connectionString, readOnly );
97 const std::string& asRole,
99 return m_impl->m_session->connect( connectionString, asRole, readOnly );
103 m_impl->m_session->disconnect();
107 return m_impl->m_session->isConnected();
111 return m_impl->m_session->connectionString();
115 if(!m_impl->m_session->isConnected()) {
116 throwException(
"No database storage connected.",
"Database::transaction");
118 return *m_impl->m_transaction;
122 if(!m_impl->m_session->isConnected()) {
123 throwException(
"No database storage connected.",
"Database::checkTransaction");
125 if(!m_impl->m_transaction->isActive()) {
126 throwException(
"Transaction is not active.",
"Database::checkTransaction");
132 return m_impl->m_session->exists();
136 bool created =
false;
138 m_impl->m_session->create( userSchemaVersion );
145 bool dropped =
false;
148 const std::map<int, Handle<DatabaseContainer> >& conts = m_impl->m_session->containers();
150 iC != conts.end(); iC++ ){
153 m_impl->m_session->drop();
162 m_impl->m_session->setAccessPermission( principal, forWrite );
163 const std::map<int, Handle<DatabaseContainer> >& conts = m_impl->m_session->containers();
165 iC != conts.end(); iC++ ){
166 iC->second->setAccessPermission( principal, forWrite );
173 if( !m_impl->m_session->exists() ){
175 m_impl->m_session->create();
177 throwException(
"Database does not exists in \""+m_impl->m_session->connectionString()+
"\"",
"Database::open");
180 m_impl->m_session->open();
185 if( !m_impl->m_session->exists() ){
186 throwException(
"Database does not exists in \""+m_impl->m_session->connectionString()+
"\"",
"Database::schemaVersion");
193 std::set< std::string > contList;
194 const std::map<int, Handle<DatabaseContainer> >& conts = m_impl->m_session->containers();
196 iC != conts.end(); iC++ ){
197 contList.insert( iC->second->name() );
203 const std::type_info& typeInfo ){
205 if( m_impl->m_session->containerHandle( name ) ){
206 throwException(
"Container with name \""+name+
"\" already exists in the database.",
207 "Database::createContainer");
218 if( m_impl->m_session->containerHandle( name ) ){
219 throwException(
"Container with name \""+name+
"\" already exists in the database.",
220 "Database::createContainer");
230 if( name.empty() ) name = nameForContainer( className );
231 if( m_impl->m_session->containerHandle( name ) ){
232 throwException(
"Container with name \""+name+
"\" already exists in the database.",
233 "Database::createContainer");
240 const std::type_info& typeInfo){
255 if( !m_impl->m_session->containerHandle( name ) ){
258 m_impl->m_session->dropContainer( name );
266 throwException(
"Container \""+name+
"\" does not exist in the database.",
267 "Database::lockContainer");
276 throwException(
"Container \""+name+
"\" does not exist in the database.",
277 "Database::containerHandle");
286 std::stringstream messg;
287 messg <<
"Container with id=" << contId <<
" not found in the database.";
289 "Database::containerHandle");
300 const Object& dataObject ){
304 return OId( cont.
id(), itemId );
308 const Object& dataObject ){
322 const std::map<int,Handle<DatabaseContainer> >& containers = m_impl->m_session->containers();
324 iCont != containers.end(); ++iCont ){
325 iCont->second->flush();
336 return m_impl->m_session->eraseObjectName( name );
341 return m_impl->m_session->eraseAllNames();
346 return m_impl->m_session->getItemId( name, destination );
352 return m_impl->m_session->fetchTypedObjectByName( name, objType );
357 return m_impl->m_session->fetchObjectByName( name );
361 std::vector<std::string>& destination ){
363 if( !m_impl->m_session->exists() ){
364 throwException(
"Database does not exists in \""+m_impl->m_session->connectionString()+
"\"",
"Database::getNamesForObject");
366 return m_impl->m_session->getNamesForObject( oid.
containerId(), oid.
itemId(), destination );
371 if( !m_impl->m_session->exists() ){
372 throwException(
"Database does not exists in \""+m_impl->m_session->connectionString()+
"\"",
"Database::listObjectNames");
374 return m_impl->m_session->listObjectNames( destination );
384 return m_impl->m_session->storageAccessSession();
Handle< DatabaseContainer > containerHandle(const std::string &name)
bool create(std::string userSchemaVersion=std::string(""))
std::auto_ptr< DatabaseSession > m_session
bool getFlag(const std::string &flagName) const
void updateItem(int itemId, const Object &data)
Object fetchItemByName(const std::string &name)
EcalChannelStatus Container
std::string nameFromClass(const Reflex::Type &contType)
static Version fromString(const std::string &versionString)
Properties & properties()
const std::string & connectionString()
int insertItem(const Object &data)
bool getItemId(const std::string &name, OId &destination)
std::auto_ptr< Transaction > m_transaction
ora::Version schemaVersion(bool userSchema=false)
static std::string automaticContainerCreation()
void open(bool writingAccess=false)
Object fetchItem(int itemId)
static std::string automaticDatabaseCreation()
bool lockContainer(const std::string &name)
Transaction & transaction()
SharedSession & storageAccessSession()
void erase(const OId &oid)
Object fetchItem(const OId &oid)
Container containerHandle(const std::string &name)
std::set< std::string > containers()
bool dropContainer(const std::string &name)
DatabaseImpl(boost::shared_ptr< ConnectionPool > &connectionPool)
Container createContainer()
boost::shared_ptr< DatabaseImpl > m_impl
DatabaseUtility utility()
bool getNamesForObject(const OId &oid, std::vector< std::string > &destination)
OId insertItem(const std::string &containerName, const Object &data)
Database & operator=(const Database &rhs)
Handle< DatabaseContainer > createContainer(const std::string &containerName, const Reflex::Type &type)
bool connect(const std::string &connectionString, bool readOnly=false)
bool eraseObjectName(const std::string &name)
Configuration & configuration()
static std::string nameForContainer(const std::type_info &typeInfo)
const Reflex::Type & type() const
bool listObjectNames(std::vector< std::string > &destination)
void throwException(const std::string &message, const std::string &methodName)
Container getContainerFromSession(const std::string &name, const Reflex::Type &contType, DatabaseSession &session)
boost::shared_ptr< void > getTypedObjectByName(const std::string &name, const std::type_info &typeInfo)
Configuration & configuration()
Reflex::Type lookupDictionary(const std::type_info &typeInfo, bool throwFlag=true)
void updateItem(const OId &oid, const Object &data)
void setObjectName(const std::string &name, const OId &oid)
std::string className(const T &t)
Container getContainer(const std::string &name, const std::type_info &typeInfo)
void setAccessPermission(const std::string &principal, bool forWrite)