Public Member Functions | |
size_t | flush () |
void | registerForUpdate (int oid, const void *data) |
UpdateBuffer (ContainerSchema &contSchema) | |
~UpdateBuffer () | |
Private Member Functions | |
void | update (int oid, const void *data) |
Private Attributes | |
std::vector< std::pair< int, const void * > > | m_buffer |
std::auto_ptr< RelationalDeleter > | m_depDeleter |
RelationalBuffer | m_operationBuffer |
DataElement | m_topLevelElement |
UpdateOperation * | m_topLevelUpdate |
std::auto_ptr< IRelationalUpdater > | m_updater |
Definition at line 79 of file DatabaseContainer.cc.
ora::UpdateBuffer::UpdateBuffer | ( | ContainerSchema & | contSchema | ) | [inline, explicit] |
Definition at line 81 of file DatabaseContainer.cc.
References ora::InputRelationalData::addId(), ora::InputRelationalData::addWhereId(), ora::MappingElement::columnNames(), ora::MappingElement::end(), ora::MappingElement::find(), m_depDeleter, m_operationBuffer, m_topLevelElement, m_topLevelUpdate, m_updater, ora::ContainerSchema::mapping(), ora::ContainerSchema::mappingForDependentClasses(), ora::RelationalBuffer::newUpdate(), ora::RelationalStreamerFactory::newUpdater(), ora::MappingElement::tableName(), ora::throwException(), ora::MappingTree::topElement(), funct::true, and ora::ContainerSchema::type().
: m_buffer(), m_operationBuffer( contSchema.storageSchema() ), m_topLevelElement(), m_depDeleter(), m_updater(), m_topLevelUpdate( 0 ){ std::vector<MappingElement> dependentMappings; contSchema.mappingForDependentClasses( dependentMappings ); m_depDeleter.reset( new RelationalDeleter( dependentMappings ) ); m_depDeleter->build( m_operationBuffer ); dependentMappings.clear(); MappingElement& topLevelMapping = contSchema.mapping( true ).topElement(); m_topLevelUpdate = &m_operationBuffer.newUpdate( topLevelMapping.tableName(), true ); m_topLevelUpdate->addId( topLevelMapping.columnNames()[ 0 ] ); m_topLevelUpdate->addWhereId( 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)+"\"", "UpdateBuffer::UpdateBuffer"); } MappingElement& mapping = iMap->second; RelationalStreamerFactory streamerFactory( contSchema ); m_updater.reset( streamerFactory.newUpdater( type, mapping )); m_updater->build( m_topLevelElement, *m_topLevelUpdate, m_operationBuffer ); }
ora::UpdateBuffer::~UpdateBuffer | ( | ) | [inline] |
Definition at line 113 of file DatabaseContainer.cc.
{ }
size_t ora::UpdateBuffer::flush | ( | ) | [inline] |
Definition at line 122 of file DatabaseContainer.cc.
References ora::RelationalBuffer::flush(), m_buffer, m_operationBuffer, and update().
{ size_t nobj = 0; for( std::vector<std::pair<int, const void*> >::const_iterator iU = m_buffer.begin(); iU != m_buffer.end(); ++iU ){ update( iU->first, iU->second ); if( m_operationBuffer.flush()) nobj++; } m_buffer.clear(); return nobj; }
void ora::UpdateBuffer::registerForUpdate | ( | int | oid, |
const void * | data | ||
) | [inline] |
Definition at line 117 of file DatabaseContainer.cc.
References m_buffer.
void ora::UpdateBuffer::update | ( | int | oid, |
const void * | data | ||
) | [inline, private] |
Definition at line 135 of file DatabaseContainer.cc.
References ora::InputRelationalData::data(), m_depDeleter, m_topLevelUpdate, m_updater, and ora::InputRelationalData::whereData().
Referenced by flush().
{ // erase the dependencies (cannot be updated...) m_depDeleter->erase( oid ); coral::AttributeList& dataBuff = m_topLevelUpdate->data(); dataBuff.begin()->data<int>() = oid; coral::AttributeList& whereDataBuff = m_topLevelUpdate->whereData(); whereDataBuff.begin()->data<int>() = oid; m_updater->update( oid, data ); }
std::vector<std::pair<int, const void*> > ora::UpdateBuffer::m_buffer [private] |
Definition at line 147 of file DatabaseContainer.cc.
Referenced by flush(), and registerForUpdate().
std::auto_ptr<RelationalDeleter> ora::UpdateBuffer::m_depDeleter [private] |
Definition at line 150 of file DatabaseContainer.cc.
Referenced by update(), and UpdateBuffer().
Definition at line 148 of file DatabaseContainer.cc.
Referenced by flush(), and UpdateBuffer().
Definition at line 149 of file DatabaseContainer.cc.
Referenced by UpdateBuffer().
Definition at line 152 of file DatabaseContainer.cc.
Referenced by update(), and UpdateBuffer().
std::auto_ptr<IRelationalUpdater> ora::UpdateBuffer::m_updater [private] |
Definition at line 151 of file DatabaseContainer.cc.
Referenced by update(), and UpdateBuffer().