#include <DatabaseContainer.h>
Public Member Functions | |
const std::string & | className () |
void | create () |
DatabaseContainer (int contId, const std::string &containerName, const Reflex::Type &containerType, DatabaseSession &session) | |
DatabaseContainer (int contId, const std::string &containerName, const std::string &className, unsigned int containerSize, DatabaseSession &session) | |
void | drop () |
void | erase (int itemId) |
void | extendSchema (const Reflex::Type &dependentType) |
void * | fetchItem (int itemId) |
void * | fetchItemAsType (int itemId, const Reflex::Type &asType) |
void | flush () |
bool | getNames (std::vector< std::string > &destination) |
int | id () |
int | insertItem (const void *data, const Reflex::Type &type) |
bool | isLocked () |
Handle< IteratorBuffer > | iteratorBuffer () |
bool | lock () |
const std::string & | mappingVersion () |
const std::string & | name () |
void | setAccessPermission (const std::string &principal, bool forWrite) |
void | setItemName (const std::string &name, int itemId) |
size_t | size () |
const Reflex::Type & | type () |
void | updateItem (int itemId, const void *data, const Reflex::Type &type) |
virtual | ~DatabaseContainer () |
Private Attributes | |
ContainerUpdateTable & | m_containerUpdateTable |
IDatabaseSchema & | m_dbSchema |
std::auto_ptr< DeleteBuffer > | m_deleteBuffer |
Handle< IteratorBuffer > | m_iteratorBuffer |
bool | m_lock |
std::auto_ptr< ReadBuffer > | m_readBuffer |
std::auto_ptr< ContainerSchema > | m_schema |
size_t | m_size |
std::auto_ptr< UpdateBuffer > | m_updateBuffer |
std::auto_ptr< WriteBuffer > | m_writeBuffer |
Definition at line 51 of file DatabaseContainer.h.
ora::DatabaseContainer::DatabaseContainer | ( | int | contId, |
const std::string & | containerName, | ||
const std::string & | className, | ||
unsigned int | containerSize, | ||
DatabaseSession & | session | ||
) |
Definition at line 294 of file DatabaseContainer.cc.
: m_dbSchema( session.schema() ), m_schema( new ContainerSchema(contId, containerName, className, session) ), m_writeBuffer(), m_updateBuffer(), m_readBuffer(), m_deleteBuffer(), m_iteratorBuffer(), m_size( containerSize ), m_containerUpdateTable( session.containerUpdateTable() ), m_lock( false ){ }
ora::DatabaseContainer::DatabaseContainer | ( | int | contId, |
const std::string & | containerName, | ||
const Reflex::Type & | containerType, | ||
DatabaseSession & | session | ||
) |
Definition at line 311 of file DatabaseContainer.cc.
: m_dbSchema( session.schema() ), m_schema( new ContainerSchema(contId, containerName, containerType, session) ), m_writeBuffer(), m_updateBuffer(), m_readBuffer(), m_deleteBuffer(), m_iteratorBuffer(), m_size(0), m_containerUpdateTable( session.containerUpdateTable() ), m_lock( false ) { }
ora::DatabaseContainer::~DatabaseContainer | ( | ) | [virtual] |
Definition at line 327 of file DatabaseContainer.cc.
{ m_iteratorBuffer.clear(); }
const std::string & ora::DatabaseContainer::className | ( | ) |
Definition at line 339 of file DatabaseContainer.cc.
{ return m_schema->className(); }
void ora::DatabaseContainer::create | ( | ) |
Definition at line 381 of file DatabaseContainer.cc.
{ m_schema->create(); }
void ora::DatabaseContainer::drop | ( | ) |
Definition at line 385 of file DatabaseContainer.cc.
References ora::throwException().
{ if(!m_schema->dbSession().testDropPermission()){ throwException("Drop permission has been denied for the current user.", "DatabaseContainer::drop"); } m_schema->drop(); m_containerUpdateTable.remove( m_schema->containerId() ); }
void ora::DatabaseContainer::erase | ( | int | itemId | ) |
Definition at line 458 of file DatabaseContainer.cc.
{ if(!m_deleteBuffer.get()){ m_deleteBuffer.reset( new DeleteBuffer( *m_schema ) ); } m_deleteBuffer->registerForDelete( itemId ); }
void ora::DatabaseContainer::extendSchema | ( | const Reflex::Type & | dependentType | ) |
Definition at line 394 of file DatabaseContainer.cc.
{ m_schema->extendIfRequired( dependentType ); }
void * ora::DatabaseContainer::fetchItem | ( | int | itemId | ) |
Definition at line 403 of file DatabaseContainer.cc.
{ if(!m_readBuffer.get()){ m_readBuffer.reset( new ReadBuffer( *m_schema ) ); } return m_readBuffer->read( itemId ); }
void * ora::DatabaseContainer::fetchItemAsType | ( | int | itemId, |
const Reflex::Type & | asType | ||
) |
Definition at line 411 of file DatabaseContainer.cc.
References ora::ClassUtils::isType(), and ora::throwException().
{ if(!m_readBuffer.get()){ m_readBuffer.reset( new ReadBuffer( *m_schema ) ); } if( !ClassUtils::isType( type(), asType ) ){ throwException("Provided output object type \""+asType.Name(Reflex::SCOPED)+"\" does not match with the container type \""+ type().Name(Reflex::SCOPED)+"\"","DatabaseContainer::fetchItemAsType"); } return m_readBuffer->read( itemId ); }
void ora::DatabaseContainer::flush | ( | ) |
Definition at line 465 of file DatabaseContainer.cc.
{ size_t prevSize = m_size; if(m_writeBuffer.get()) m_size += m_writeBuffer->flush(); if(m_updateBuffer.get()) m_updateBuffer->flush(); if(m_deleteBuffer.get()) m_size -= m_deleteBuffer->flush(); m_schema->containerSequences().sinchronizeAll(); if( prevSize != m_size ){ m_containerUpdateTable.takeNote( id(), m_size ); } }
bool ora::DatabaseContainer::getNames | ( | std::vector< std::string > & | destination | ) |
Definition at line 481 of file DatabaseContainer.cc.
int ora::DatabaseContainer::id | ( | void | ) |
Definition at line 331 of file DatabaseContainer.cc.
{ return m_schema->containerId(); }
int ora::DatabaseContainer::insertItem | ( | const void * | data, |
const Reflex::Type & | type | ||
) |
Definition at line 423 of file DatabaseContainer.cc.
References ora::ClassUtils::resolvedType(), ora::MappingRules::sequenceNameForContainer(), and ora::throwException().
{ if(!m_writeBuffer.get()){ m_writeBuffer.reset( new WriteBuffer( *m_schema ) ); } Reflex::Type inputResType = ClassUtils::resolvedType( dataType ); Reflex::Type contType = ClassUtils::resolvedType(m_schema->type()); if( inputResType.Name()!= contType.Name() && !inputResType.HasBase( contType ) ){ throwException( "Provided input object type=\""+inputResType.Name()+ "\" does not match with the container type=\""+contType.Name()+"\"", "DatabaseContainer::insertItem" ); } int newId = m_schema->containerSequences().getNextId( MappingRules::sequenceNameForContainer( m_schema->containerName()) ); m_writeBuffer->registerForWrite( newId, data ); return newId; }
bool ora::DatabaseContainer::isLocked | ( | ) |
Definition at line 377 of file DatabaseContainer.cc.
{ return m_lock; }
ora::Handle< ora::IteratorBuffer > ora::DatabaseContainer::iteratorBuffer | ( | ) |
Definition at line 355 of file DatabaseContainer.cc.
References ora::Handle< T >::reset().
{ if(!m_readBuffer.get()){ m_readBuffer.reset( new ReadBuffer( *m_schema ) ); } if( !m_iteratorBuffer ){ m_iteratorBuffer.reset( new IteratorBuffer(*m_schema, *m_readBuffer ) ); m_iteratorBuffer->reset(); } return m_iteratorBuffer; }
bool ora::DatabaseContainer::lock | ( | ) |
Definition at line 366 of file DatabaseContainer.cc.
References mergeVDriftHistosByStation::name, ora::ContainerHeaderData::numberOfObjects, and ora::throwException().
{ if( !m_lock ){ ContainerHeaderData headerData; m_lock = m_dbSchema.containerHeaderTable().lockContainer( m_schema->containerId(), headerData ); if(!m_lock) throwException("Container \""+name()+"\" has been dropped.","DatabaseContainer::lock()"); // once the lock has been taken over, update the size in case has been changed... m_size = headerData.numberOfObjects; } return m_lock; }
const std::string & ora::DatabaseContainer::mappingVersion | ( | ) |
Definition at line 347 of file DatabaseContainer.cc.
{ return m_schema->mappingVersion(); }
const std::string & ora::DatabaseContainer::name | ( | ) |
Definition at line 335 of file DatabaseContainer.cc.
{ return m_schema->containerName(); }
void ora::DatabaseContainer::setAccessPermission | ( | const std::string & | principal, |
bool | forWrite | ||
) |
Definition at line 398 of file DatabaseContainer.cc.
void ora::DatabaseContainer::setItemName | ( | const std::string & | name, |
int | itemId | ||
) |
Definition at line 476 of file DatabaseContainer.cc.
size_t ora::DatabaseContainer::size | ( | void | ) |
Definition at line 351 of file DatabaseContainer.cc.
{ return m_size; }
const Reflex::Type & ora::DatabaseContainer::type | ( | ) |
Definition at line 343 of file DatabaseContainer.cc.
{ return m_schema->type(); }
void ora::DatabaseContainer::updateItem | ( | int | itemId, |
const void * | data, | ||
const Reflex::Type & | type | ||
) |
Definition at line 441 of file DatabaseContainer.cc.
References ora::ClassUtils::resolvedType(), and ora::throwException().
{ if(!m_updateBuffer.get()){ m_updateBuffer.reset( new UpdateBuffer( *m_schema ) ); } Reflex::Type inputResType = ClassUtils::resolvedType( dataType ); Reflex::Type contType = ClassUtils::resolvedType(m_schema->type()); if( inputResType.Name()!= contType.Name() && !inputResType.HasBase( contType ) ){ throwException( "Provided input object type=\""+inputResType.Name()+"\" does not match with the container type=\""+ contType.Name()+"\".", "DatabaseContainer::updateItem" ); } m_updateBuffer->registerForUpdate( itemId, data ); }
Definition at line 113 of file DatabaseContainer.h.
Definition at line 105 of file DatabaseContainer.h.
std::auto_ptr<DeleteBuffer> ora::DatabaseContainer::m_deleteBuffer [private] |
Definition at line 110 of file DatabaseContainer.h.
Definition at line 111 of file DatabaseContainer.h.
bool ora::DatabaseContainer::m_lock [private] |
Definition at line 114 of file DatabaseContainer.h.
std::auto_ptr<ReadBuffer> ora::DatabaseContainer::m_readBuffer [private] |
Definition at line 109 of file DatabaseContainer.h.
std::auto_ptr<ContainerSchema> ora::DatabaseContainer::m_schema [private] |
Definition at line 106 of file DatabaseContainer.h.
size_t ora::DatabaseContainer::m_size [private] |
Definition at line 112 of file DatabaseContainer.h.
std::auto_ptr<UpdateBuffer> ora::DatabaseContainer::m_updateBuffer [private] |
Definition at line 108 of file DatabaseContainer.h.
std::auto_ptr<WriteBuffer> ora::DatabaseContainer::m_writeBuffer [private] |
Definition at line 107 of file DatabaseContainer.h.