CMS 3D CMS Logo

Public Member Functions | Private Attributes

ora::DatabaseContainer Class Reference

#include <DatabaseContainer.h>

List of all members.

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)
Handle< IteratorBufferiteratorBuffer ()
const std::string & mappingVersion ()
const std::string & name ()
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

ContainerUpdateTablem_containerUpdateTable
std::auto_ptr< DeleteBufferm_deleteBuffer
Handle< IteratorBufferm_iteratorBuffer
std::auto_ptr< ReadBufferm_readBuffer
std::auto_ptr< ContainerSchemam_schema
size_t m_size
std::auto_ptr< UpdateBufferm_updateBuffer
std::auto_ptr< WriteBufferm_writeBuffer

Detailed Description

Definition at line 50 of file DatabaseContainer.h.


Constructor & Destructor Documentation

ora::DatabaseContainer::DatabaseContainer ( int  contId,
const std::string &  containerName,
const std::string &  className,
unsigned int  containerSize,
DatabaseSession session 
)

Definition at line 308 of file DatabaseContainer.cc.

                                                                     :
  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() ){
}
ora::DatabaseContainer::DatabaseContainer ( int  contId,
const std::string &  containerName,
const Reflex::Type &  containerType,
DatabaseSession session 
)

Definition at line 323 of file DatabaseContainer.cc.

                                                                     :
  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() ){
}
ora::DatabaseContainer::~DatabaseContainer ( ) [virtual]

Definition at line 337 of file DatabaseContainer.cc.

                                        {
  m_iteratorBuffer.clear();
}

Member Function Documentation

const std::string & ora::DatabaseContainer::className ( )

Definition at line 349 of file DatabaseContainer.cc.

                                                {
  return m_schema->className();
}
void ora::DatabaseContainer::create ( )

Definition at line 376 of file DatabaseContainer.cc.

                                 {
  m_schema->create();
}
void ora::DatabaseContainer::drop ( )

Definition at line 380 of file DatabaseContainer.cc.

                               {
  m_schema->drop();
}
void ora::DatabaseContainer::erase ( int  itemId)

Definition at line 443 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 384 of file DatabaseContainer.cc.

                                                                        {
  m_schema->extendIfRequired( dependentType );
}
void * ora::DatabaseContainer::fetchItem ( int  itemId)

Definition at line 388 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 396 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 450 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 466 of file DatabaseContainer.cc.

                                                                      {
  return m_schema->dbSession().getNamesForContainer( m_schema->containerId(), destination );
}
int ora::DatabaseContainer::id ( void  )

Definition at line 341 of file DatabaseContainer.cc.

                            {
  return m_schema->containerId();
}
int ora::DatabaseContainer::insertItem ( const void *  data,
const Reflex::Type &  type 
)

Definition at line 408 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;
}
ora::Handle< ora::IteratorBuffer > ora::DatabaseContainer::iteratorBuffer ( )

Definition at line 365 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;
}
const std::string & ora::DatabaseContainer::mappingVersion ( )

Definition at line 357 of file DatabaseContainer.cc.

                                                     {
  return m_schema->mappingVersion();
}
const std::string & ora::DatabaseContainer::name ( )

Definition at line 345 of file DatabaseContainer.cc.

                                           {
  return m_schema->containerName();
}
void ora::DatabaseContainer::setItemName ( const std::string &  name,
int  itemId 
)

Definition at line 461 of file DatabaseContainer.cc.

                                                      {
  m_schema->dbSession().setObjectName( name, m_schema->containerId(), itemId );
}
size_t ora::DatabaseContainer::size ( void  )

Definition at line 361 of file DatabaseContainer.cc.

                                 {
  return m_size;
}
const Reflex::Type & ora::DatabaseContainer::type ( )

Definition at line 353 of file DatabaseContainer.cc.

                                            {
  return m_schema->type();
}
void ora::DatabaseContainer::updateItem ( int  itemId,
const void *  data,
const Reflex::Type &  type 
)

Definition at line 426 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 );
}

Member Data Documentation

Definition at line 105 of file DatabaseContainer.h.

Definition at line 102 of file DatabaseContainer.h.

Definition at line 103 of file DatabaseContainer.h.

Definition at line 101 of file DatabaseContainer.h.

Definition at line 98 of file DatabaseContainer.h.

Definition at line 104 of file DatabaseContainer.h.

Definition at line 100 of file DatabaseContainer.h.

Definition at line 99 of file DatabaseContainer.h.