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 m_impl->m_session->disconnect();
101 return m_impl->m_session->isConnected();
105 return m_impl->m_session->connectionString();
109 if(!m_impl->m_session->isConnected()) {
110 throwException(
"No database storage connected.",
"Database::transaction");
112 return *m_impl->m_transaction;
116 if(!m_impl->m_session->isConnected()) {
117 throwException(
"No database storage connected.",
"Database::checkTransaction");
119 if(!m_impl->m_transaction->isActive()) {
120 throwException(
"Transaction is not active.",
"Database::checkTransaction");
126 return m_impl->m_session->exists();
130 bool created =
false;
132 m_impl->m_session->create();
142 const std::map<int, Handle<DatabaseContainer> >& conts = m_impl->m_session->containers();
144 iC != conts.end(); iC++ ){
147 m_impl->m_session->drop();
155 if( !m_impl->m_session->exists() ){
157 m_impl->m_session->create();
159 throwException(
"Database does not exists in \""+m_impl->m_session->connectionString()+
"\"",
"Database::open");
162 m_impl->m_session->open();
167 std::set< std::string > contList;
168 const std::map<int, Handle<DatabaseContainer> >& conts = m_impl->m_session->containers();
170 iC != conts.end(); iC++ ){
171 contList.insert( iC->second->name() );
177 const std::type_info& typeInfo ){
179 if( m_impl->m_session->containerHandle( name ) ){
180 throwException(
"Container with name \""+name+
"\" already exists in the database.",
181 "Database::createContainer");
192 if( m_impl->m_session->containerHandle( name ) ){
193 throwException(
"Container with name \""+name+
"\" already exists in the database.",
194 "Database::createContainer");
204 if( name.empty() ) name = nameForContainer( className );
205 if( m_impl->m_session->containerHandle( name ) ){
206 throwException(
"Container with name \""+name+
"\" already exists in the database.",
207 "Database::createContainer");
214 const std::type_info& typeInfo){
229 if( !m_impl->m_session->containerHandle( name ) ){
232 m_impl->m_session->dropContainer( name );
240 throwException(
"Container \""+name+
"\" does not exist in the database.",
241 "Database::containerHandle");
250 std::stringstream messg;
251 messg <<
"Container with id=" << contId <<
" not found in the database.";
253 "Database::containerHandle");
264 const Object& dataObject ){
268 return OId( cont.
id(), itemId );
272 const Object& dataObject ){
286 const std::map<int,Handle<DatabaseContainer> >& containers = m_impl->m_session->containers();
288 iCont != containers.end(); ++iCont ){
289 iCont->second->flush();
300 return m_impl->m_session->eraseObjectName( name );
305 return m_impl->m_session->eraseAllNames();
310 return m_impl->m_session->getItemId( name, destination );
316 return m_impl->m_session->fetchTypedObjectByName( name, objType );
321 return m_impl->m_session->fetchObjectByName( name );
325 std::vector<std::string>& destination ){
327 return m_impl->m_session->getNamesForObject( oid.
containerId(), oid.
itemId(), destination );
332 return m_impl->m_session->listObjectNames( destination );
342 return m_impl->m_session->storageAccessSession();
Handle< DatabaseContainer > containerHandle(const std::string &name)
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)
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
static std::string automaticContainerCreation()
void open(bool writingAccess=false)
Object fetchItem(int itemId)
static std::string automaticDatabaseCreation()
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)