CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

ora::WriteBuffer Class Reference

List of all members.

Public Member Functions

size_t flush ()
void registerForWrite (int oid, const void *data)
 WriteBuffer (ContainerSchema &contSchema)
 ~WriteBuffer ()

Private Member Functions

void write (int oid, const void *data)

Private Attributes

std::vector< std::pair< int,
const void * > > 
m_buffer
RelationalBuffer m_operationBuffer
DataElement m_topLevelElement
InsertOperationm_topLevelInsert
std::auto_ptr< IRelationalWriterm_writer

Detailed Description

Definition at line 20 of file DatabaseContainer.cc.


Constructor & Destructor Documentation

ora::WriteBuffer::WriteBuffer ( ContainerSchema contSchema) [inline, explicit]

Definition at line 22 of file DatabaseContainer.cc.

References ora::InputRelationalData::addId(), ora::MappingElement::columnNames(), ora::MappingElement::end(), ora::MappingElement::find(), m_operationBuffer, m_topLevelElement, m_topLevelInsert, m_writer, ora::ContainerSchema::mapping(), ora::RelationalBuffer::newInsert(), ora::RelationalStreamerFactory::newWriter(), ora::MappingElement::tableName(), ora::throwException(), ora::MappingTree::topElement(), and ora::ContainerSchema::type().

                                                         :
        m_buffer(),
        m_operationBuffer( contSchema.storageSchema() ),
        m_topLevelElement(),
        m_writer(),
        m_topLevelInsert( 0 ){

        MappingElement& topLevelMapping = contSchema.mapping( true ).topElement();
        m_topLevelInsert = &m_operationBuffer.newInsert( topLevelMapping.tableName() );
        m_topLevelInsert->addId(  topLevelMapping.columnNames()[ 0 ] );
        const Reflex::Type& type = contSchema.type();
        MappingElement::iterator iMap = topLevelMapping.find( type.Name(Reflex::SCOPED) );
        // the first inner mapping is the relevant...
        if( iMap == topLevelMapping.end()){
          throwException("Could not find a mapping element for class \""+
                         type.Name(Reflex::SCOPED)+"\"",
                         "WriteBuffer::WriteBuffer");
        }
        MappingElement& mapping = iMap->second;
        RelationalStreamerFactory streamerFactory( contSchema );
        m_writer.reset( streamerFactory.newWriter( type, mapping ) );
        m_writer->build( m_topLevelElement, *m_topLevelInsert, m_operationBuffer );
      }
ora::WriteBuffer::~WriteBuffer ( ) [inline]

Definition at line 47 of file DatabaseContainer.cc.

                    {
      }

Member Function Documentation

size_t ora::WriteBuffer::flush ( ) [inline]

Definition at line 54 of file DatabaseContainer.cc.

References ora::RelationalBuffer::flush(), m_buffer, m_operationBuffer, and write().

                    {
        size_t nobj = 0;
        for( std::vector<std::pair<int, const void*> >::const_iterator iW = m_buffer.begin();
             iW != m_buffer.end(); ++iW ){
          write( iW->first, iW->second );
          if( m_operationBuffer.flush() ) nobj++;
        }
        m_buffer.clear();
        return nobj;
      }
void ora::WriteBuffer::registerForWrite ( int  oid,
const void *  data 
) [inline]

Definition at line 50 of file DatabaseContainer.cc.

References m_buffer.

                                                        {
        m_buffer.push_back( std::make_pair(oid, data ) );
      }
void ora::WriteBuffer::write ( int  oid,
const void *  data 
) [inline, private]

Definition at line 66 of file DatabaseContainer.cc.

References ora::InputRelationalData::data(), m_topLevelInsert, and m_writer.

Referenced by flush().

                                             {
        coral::AttributeList& dataBuff = m_topLevelInsert->data();
        dataBuff.begin()->data<int>() = oid;
        m_writer->write( oid, data );
      }      

Member Data Documentation

std::vector<std::pair<int, const void*> > ora::WriteBuffer::m_buffer [private]

Definition at line 73 of file DatabaseContainer.cc.

Referenced by flush(), and registerForWrite().

Definition at line 74 of file DatabaseContainer.cc.

Referenced by flush(), and WriteBuffer().

Definition at line 75 of file DatabaseContainer.cc.

Referenced by WriteBuffer().

Definition at line 77 of file DatabaseContainer.cc.

Referenced by write(), and WriteBuffer().

Definition at line 76 of file DatabaseContainer.cc.

Referenced by write(), and WriteBuffer().