CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
ora::Database Class Reference

#include <Database.h>

Public Member Functions

Configurationconfiguration ()
 
bool connect (const std::string &connectionString, bool readOnly=false)
 
bool connect (const std::string &connectionString, const std::string &asRole, bool readOnly=false)
 
const std::string & connectionString ()
 
Container containerHandle (const std::string &name)
 
Container containerHandle (int contId)
 
std::set< std::string > containers ()
 
bool create (std::string userSchemaVersion=std::string(""))
 
template<typename T >
Container createContainer (const std::string &name)
 
template<typename T >
Container createContainer ()
 
Container createContainer (const std::string &className, std::string name="")
 
template<typename T >
ora::Container createContainer (const std::string &name)
 
template<typename T >
ora::Container createContainer ()
 
 Database ()
 
 Database (const Database &rhs)
 
 Database (boost::shared_ptr< ConnectionPool > &connectionPool)
 
void disconnect ()
 
bool drop ()
 
bool dropContainer (const std::string &name)
 
void erase (const OId &oid)
 
bool eraseAllNames ()
 
bool eraseObjectName (const std::string &name)
 
bool exists ()
 
template<typename T >
boost::shared_ptr< Tfetch (const OId &oid)
 
template<typename T >
boost::shared_ptr< TfetchByName (const std::string &name)
 
Object fetchItem (const OId &oid)
 
Object fetchItemByName (const std::string &name)
 
void flush ()
 
bool getItemId (const std::string &name, OId &destination)
 
bool getNamesForObject (const OId &oid, std::vector< std::string > &destination)
 
template<typename T >
OId insert (const std::string &containerName, const T &data)
 
template<typename T >
OId insert (const T &data)
 
template<typename T >
ora::OId insert (const std::string &containerName, const T &data)
 
template<typename T >
ora::OId insert (const T &data)
 
OId insertItem (const std::string &containerName, const Object &data)
 
bool isConnected ()
 
bool listObjectNames (std::vector< std::string > &destination)
 
bool lockContainer (const std::string &name)
 
Databaseoperator= (const Database &rhs)
 
ora::Version schemaVersion (bool userSchema=false)
 
void setAccessPermission (const std::string &principal, bool forWrite)
 
void setObjectName (const std::string &name, const OId &oid)
 
SharedSessionstorageAccessSession ()
 
Transactiontransaction ()
 
template<typename T >
void update (const OId &oid, const T &data)
 
void updateItem (const OId &oid, const Object &data)
 
DatabaseUtility utility ()
 
virtual ~Database ()
 

Static Public Member Functions

static std::string nameForContainer (const std::type_info &typeInfo)
 
static std::string nameForContainer (const std::string &className)
 

Private Member Functions

void checkTransaction ()
 
Container createContainer (const std::string &name, const std::type_info &typeInfo)
 
Container createContainer (const std::type_info &typeInfo)
 
Container getContainer (const std::string &name, const std::type_info &typeInfo)
 
Container getContainer (const std::type_info &typeInfo)
 
boost::shared_ptr< void > getTypedObjectByName (const std::string &name, const std::type_info &typeInfo)
 
void open (bool writingAccess=false)
 

Private Attributes

boost::shared_ptr< DatabaseImplm_impl
 

Detailed Description

Definition at line 24 of file Database.h.

Constructor & Destructor Documentation

ora::Database::Database ( )

Definition at line 66 of file Database.cc.

Referenced by ProducePlots.ProducePlots::plotAllAndLast40Runs(), PopulateDB.PopulateDB::run(), and DiscoverProcessedRuns.DiscoverProcessedRuns::runsList().

66  :
67  m_impl( new DatabaseImpl ){
68 }
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
ora::Database::Database ( const Database rhs)

Definition at line 70 of file Database.cc.

Referenced by ProducePlots.ProducePlots::plotAllAndLast40Runs(), PopulateDB.PopulateDB::run(), and DiscoverProcessedRuns.DiscoverProcessedRuns::runsList().

70  :
71  m_impl( rhs.m_impl ){
72 }
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
ora::Database::Database ( boost::shared_ptr< ConnectionPool > &  connectionPool)

Definition at line 74 of file Database.cc.

Referenced by ProducePlots.ProducePlots::plotAllAndLast40Runs(), PopulateDB.PopulateDB::run(), and DiscoverProcessedRuns.DiscoverProcessedRuns::runsList().

74  :
75  m_impl( new DatabaseImpl( connectionPool) ){
76 }
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
ora::Database::~Database ( )
virtual

Definition at line 78 of file Database.cc.

78  {
79  disconnect();
80 }
void disconnect()
Definition: Database.cc:102

Member Function Documentation

void ora::Database::checkTransaction ( )
private

Definition at line 121 of file Database.cc.

References ora::throwException().

121  {
122  if(!m_impl->m_session->isConnected()) {
123  throwException("No database storage connected.","Database::checkTransaction");
124  }
125  if(!m_impl->m_transaction->isActive()) {
126  throwException("Transaction is not active.","Database::checkTransaction");
127  }
128 }
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:10
ora::Configuration & ora::Database::configuration ( )

Definition at line 87 of file Database.cc.

87  {
88  return m_impl->m_session->configuration();
89 }
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
bool ora::Database::connect ( const std::string &  connectionString,
bool  readOnly = false 
)

Definition at line 91 of file Database.cc.

Referenced by Vispa.Gui.ZoomableScrollArea.ZoomableScrollArea::__init__(), Vispa.Views.PropertyView.BooleanProperty::__init__(), Vispa.Gui.FindDialog.FindDialog::_addScript(), Vispa.Gui.FindDialog.FindDialog::_addStringProperty(), Vispa.Main.Application.Application::_connectSignals(), Vispa.Plugins.ConfigEditor.CodeTableView.CodeTableView::_createItem(), Vispa.Gui.BoxContentDialog.BoxContentDialog::addButton(), Vispa.Gui.ToolBoxContainer.ToolBoxContainer::addWidget(), Vispa.Views.PropertyView.PropertyView::append(), Vispa.Views.PropertyView.PropertyView::appendAddRow(), Vispa.Main.Application.Application::createAction(), Vispa.Views.PropertyView.TextEditWithButtonProperty::createButton(), Vispa.Views.LineDecayView.LineDecayView::createLineDecayContainer(), Vispa.Views.PropertyView.TextEditWithButtonProperty::createLineEdit(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.PropertyView.TextEditWithButtonProperty::createTextEdit(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::filterDialog(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::find(), Vispa.Gui.PortWidget.PortWidget::mouseMoveEvent(), Vispa.Views.PropertyView.BooleanProperty::setChecked(), Vispa.Main.SplitterTab.SplitterTab::setController(), Vispa.Plugins.Browser.BrowserTab.BrowserTab::setController(), Vispa.Views.PropertyView.BooleanProperty::setReadOnly(), Vispa.Views.PropertyView.DropDownProperty::setReadOnly(), Vispa.Views.PropertyView.TextEditWithButtonProperty::setReadOnly(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::setTab(), Vispa.Views.PropertyView.IntegerProperty::setValue(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::switchCenterView(), Vispa.Plugins.EdmBrowser.EdmBrowserTabController.EdmBrowserTabController::updateViewMenu(), and Vispa.Plugins.ConfigEditor.ConfigEditorTabController.ConfigEditorTabController::updateViewMenu().

92  {
93  return m_impl->m_session->connect( connectionString, readOnly );
94 }
const std::string & connectionString()
Definition: Database.cc:110
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
bool ora::Database::connect ( const std::string &  connectionString,
const std::string &  asRole,
bool  readOnly = false 
)

Definition at line 96 of file Database.cc.

Referenced by Vispa.Gui.ZoomableScrollArea.ZoomableScrollArea::__init__(), Vispa.Views.PropertyView.BooleanProperty::__init__(), Vispa.Gui.FindDialog.FindDialog::_addScript(), Vispa.Gui.FindDialog.FindDialog::_addStringProperty(), Vispa.Main.Application.Application::_connectSignals(), Vispa.Plugins.ConfigEditor.CodeTableView.CodeTableView::_createItem(), Vispa.Gui.BoxContentDialog.BoxContentDialog::addButton(), Vispa.Gui.ToolBoxContainer.ToolBoxContainer::addWidget(), Vispa.Views.PropertyView.PropertyView::append(), Vispa.Views.PropertyView.PropertyView::appendAddRow(), Vispa.Main.Application.Application::createAction(), Vispa.Views.PropertyView.TextEditWithButtonProperty::createButton(), Vispa.Views.LineDecayView.LineDecayView::createLineDecayContainer(), Vispa.Views.PropertyView.TextEditWithButtonProperty::createLineEdit(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.PropertyView.TextEditWithButtonProperty::createTextEdit(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::filterDialog(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::find(), Vispa.Gui.PortWidget.PortWidget::mouseMoveEvent(), Vispa.Views.PropertyView.BooleanProperty::setChecked(), Vispa.Main.SplitterTab.SplitterTab::setController(), Vispa.Plugins.Browser.BrowserTab.BrowserTab::setController(), Vispa.Views.PropertyView.BooleanProperty::setReadOnly(), Vispa.Views.PropertyView.DropDownProperty::setReadOnly(), Vispa.Views.PropertyView.TextEditWithButtonProperty::setReadOnly(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::setTab(), Vispa.Views.PropertyView.IntegerProperty::setValue(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::switchCenterView(), Vispa.Plugins.EdmBrowser.EdmBrowserTabController.EdmBrowserTabController::updateViewMenu(), and Vispa.Plugins.ConfigEditor.ConfigEditorTabController.ConfigEditorTabController::updateViewMenu().

98  {
99  return m_impl->m_session->connect( connectionString, asRole, readOnly );
100 }
const std::string & connectionString()
Definition: Database.cc:110
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
const std::string & ora::Database::connectionString ( )
ora::Container ora::Database::containerHandle ( const std::string &  name)

Definition at line 272 of file Database.cc.

References cont, and ora::throwException().

Referenced by cond::DbSession::importObject().

272  {
273  open();
274  Handle<DatabaseContainer> cont = m_impl->m_session->containerHandle( name );
275  if( !cont ){
276  throwException("Container \""+name+"\" does not exist in the database.",
277  "Database::containerHandle");
278  }
279  return Container( cont );
280 }
EcalChannelStatus Container
void open(bool writingAccess=false)
Definition: Database.cc:171
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
int cont
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:10
ora::Container ora::Database::containerHandle ( int  contId)

Definition at line 282 of file Database.cc.

References cont, and ora::throwException().

282  {
283  open();
284  Handle<DatabaseContainer> cont = m_impl->m_session->containerHandle( contId );
285  if( !cont ){
286  std::stringstream messg;
287  messg << "Container with id=" << contId << " not found in the database.";
288  throwException(messg.str(),
289  "Database::containerHandle");
290  }
291  return Container( cont );
292 }
EcalChannelStatus Container
void open(bool writingAccess=false)
Definition: Database.cc:171
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
int cont
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:10
std::set< std::string > ora::Database::containers ( )

Definition at line 191 of file Database.cc.

References Association::map.

Referenced by cond::IOVSchemaUtility::createIOVContainer(), cond::IOVSchemaUtility::createPayloadContainer(), cond::IOVSchemaUtility::dropIOVContainer(), cond::IOVSchemaUtility::dropPayloadContainer(), and cond::IOVSchemaUtility::existsIOVContainer().

191  {
192  open();
193  std::set< std::string > contList;
194  const std::map<int, Handle<DatabaseContainer> >& conts = m_impl->m_session->containers();
195  for(std::map<int, Handle<DatabaseContainer> >::const_iterator iC = conts.begin();
196  iC != conts.end(); iC++ ){
197  contList.insert( iC->second->name() );
198  }
199  return contList;
200 }
void open(bool writingAccess=false)
Definition: Database.cc:171
dictionary map
Definition: Association.py:205
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
bool ora::Database::create ( std::string  userSchemaVersion = std::string(""))

Definition at line 135 of file Database.cc.

Referenced by cond::IOVSchemaUtility::createIOVContainer().

135  {
136  bool created = false;
137  if( !exists()){
138  m_impl->m_session->create( userSchemaVersion );
139  created = true;
140  }
141  return created;
142 }
bool exists()
Definition: Database.cc:130
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
template<typename T >
Container ora::Database::createContainer ( const std::string &  name)
template<typename T >
Container ora::Database::createContainer ( )

Referenced by createContainer().

ora::Container ora::Database::createContainer ( const std::string &  className,
std::string  name = "" 
)

Definition at line 226 of file Database.cc.

References cont, ora::ClassUtils::lookupDictionary(), and ora::throwException().

227  {
228  open( true );
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");
234  }
235  Handle<DatabaseContainer> cont = m_impl->m_session->createContainer( name, contType );
236  return Container( cont );
237 }
EcalChannelStatus Container
void open(bool writingAccess=false)
Definition: Database.cc:171
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
int cont
static std::string nameForContainer(const std::type_info &typeInfo)
Definition: Database.cc:57
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:10
Reflex::Type lookupDictionary(const std::type_info &typeInfo, bool throwFlag=true)
Definition: ClassUtils.cc:93
std::string className(const T &t)
Definition: ClassName.h:30
ora::Container ora::Database::createContainer ( const std::string &  name,
const std::type_info &  typeInfo 
)
private

Definition at line 202 of file Database.cc.

References cont, ora::ClassUtils::lookupDictionary(), and ora::throwException().

203  {
204  open( true );
205  if( m_impl->m_session->containerHandle( name ) ){
206  throwException("Container with name \""+name+"\" already exists in the database.",
207  "Database::createContainer");
208  }
209  Reflex::Type contType = ClassUtils::lookupDictionary( typeInfo );
210  Handle<DatabaseContainer> cont = m_impl->m_session->createContainer( name, contType );
211  return Container( cont );
212 }
EcalChannelStatus Container
void open(bool writingAccess=false)
Definition: Database.cc:171
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
int cont
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:10
Reflex::Type lookupDictionary(const std::type_info &typeInfo, bool throwFlag=true)
Definition: ClassUtils.cc:93
ora::Container ora::Database::createContainer ( const std::type_info &  typeInfo)
private

Definition at line 214 of file Database.cc.

References cont, ora::ClassUtils::lookupDictionary(), mergeVDriftHistosByStation::name, ora::nameFromClass(), and ora::throwException().

214  {
215  open( true );
216  Reflex::Type contType = ClassUtils::lookupDictionary( typeInfo );
217  std::string name = nameFromClass( contType );
218  if( m_impl->m_session->containerHandle( name ) ){
219  throwException("Container with name \""+name+"\" already exists in the database.",
220  "Database::createContainer");
221  }
222  Handle<DatabaseContainer> cont = m_impl->m_session->createContainer( name, contType );
223  return Container( cont );
224 }
EcalChannelStatus Container
std::string nameFromClass(const Reflex::Type &contType)
Definition: Database.cc:37
void open(bool writingAccess=false)
Definition: Database.cc:171
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
int cont
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:10
Reflex::Type lookupDictionary(const std::type_info &typeInfo, bool throwFlag=true)
Definition: ClassUtils.cc:93
template<typename T >
ora::Container ora::Database::createContainer ( const std::string &  name)
inline

Definition at line 201 of file Database.h.

References createContainer().

201  {
202  return createContainer( name, typeid(T) );
203 }
Container createContainer()
long double T
template<typename T >
ora::Container ora::Database::createContainer ( )
inline

Definition at line 207 of file Database.h.

207  {
208  return createContainer( typeid(T) );
209 }
Container createContainer()
long double T
void ora::Database::disconnect ( void  )
bool ora::Database::drop ( )

Definition at line 144 of file Database.cc.

References Association::map.

Referenced by cond::IOVSchemaUtility::dropAll().

144  {
145  bool dropped = false;
146  if( exists()){
147  open();
148  const std::map<int, Handle<DatabaseContainer> >& conts = m_impl->m_session->containers();
149  for(std::map<int, Handle<DatabaseContainer> >::const_iterator iC = conts.begin();
150  iC != conts.end(); iC++ ){
151  iC->second->drop();
152  }
153  m_impl->m_session->drop();
154  dropped = true;
155  }
156  return dropped;
157 }
void open(bool writingAccess=false)
Definition: Database.cc:171
dictionary map
Definition: Association.py:205
bool exists()
Definition: Database.cc:130
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
bool ora::Database::dropContainer ( const std::string &  name)

Definition at line 253 of file Database.cc.

Referenced by cond::IOVSchemaUtility::dropIOVContainer(), and cond::IOVSchemaUtility::dropPayloadContainer().

253  {
254  open();
255  if( !m_impl->m_session->containerHandle( name ) ){
256  return false;
257  }
258  m_impl->m_session->dropContainer( name );
259  return true;
260 }
void open(bool writingAccess=false)
Definition: Database.cc:171
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
void ora::Database::erase ( const OId oid)

Definition at line 314 of file Database.cc.

References cont, ora::OId::containerId(), ora::Container::erase(), and ora::OId::itemId().

314  {
315  open();
316  Container cont = containerHandle( oid.containerId() );
317  cont.erase( oid.itemId() );
318 }
EcalChannelStatus Container
void open(bool writingAccess=false)
Definition: Database.cc:171
Container containerHandle(const std::string &name)
Definition: Database.cc:272
void erase(int itemId)
Definition: Container.cc:154
int cont
bool ora::Database::eraseAllNames ( )

Definition at line 339 of file Database.cc.

339  {
340  open();
341  return m_impl->m_session->eraseAllNames();
342 }
void open(bool writingAccess=false)
Definition: Database.cc:171
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
bool ora::Database::eraseObjectName ( const std::string &  name)

Definition at line 334 of file Database.cc.

334  {
335  open();
336  return m_impl->m_session->eraseObjectName( name );
337 }
void open(bool writingAccess=false)
Definition: Database.cc:171
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
bool ora::Database::exists ( )

Definition at line 130 of file Database.cc.

Referenced by cond::IOVSchemaUtility::createIOVContainer(), and cond::IOVSchemaUtility::existsIOVContainer().

130  {
132  return m_impl->m_session->exists();
133 }
void checkTransaction()
Definition: Database.cc:121
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
template<typename T >
boost::shared_ptr< T > ora::Database::fetch ( const OId oid)
inline

Definition at line 213 of file Database.h.

References cont, ora::OId::containerId(), ora::Container::fetch(), and ora::OId::itemId().

Referenced by cond::DbSession::getTypedObject().

213  {
214  Container cont = containerHandle( oid.containerId() );
215  return cont.fetch<T>( oid.itemId() );
216 }
EcalChannelStatus Container
Container containerHandle(const std::string &name)
Definition: Database.cc:272
int cont
boost::shared_ptr< T > fetch(int itemId)
Definition: Container.h:127
long double T
template<typename T >
boost::shared_ptr< T > ora::Database::fetchByName ( const std::string &  name)
inline

Definition at line 245 of file Database.h.

245  {
246  return boost::static_pointer_cast<T>( getTypedObjectByName( name, typeid(T) ) );
247 }
boost::shared_ptr< void > getTypedObjectByName(const std::string &name, const std::type_info &typeInfo)
Definition: Database.cc:349
long double T
ora::Object ora::Database::fetchItem ( const OId oid)

Definition at line 294 of file Database.cc.

References cont, ora::OId::containerId(), ora::Container::fetchItem(), and ora::OId::itemId().

294  {
295  Container cont = containerHandle( oid.containerId() );
296  return cont.fetchItem( oid.itemId() );
297 }
EcalChannelStatus Container
Object fetchItem(int itemId)
Definition: Container.cc:102
Container containerHandle(const std::string &name)
Definition: Database.cc:272
int cont
ora::Object ora::Database::fetchItemByName ( const std::string &  name)

Definition at line 355 of file Database.cc.

355  {
356  open();
357  return m_impl->m_session->fetchObjectByName( name );
358 }
void open(bool writingAccess=false)
Definition: Database.cc:171
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
void ora::Database::flush ( )

Definition at line 320 of file Database.cc.

References Association::map.

Referenced by cond::DbSession::storeObject(), and cond::DbSession::updateObject().

320  {
321  open();
322  const std::map<int,Handle<DatabaseContainer> >& containers = m_impl->m_session->containers();
323  for( std::map<int,Handle<DatabaseContainer> >::const_iterator iCont = containers.begin();
324  iCont != containers.end(); ++iCont ){
325  iCont->second->flush();
326  }
327 }
void open(bool writingAccess=false)
Definition: Database.cc:171
dictionary map
Definition: Association.py:205
std::set< std::string > containers()
Definition: Database.cc:191
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
ora::Container ora::Database::getContainer ( const std::string &  name,
const std::type_info &  typeInfo 
)
private

Definition at line 239 of file Database.cc.

References ora::getContainerFromSession(), and ora::ClassUtils::lookupDictionary().

240  {
241  open( true );
242  Reflex::Type objType = ClassUtils::lookupDictionary( typeInfo );
243  return getContainerFromSession( containerName, objType, *m_impl->m_session );
244 }
void open(bool writingAccess=false)
Definition: Database.cc:171
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
Container getContainerFromSession(const std::string &name, const Reflex::Type &contType, DatabaseSession &session)
Definition: Database.cc:41
Reflex::Type lookupDictionary(const std::type_info &typeInfo, bool throwFlag=true)
Definition: ClassUtils.cc:93
ora::Container ora::Database::getContainer ( const std::type_info &  typeInfo)
private

Definition at line 246 of file Database.cc.

References ora::getContainerFromSession(), ora::ClassUtils::lookupDictionary(), and ora::nameFromClass().

246  {
247  open( true );
248  Reflex::Type objType = ClassUtils::lookupDictionary( typeInfo );
249  std::string contName = nameFromClass( objType );
250  return getContainerFromSession( contName, objType, *m_impl->m_session);
251 }
std::string nameFromClass(const Reflex::Type &contType)
Definition: Database.cc:37
void open(bool writingAccess=false)
Definition: Database.cc:171
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
Container getContainerFromSession(const std::string &name, const Reflex::Type &contType, DatabaseSession &session)
Definition: Database.cc:41
Reflex::Type lookupDictionary(const std::type_info &typeInfo, bool throwFlag=true)
Definition: ClassUtils.cc:93
bool ora::Database::getItemId ( const std::string &  name,
ora::OId destination 
)

Definition at line 344 of file Database.cc.

344  {
345  open();
346  return m_impl->m_session->getItemId( name, destination );
347 }
void open(bool writingAccess=false)
Definition: Database.cc:171
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
bool ora::Database::getNamesForObject ( const OId oid,
std::vector< std::string > &  destination 
)

Definition at line 360 of file Database.cc.

References ora::OId::containerId(), ora::OId::itemId(), and ora::throwException().

361  {
363  if( !m_impl->m_session->exists() ){
364  throwException("Database does not exists in \""+m_impl->m_session->connectionString()+"\"","Database::getNamesForObject");
365  }
366  return m_impl->m_session->getNamesForObject( oid.containerId(), oid.itemId(), destination );
367 }
void checkTransaction()
Definition: Database.cc:121
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:10
boost::shared_ptr< void > ora::Database::getTypedObjectByName ( const std::string &  name,
const std::type_info &  typeInfo 
)
private

Definition at line 349 of file Database.cc.

References ora::ClassUtils::lookupDictionary().

349  {
350  open();
351  Reflex::Type objType = ClassUtils::lookupDictionary( typeInfo );
352  return m_impl->m_session->fetchTypedObjectByName( name, objType );
353 }
void open(bool writingAccess=false)
Definition: Database.cc:171
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
Reflex::Type lookupDictionary(const std::type_info &typeInfo, bool throwFlag=true)
Definition: ClassUtils.cc:93
template<typename T >
OId ora::Database::insert ( const std::string &  containerName,
const T data 
)
template<typename T >
OId ora::Database::insert ( const T data)
template<typename T >
ora::OId ora::Database::insert ( const std::string &  containerName,
const T data 
)
inline

Definition at line 220 of file Database.h.

References cont, ora::Container::id(), and ora::Container::insert().

221  {
222  Container cont = getContainer( containerName, typeid(data) );
223  int itemId = cont.insert( data );
224  return OId( cont.id(), itemId );
225 }
EcalChannelStatus Container
int cont
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
Container getContainer(const std::string &name, const std::type_info &typeInfo)
Definition: Database.cc:239
template<typename T >
ora::OId ora::Database::insert ( const T data)
inline

Definition at line 229 of file Database.h.

References cont, ora::Container::id(), and ora::Container::insert().

229  {
230  Container cont = getContainer( typeid(data) );
231  int itemId = cont.insert( data );
232  return OId( cont.id(), itemId );
233 }
EcalChannelStatus Container
int cont
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
Container getContainer(const std::string &name, const std::type_info &typeInfo)
Definition: Database.cc:239
ora::OId ora::Database::insertItem ( const std::string &  containerName,
const Object data 
)

Definition at line 299 of file Database.cc.

References cont, ora::getContainerFromSession(), ora::Container::id(), ora::Container::insertItem(), and ora::Object::type().

300  {
301  open( true );
302  Container cont = getContainerFromSession( containerName, dataObject.type(), *m_impl->m_session );
303  int itemId = cont.insertItem( dataObject );
304  return OId( cont.id(), itemId );
305 }
EcalChannelStatus Container
int insertItem(const Object &data)
Definition: Container.cc:122
void open(bool writingAccess=false)
Definition: Database.cc:171
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
int cont
Container getContainerFromSession(const std::string &name, const Reflex::Type &contType, DatabaseSession &session)
Definition: Database.cc:41
bool ora::Database::isConnected ( )

Definition at line 106 of file Database.cc.

106  {
107  return m_impl->m_session->isConnected();
108 }
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
bool ora::Database::listObjectNames ( std::vector< std::string > &  destination)

Definition at line 369 of file Database.cc.

References ora::throwException().

369  {
371  if( !m_impl->m_session->exists() ){
372  throwException("Database does not exists in \""+m_impl->m_session->connectionString()+"\"","Database::listObjectNames");
373  }
374  return m_impl->m_session->listObjectNames( destination );
375 }
void checkTransaction()
Definition: Database.cc:121
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:10
bool ora::Database::lockContainer ( const std::string &  name)

Definition at line 262 of file Database.cc.

References cont, ora::DatabaseContainer::lock(), and ora::throwException().

Referenced by cond::ExportIOVUtilities::execute().

262  {
263  open();
264  Handle<DatabaseContainer> cont = m_impl->m_session->containerHandle( name );
265  if( !cont ){
266  throwException("Container \""+name+"\" does not exist in the database.",
267  "Database::lockContainer");
268  }
269  return cont->lock();
270 }
void open(bool writingAccess=false)
Definition: Database.cc:171
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
int cont
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:10
std::string ora::Database::nameForContainer ( const std::type_info &  typeInfo)
static

Definition at line 57 of file Database.cc.

References ora::ClassUtils::lookupDictionary(), and ora::nameFromClass().

57  {
58  Reflex::Type contType = ClassUtils::lookupDictionary( typeInfo );
59  return nameFromClass( contType );
60 }
std::string nameFromClass(const Reflex::Type &contType)
Definition: Database.cc:37
Reflex::Type lookupDictionary(const std::type_info &typeInfo, bool throwFlag=true)
Definition: ClassUtils.cc:93
std::string ora::Database::nameForContainer ( const std::string &  className)
static

Definition at line 62 of file Database.cc.

References className().

62  {
63  return className;
64 }
std::string className(const T &t)
Definition: ClassName.h:30
void ora::Database::open ( bool  writingAccess = false)
private

Definition at line 171 of file Database.cc.

References ora::Configuration::automaticDatabaseCreation(), and ora::throwException().

Referenced by Vispa.Plugins.ConfigEditor.ConfigEditorTabController.ConfigEditorTabController::importConfig().

171  {
173  if( !m_impl->m_session->exists() ){
174  if( writingAccess && m_impl->m_session->configuration().properties().getFlag( Configuration::automaticDatabaseCreation() ) ){
175  m_impl->m_session->create();
176  } else {
177  throwException("Database does not exists in \""+m_impl->m_session->connectionString()+"\"","Database::open");
178  }
179  }
180  m_impl->m_session->open();
181 }
void checkTransaction()
Definition: Database.cc:121
static std::string automaticDatabaseCreation()
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:10
ora::Database & ora::Database::operator= ( const Database rhs)

Definition at line 82 of file Database.cc.

References m_impl.

82  {
83  if( this != &rhs ) m_impl = rhs.m_impl;
84  return *this;
85 }
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
ora::Version ora::Database::schemaVersion ( bool  userSchema = false)

Definition at line 183 of file Database.cc.

References ora::Version::fromString(), and ora::throwException().

183  {
185  if( !m_impl->m_session->exists() ){
186  throwException("Database does not exists in \""+m_impl->m_session->connectionString()+"\"","Database::schemaVersion");
187  }
188  return Version::fromString( m_impl->m_session->schemaVersion( userSchema ) );
189 }
static Version fromString(const std::string &versionString)
Definition: Version.cc:24
void checkTransaction()
Definition: Database.cc:121
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:10
void ora::Database::setAccessPermission ( const std::string &  principal,
bool  forWrite 
)

Definition at line 159 of file Database.cc.

References Association::map.

159  {
160  if( exists()){
161  open();
162  m_impl->m_session->setAccessPermission( principal, forWrite );
163  const std::map<int, Handle<DatabaseContainer> >& conts = m_impl->m_session->containers();
164  for(std::map<int, Handle<DatabaseContainer> >::const_iterator iC = conts.begin();
165  iC != conts.end(); iC++ ){
166  iC->second->setAccessPermission( principal, forWrite );
167  }
168  }
169 }
void open(bool writingAccess=false)
Definition: Database.cc:171
dictionary map
Definition: Association.py:205
bool exists()
Definition: Database.cc:130
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
void ora::Database::setObjectName ( const std::string &  name,
const OId oid 
)

Definition at line 329 of file Database.cc.

References ora::OId::containerId(), and ora::OId::itemId().

329  {
330  open( true );
331  m_impl->m_session->setObjectName( name, oid.containerId(), oid.itemId() );
332 }
void open(bool writingAccess=false)
Definition: Database.cc:171
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
ora::SharedSession & ora::Database::storageAccessSession ( )

Definition at line 383 of file Database.cc.

383  {
384  return m_impl->m_session->storageAccessSession();
385 }
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
ora::Transaction & ora::Database::transaction ( )

Definition at line 114 of file Database.cc.

References ora::throwException().

114  {
115  if(!m_impl->m_session->isConnected()) {
116  throwException("No database storage connected.","Database::transaction");
117  }
118  return *m_impl->m_transaction;
119 }
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:10
template<typename T >
void ora::Database::update ( const OId oid,
const T data 
)
inline

Definition at line 237 of file Database.h.

References cont, ora::OId::containerId(), data, ora::OId::itemId(), and ora::Container::update().

Referenced by progressbar.ProgressBar::__next__(), relval_steps.Matrix::__setitem__(), relval_steps.Steps::__setitem__(), python.seqvaluedict.seqdict::__setslice__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), python.seqvaluedict.seqdict::extend(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), relval_steps.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), Vispa.Gui.PortConnection.PointToPointConnection::updateConnection(), and cond::DbSession::updateObject().

238  {
239  Container cont = containerHandle( oid.containerId() );
240  cont.update( oid.itemId(), data );
241 }
EcalChannelStatus Container
Container containerHandle(const std::string &name)
Definition: Database.cc:272
void update(int itemId, const T &data)
Definition: Container.h:139
int cont
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void ora::Database::updateItem ( const OId oid,
const Object data 
)

Definition at line 307 of file Database.cc.

References cont, ora::OId::containerId(), ora::OId::itemId(), and ora::Container::updateItem().

308  {
309  open();
310  Container cont = containerHandle( oid.containerId() );
311  cont.updateItem( oid.itemId(), dataObject );
312 }
void updateItem(int itemId, const Object &data)
Definition: Container.cc:137
EcalChannelStatus Container
void open(bool writingAccess=false)
Definition: Database.cc:171
Container containerHandle(const std::string &name)
Definition: Database.cc:272
int cont
ora::DatabaseUtility ora::Database::utility ( )

Definition at line 377 of file Database.cc.

377  {
379  Handle<DatabaseUtilitySession> utilSession = m_impl->m_session->utility();
380  return DatabaseUtility( utilSession );
381 }
void checkTransaction()
Definition: Database.cc:121
boost::shared_ptr< DatabaseImpl > m_impl
Definition: Database.h:193

Member Data Documentation

boost::shared_ptr<DatabaseImpl> ora::Database::m_impl
private

Definition at line 193 of file Database.h.

Referenced by operator=().