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 |
InsertOperation * | m_topLevelInsert |
std::auto_ptr< IRelationalWriter > | m_writer |
Definition at line 20 of file DatabaseContainer.cc.
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.
{ }
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.
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 ); }
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().
std::auto_ptr<IRelationalWriter> ora::WriteBuffer::m_writer [private] |
Definition at line 76 of file DatabaseContainer.cc.
Referenced by write(), and WriteBuffer().