test
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 Attributes
ora::STLContainerReader Class Reference

#include <STLContainerStreamer.h>

Inheritance diagram for ora::STLContainerReader:
ora::IRelationalReader

Public Member Functions

bool build (DataElement &offset, IRelationalData &relationalData)
 
void clear ()
 
void read (void *address)
 Reads a data element. More...
 
void select (int oid)
 
void setRecordId (const std::vector< int > &identity)
 
 STLContainerReader (const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &contSchema)
 Constructor. More...
 
virtual ~STLContainerReader ()
 
- Public Member Functions inherited from ora::IRelationalReader
virtual ~IRelationalReader ()
 

Private Attributes

std::auto_ptr< IArrayHandlerm_arrayHandler
 
bool m_associative
 
std::auto_ptr< IRelationalReaderm_dataReader
 
std::auto_ptr< IRelationalReaderm_keyReader
 
DataElement m_localElement
 
MappingElementm_mappingElement
 
edm::TypeWithDict m_objectType
 
DataElementm_offset
 
std::auto_ptr
< MultiRecordSelectOperation
m_query
 
std::vector< int > m_recordId
 
ContainerSchemam_schema
 

Detailed Description

Definition at line 79 of file STLContainerStreamer.h.

Constructor & Destructor Documentation

ora::STLContainerReader::STLContainerReader ( const edm::TypeWithDict objectType,
MappingElement mapping,
ContainerSchema contSchema 
)

Constructor.

Definition at line 237 of file STLContainerStreamer.cc.

239  :
240  m_objectType( objectType ),
241  m_mappingElement( mapping ),
242  m_schema( contSchema ),
243  m_recordId(),
244  m_localElement(),
246  m_offset(0 ),
247  m_query(),
248  m_arrayHandler(),
249  m_keyReader(),
250  m_dataReader(){
251 }
std::auto_ptr< IRelationalReader > m_keyReader
MappingElement & m_mappingElement
std::auto_ptr< IArrayHandler > m_arrayHandler
std::auto_ptr< MultiRecordSelectOperation > m_query
std::auto_ptr< IRelationalReader > m_dataReader
std::vector< int > m_recordId
edm::TypeWithDict m_objectType
bool isTypeAssociativeContainer(const edm::TypeWithDict &typ)
Definition: ClassUtils.cc:286
ora::STLContainerReader::~STLContainerReader ( )
virtual

Definition at line 253 of file STLContainerStreamer.cc.

253  {
254 }

Member Function Documentation

bool ora::STLContainerReader::build ( DataElement offset,
IRelationalData relationalData 
)
virtual

Implements ora::IRelationalReader.

Definition at line 256 of file STLContainerStreamer.cc.

References ora::ClassUtils::containerDataType(), ora::ClassUtils::containerKeyType(), ora::ClassUtils::containerValueType(), i, ora::ArrayHandlerFactory::newArrayHandler(), ora::RelationalStreamerFactory::newReader(), hltrates_dqm_sourceclient-live_cfg::offset, ora::ClassUtils::resolvedType(), AlCaHLTBitMon_QueryRunRegistry::string, ora::throwException(), and edm::TypeWithDict::unscopedName().

Referenced by psClasses.BuildThread::run().

256  {
258  m_recordId.clear();
259  // allocate for the index...
260  m_recordId.push_back(0);
261 
262  RelationalStreamerFactory streamerFactory( m_schema );
263 
264  // first open the insert on the extra table...
265  m_query.reset( new MultiRecordSelectOperation( m_mappingElement.tableName(), m_schema.storageSchema() ));
266 
267  m_query->addWhereId( m_mappingElement.pkColumn() );
268  std::vector<std::string> recIdCols = m_mappingElement.recordIdColumns();
269  for( size_t i=0; i<recIdCols.size(); i++ ){
270  m_query->addId( recIdCols[ i ] );
271  m_query->addOrderId( recIdCols[ i ] );
272  }
273 
274  m_offset = &offset;
275 
277 
278  edm::TypeWithDict valueType;
279  if ( m_associative ){
280 
282  edm::TypeWithDict keyResolvedType = ClassUtils::resolvedType(keyType);
283 
284  if ( ! keyType ||!keyResolvedType ) {
285  throwException( "Missing dictionary information for the key type of the container \"" +
286  m_objectType.cppName() + "\"",
287  "STLContainerReader::build" );
288  }
289 
290  std::string keyName("key_type");
291  // Retrieve the relevant mapping element
293  if ( iMe == m_mappingElement.end() ) {
294  throwException( "Item for \"" + keyName + "\" not found in the mapping element",
295  "STLContainerReader::build" );
296  }
297 
298  m_keyReader.reset( streamerFactory.newReader( keyResolvedType, iMe->second ) );
299  m_keyReader->build( m_localElement, *m_query );
300 
302  } else {
304  }
305 
306  edm::TypeWithDict valueResolvedType = ClassUtils::resolvedType(valueType);
307  // Check the component type
308  if ( ! valueType ||!valueResolvedType ) {
309  throwException( "Missing dictionary information for the content type of the container \"" +
310  m_objectType.cppName() + "\"",
311  "STLContainerReader::build" );
312  }
313 
314  std::string valueName(m_associative ? "mapped_type" : "value_type");
315  // Retrieve the relevant mapping element
317  if ( iMe == m_mappingElement.end() ) {
318  // Try again with the name of a possible typedef
319  std::string valueName2 = valueType.unscopedName();
320  iMe = m_mappingElement.find( valueName2 );
321  if ( iMe == m_mappingElement.end() ) {
322  throwException( "Item for \"" + valueName + "\" not found in the mapping element",
323  "STLContainerReader::build" );
324  }
325  }
326 
327  m_dataReader.reset( streamerFactory.newReader( valueResolvedType, iMe->second ) );
328  m_dataReader->build( m_localElement, *m_query );
329  return true;
330 }
std::auto_ptr< IRelationalReader > m_keyReader
int i
Definition: DBlmapReader.cc:9
edm::TypeWithDict resolvedType(const edm::TypeWithDict &typ)
Definition: ClassUtils.cc:486
MappingElement & m_mappingElement
std::string unscopedName() const
std::auto_ptr< IArrayHandler > m_arrayHandler
std::auto_ptr< MultiRecordSelectOperation > m_query
std::string cppName() const
std::vector< std::string > recordIdColumns() const
static IArrayHandler * newArrayHandler(const edm::TypeWithDict &arrayType)
std::auto_ptr< IRelationalReader > m_dataReader
std::vector< int > m_recordId
iterator find(const std::string &key)
Retrieves a sub-element.
std::string pkColumn() const
std::map< std::string, MappingElement >::iterator iterator
Iterator definition.
edm::TypeWithDict m_objectType
coral::ISchema & storageSchema()
edm::TypeWithDict containerKeyType(const edm::TypeWithDict &typ)
Definition: ClassUtils.cc:429
edm::TypeWithDict containerDataType(const edm::TypeWithDict &typ)
Definition: ClassUtils.cc:449
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
iterator end()
Returns an iterator in the end of the sequence.
edm::TypeWithDict containerValueType(const edm::TypeWithDict &typ)
Definition: ClassUtils.cc:410
const std::string & tableName() const
void ora::STLContainerReader::clear ( void  )
virtual
void ora::STLContainerReader::read ( void *  address)
virtual

Reads a data element.

Implements ora::IRelationalReader.

Definition at line 353 of file STLContainerStreamer.cc.

References edm::ObjectWithDict::address(), edm::TypeWithDict::construct(), edm::TypeWithDict::cppName(), edm::TypeWithDict::dataMemberByName(), edm::TypeWithDict::destruct(), i, edm::TypeWithDict::isFundamental(), edm::MemberWithDict::offset(), edm::TypeWithDict::templateArgumentAt(), and ora::throwException().

Referenced by edmIntegrityCheck.PublishToFileSystem::get(), Vispa.Plugins.EdmBrowser.EdmDataAccessor.EdmDataAccessor::goto(), and Vispa.Plugins.EdmBrowser.EdmDataAccessor.EdmDataAccessor::setFilterBranches().

353  {
354 
355  if(!m_offset){
356  throwException("The streamer has not been built.",
357  "STLContainerReader::read");
358  }
359 
360  void* address = m_offset->address( destinationData );
361 
362  const edm::TypeWithDict& iteratorReturnType = m_arrayHandler->iteratorReturnType();
363  U_Primitives primitiveStub;
364 
365  edm::TypeWithDict keyType;
366  edm::MemberWithDict firstMember;
367  edm::MemberWithDict secondMember;
368  if ( m_associative ) {
369  keyType = m_objectType.templateArgumentAt(0);
370  firstMember = iteratorReturnType.dataMemberByName( "first" );
371  if ( ! firstMember ) {
372  throwException("Could not retrieve the data member \"first\" of the class \"" +
373  iteratorReturnType.cppName() + "\"",
374  "STLContainerReader::read" );
375  }
376  secondMember = iteratorReturnType.dataMemberByName( "second" );
377  if ( ! secondMember ) {
378  throwException( "Could not retrieve the data member \"second\" of the class \"" +
379  iteratorReturnType.cppName() + "\"",
380  "STLContainerReader::read" );
381  }
382  }
383 
384  bool isElementFundamental = iteratorReturnType.isFundamental();
385 
386  m_arrayHandler->clear( address );
387 
388  size_t cursorSize = m_query->selectionSize(m_recordId, m_recordId.size()-1);
389  unsigned int i=0;
390  // Create a new element for the array
391  void* objectData = 0;
392  if(isElementFundamental){
393  objectData = &primitiveStub;
394  } else {
395  objectData = iteratorReturnType.construct().address();
396  }
397 
398  while ( i< cursorSize ){
399 
400  m_recordId[m_recordId.size()-1] = (int)i;
401  m_query->selectRow( m_recordId );
402 
403  void* componentData = objectData;
404  void* keyData = 0;
405 
406  if ( keyType ) { // treat the key object first
407  keyData = static_cast< char* >( objectData ) + firstMember.offset();
408  m_keyReader->setRecordId( m_recordId );
409  m_keyReader->read( keyData );
410 
411  componentData = static_cast< char* >( objectData ) + secondMember.offset();
412  }
413  m_dataReader->setRecordId( m_recordId );
414  m_dataReader->read( componentData );
415 
416  size_t prevSize = m_arrayHandler->size( address );
417  m_arrayHandler->appendNewElement( address, objectData );
418  bool inserted = m_arrayHandler->size( address )>prevSize;
419  if ( !inserted ) {
420  throwException( "Could not insert a new element in the array type \"" +
421  m_objectType.cppName() + "\"",
422  "STLContainerReader::read" );
423  }
424  ++i;
425  }
426  if ( ! ( iteratorReturnType.isFundamental() ) ) {
427  iteratorReturnType.destruct( objectData );
428  }
429 
430  m_arrayHandler->finalize( address );
431 
432 }
std::auto_ptr< IRelationalReader > m_keyReader
int i
Definition: DBlmapReader.cc:9
void * address() const
void * address(const void *topLevelAddress) const
Definition: DataElement.cc:49
size_t offset() const
TypeWithDict templateArgumentAt(size_t index) const
MemberWithDict dataMemberByName(std::string const &) const
std::auto_ptr< IArrayHandler > m_arrayHandler
std::auto_ptr< MultiRecordSelectOperation > m_query
std::string cppName() const
bool isFundamental() const
std::auto_ptr< IRelationalReader > m_dataReader
std::vector< int > m_recordId
edm::TypeWithDict m_objectType
void destruct(void *address, bool dealloc=true) const
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
ObjectWithDict construct() const
void ora::STLContainerReader::select ( int  oid)
virtual

Implements ora::IRelationalReader.

Definition at line 332 of file STLContainerStreamer.cc.

References ora::throwException().

Referenced by Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::find(), Vispa.Views.LineDecayView.LineDecayContainer::mousePressEvent(), Vispa.Gui.PortConnection.PointToPointConnection::mousePressEvent(), Vispa.Gui.VispaWidget.VispaWidget::mousePressEvent(), and Vispa.Views.AbstractView.AbstractView::restoreSelection().

332  {
333  if(!m_query.get()){
334  throwException("The streamer has not been built.",
335  "STLContainerReader::read");
336  }
337  coral::AttributeList& whereData = m_query->whereData();
338  whereData[ m_mappingElement.pkColumn() ].data<int>() = oid;
339  m_query->execute();
340  if(m_keyReader.get()) m_keyReader->select( oid );
341  m_dataReader->select( oid );
342 }
std::auto_ptr< IRelationalReader > m_keyReader
MappingElement & m_mappingElement
std::auto_ptr< MultiRecordSelectOperation > m_query
std::auto_ptr< IRelationalReader > m_dataReader
std::string pkColumn() const
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
void ora::STLContainerReader::setRecordId ( const std::vector< int > &  identity)
virtual

Implements ora::IRelationalReader.

Definition at line 344 of file STLContainerStreamer.cc.

References i.

344  {
345  m_recordId.clear();
346  for(size_t i=0;i<identity.size();i++) {
347  m_recordId.push_back( identity[i] );
348  }
349  // allocate the element for the index...
350  m_recordId.push_back( 0 );
351 }
int i
Definition: DBlmapReader.cc:9
std::vector< int > m_recordId

Member Data Documentation

std::auto_ptr<IArrayHandler> ora::STLContainerReader::m_arrayHandler
private

Definition at line 110 of file STLContainerStreamer.h.

bool ora::STLContainerReader::m_associative
private

Definition at line 107 of file STLContainerStreamer.h.

std::auto_ptr<IRelationalReader> ora::STLContainerReader::m_dataReader
private

Definition at line 112 of file STLContainerStreamer.h.

std::auto_ptr<IRelationalReader> ora::STLContainerReader::m_keyReader
private

Definition at line 111 of file STLContainerStreamer.h.

DataElement ora::STLContainerReader::m_localElement
private

Definition at line 104 of file STLContainerStreamer.h.

MappingElement& ora::STLContainerReader::m_mappingElement
private

Definition at line 101 of file STLContainerStreamer.h.

edm::TypeWithDict ora::STLContainerReader::m_objectType
private

Definition at line 100 of file STLContainerStreamer.h.

DataElement* ora::STLContainerReader::m_offset
private

Definition at line 108 of file STLContainerStreamer.h.

std::auto_ptr<MultiRecordSelectOperation> ora::STLContainerReader::m_query
private

Definition at line 109 of file STLContainerStreamer.h.

std::vector<int> ora::STLContainerReader::m_recordId
private

Definition at line 103 of file STLContainerStreamer.h.

ContainerSchema& ora::STLContainerReader::m_schema
private

Definition at line 102 of file STLContainerStreamer.h.