CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
ora::UpdateBuffer Class Reference

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< RelationalDeleterm_depDeleter
 
RelationalBuffer m_operationBuffer
 
DataElement m_topLevelElement
 
UpdateOperationm_topLevelUpdate
 
std::auto_ptr< IRelationalUpdaterm_updater
 

Detailed Description

Definition at line 79 of file DatabaseContainer.cc.

Constructor & Destructor Documentation

ora::UpdateBuffer::UpdateBuffer ( ContainerSchema contSchema)
inlineexplicit

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().

81  :
82  m_buffer(),
83  m_operationBuffer( contSchema.storageSchema() ),
85  m_depDeleter(),
86  m_updater(),
87  m_topLevelUpdate( 0 ){
88 
89  std::vector<MappingElement> dependentMappings;
90  contSchema.mappingForDependentClasses( dependentMappings );
91  m_depDeleter.reset( new RelationalDeleter( dependentMappings ) );
93  dependentMappings.clear();
94 
95  MappingElement& topLevelMapping = contSchema.mapping( true ).topElement();
96  m_topLevelUpdate = &m_operationBuffer.newUpdate( topLevelMapping.tableName(), true );
97  m_topLevelUpdate->addId( topLevelMapping.columnNames()[ 0 ] );
98  m_topLevelUpdate->addWhereId( topLevelMapping.columnNames()[ 0 ] );
99  const Reflex::Type& type = contSchema.type();
100  MappingElement::iterator iMap = topLevelMapping.find( type.Name(Reflex::SCOPED) );
101  // the first inner mapping is the relevant...
102  if( iMap == topLevelMapping.end()){
103  throwException("Could not find a mapping element for class \""+
104  type.Name(Reflex::SCOPED)+"\"",
105  "UpdateBuffer::UpdateBuffer");
106  }
107  MappingElement& mapping = iMap->second;
108  RelationalStreamerFactory streamerFactory( contSchema );
109  m_updater.reset( streamerFactory.newUpdater( type, mapping ));
111  }
type
Definition: HCALResponse.h:22
std::auto_ptr< RelationalDeleter > m_depDeleter
DataElement m_topLevelElement
RelationalBuffer m_operationBuffer
std::auto_ptr< IRelationalUpdater > m_updater
void addId(const std::string &columnName)
std::map< std::string, MappingElement >::iterator iterator
Iterator definition.
std::vector< std::pair< int, const void * > > m_buffer
UpdateOperation * m_topLevelUpdate
void addWhereId(const std::string &columnName)
UpdateOperation & newUpdate(const std::string &tableName, bool addToResult=false)
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:10
ora::UpdateBuffer::~UpdateBuffer ( )
inline

Definition at line 113 of file DatabaseContainer.cc.

113  {
114  }

Member Function Documentation

size_t ora::UpdateBuffer::flush ( )
inline

Definition at line 122 of file DatabaseContainer.cc.

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

122  {
123  size_t nobj = 0;
124  for( std::vector<std::pair<int, const void*> >::const_iterator iU = m_buffer.begin();
125  iU != m_buffer.end(); ++iU ){
126  update( iU->first, iU->second );
127  if( m_operationBuffer.flush()) nobj++;
128  }
129  m_buffer.clear();
130  return nobj;
131  }
RelationalBuffer m_operationBuffer
std::vector< std::pair< int, const void * > > m_buffer
void update(int oid, const void *data)
void ora::UpdateBuffer::registerForUpdate ( int  oid,
const void *  data 
)
inline

Definition at line 117 of file DatabaseContainer.cc.

References m_buffer.

117  {
118  m_buffer.push_back( std::make_pair( oid, data ));
119  }
std::vector< std::pair< int, const void * > > m_buffer
void ora::UpdateBuffer::update ( int  oid,
const void *  data 
)
inlineprivate

Definition at line 135 of file DatabaseContainer.cc.

References ora::InputRelationalData::data(), m_depDeleter, m_topLevelUpdate, m_updater, and ora::InputRelationalData::whereData().

Referenced by python.seqvaluedict.seqdict::__setslice__(), python.Vispa.Gui.VispaWidget.VispaWidget::autosize(), python.Vispa.Views.LineDecayView.LineDecayContainer::createObject(), python.Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), python.Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), python.seqvaluedict.seqdict::extend(), flush(), python.Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), python.Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), python.Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), python.Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), python.Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), python.Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), python.Vispa.Gui.FindDialog.FindDialog::reset(), python.Vispa.Gui.PortConnection.PointToPointConnection::select(), python.Vispa.Gui.VispaWidget.VispaWidget::select(), python.Vispa.Views.LineDecayView.LineDecayContainer::select(), python.Vispa.Gui.VispaWidget.VispaWidget::setText(), python.Vispa.Gui.VispaWidget.VispaWidget::setTitle(), python.Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), python.Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and python.Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

135  {
136  // erase the dependencies (cannot be updated...)
137  m_depDeleter->erase( oid );
138  coral::AttributeList& dataBuff = m_topLevelUpdate->data();
139  dataBuff.begin()->data<int>() = oid;
140  coral::AttributeList& whereDataBuff = m_topLevelUpdate->whereData();
141  whereDataBuff.begin()->data<int>() = oid;
142  m_updater->update( oid, data );
143  }
std::auto_ptr< RelationalDeleter > m_depDeleter
coral::AttributeList & whereData()
std::auto_ptr< IRelationalUpdater > m_updater
UpdateOperation * m_topLevelUpdate
coral::AttributeList & data()

Member Data Documentation

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().

RelationalBuffer ora::UpdateBuffer::m_operationBuffer
private

Definition at line 148 of file DatabaseContainer.cc.

Referenced by flush(), and UpdateBuffer().

DataElement ora::UpdateBuffer::m_topLevelElement
private

Definition at line 149 of file DatabaseContainer.cc.

Referenced by UpdateBuffer().

UpdateOperation* ora::UpdateBuffer::m_topLevelUpdate
private

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().