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::OraPtrReadBuffer Class Reference

Public Member Functions

bool build (DataElement &dataElement)
 
 OraPtrReadBuffer (const Reflex::Type &objectType, MappingElement &mapping, ContainerSchema &contSchema)
 
void * read (const std::vector< int > &fullId)
 
 ~OraPtrReadBuffer ()
 

Private Attributes

DataElementm_dataElement
 
DataElement m_localElement
 
MappingElementm_mapping
 
Reflex::Type m_objectType
 
SelectOperation m_query
 
std::auto_ptr< IRelationalReaderm_reader
 
ContainerSchemam_schema
 

Detailed Description

Definition at line 15 of file OraPtrStreamer.cc.

Constructor & Destructor Documentation

ora::OraPtrReadBuffer::OraPtrReadBuffer ( const Reflex::Type &  objectType,
MappingElement mapping,
ContainerSchema contSchema 
)
inline

Definition at line 17 of file OraPtrStreamer.cc.

17  :
18  m_objectType( objectType ),
19  m_mapping( mapping ),
20  m_schema( contSchema ),
22  m_query( mapping.tableName(), contSchema.storageSchema() ),
23  m_dataElement( 0 ),
24  m_reader(){
25  }
DataElement * m_dataElement
std::auto_ptr< IRelationalReader > m_reader
SelectOperation m_query
Reflex::Type m_objectType
MappingElement & m_mapping
ContainerSchema & m_schema
ora::OraPtrReadBuffer::~OraPtrReadBuffer ( )
inline

Definition at line 27 of file OraPtrStreamer.cc.

27  {
28  }

Member Function Documentation

bool ora::OraPtrReadBuffer::build ( DataElement dataElement)
inline

Definition at line 30 of file OraPtrStreamer.cc.

References ora::SelectOperation::addWhereId(), ora::DataElement::clear(), ora::MappingElement::columnNames(), ora::MappingElement::end(), ora::MappingElement::find(), i, m_dataElement, m_localElement, m_mapping, m_objectType, m_query, m_reader, m_schema, ora::RelationalStreamerFactory::newReader(), ora::ClassUtils::resolvedType(), AlCaHLTBitMon_QueryRunRegistry::string, and ora::throwException().

Referenced by psClasses.BuildThread::run().

30  {
31  m_dataElement = &dataElement;
33 
34  const std::vector<std::string>& columns = m_mapping.columnNames();
35  size_t cols = columns.size();
36  for( size_t i=0; i<cols; i++ ){
37  m_query.addWhereId( columns[ i ] );
38  }
39 
40  // Check the type
41  Reflex::Type ptrType = m_objectType.TemplateArgumentAt(0);
42  Reflex::Type ptrResolvedType = ClassUtils::resolvedType(ptrType);
43  // Check the component type
44  if ( ! ptrType || !ptrResolvedType ) {
45  throwException( "Missing dictionary information for the type of the pointer \"" +
46  m_objectType.Name(Reflex::SCOPED|Reflex::FINAL) + "\"",
47  "OraPtrReadBuffer::build" );
48  }
49 
50  std::string ptrTypeName = ptrType.Name();
51  // Retrieve the relevant mapping element
52  MappingElement::iterator iMe = m_mapping.find( ptrTypeName );
53  if ( iMe == m_mapping.end() ) {
54  throwException( "Item for \"" + ptrTypeName + "\" not found in the mapping element",
55  "OraPtrReadBuffer::build" );
56  }
57  RelationalStreamerFactory streamerFactory( m_schema );
58  m_reader.reset( streamerFactory.newReader( ptrResolvedType, iMe->second ) );
59  return m_reader->build( m_localElement, m_query );
60  }
int i
Definition: DBlmapReader.cc:9
DataElement * m_dataElement
std::auto_ptr< IRelationalReader > m_reader
int addWhereId(const std::string &columnName)
SelectOperation m_query
iterator find(const std::string &key)
Retrieves a sub-element.
Reflex::Type m_objectType
std::map< std::string, MappingElement >::iterator iterator
Iterator definition.
const std::vector< std::string > & columnNames() const
Reflex::Type resolvedType(const Reflex::Type &typ)
Definition: ClassUtils.cc:404
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.
MappingElement & m_mapping
ContainerSchema & m_schema
void* ora::OraPtrReadBuffer::read ( const std::vector< int > &  fullId)
inline

Definition at line 62 of file OraPtrStreamer.cc.

References ora::SelectOperation::clear(), ora::ClassUtils::constructObject(), roll_playback::destination, ora::SelectOperation::execute(), i, m_dataElement, m_objectType, m_query, m_reader, ora::SelectOperation::nextCursorRow(), ora::throwException(), and ora::SelectOperation::whereData().

Referenced by Vispa.Plugins.EdmBrowser.EdmDataAccessor.EdmDataAccessor::goto(), ora::RelationalPtrLoader::load(), and Vispa.Plugins.EdmBrowser.EdmDataAccessor.EdmDataAccessor::setFilterBranches().

62  {
63  if(!m_dataElement) throwException( "Read buffer has not been built.","OraPtrReadBuffer::read");
64 
65  if(!fullId.size()) throwException( "Object id set is empty.","OraPtrReadBuffer::read");
66 
67  coral::AttributeList& whereBuff = m_query.whereData();
68  coral::AttributeList::iterator iCol = whereBuff.begin();
69  size_t i=0;
70  for( coral::AttributeList::iterator iCol = whereBuff.begin(); iCol != whereBuff.end(); ++iCol ){
71  if( i<fullId.size() ){
72  iCol->data<int>() = fullId[i];
73  }
74  i++;
75  }
76 
77  std::vector<int> recordId( fullId.size()-1 );
78  for( size_t i=0; i<fullId.size()-1; i++ ){
79  recordId[i] = fullId[i+1];
80  ++i;
81  }
82 
83  m_query.execute();
84  m_reader->select( fullId[0] );
85  void* destination = 0;
86  if( m_query.nextCursorRow() ){
87  destination = ClassUtils::constructObject( m_objectType.TemplateArgumentAt(0) );
88  m_reader->setRecordId( recordId );
89  m_reader->read( destination );
90  }
91  m_query.clear();
92  m_reader->clear();
93  return destination;
94  }
int i
Definition: DBlmapReader.cc:9
void * constructObject(const Reflex::Type &typ)
Definition: ClassUtils.cc:127
DataElement * m_dataElement
string destination
std::auto_ptr< IRelationalReader > m_reader
SelectOperation m_query
Reflex::Type m_objectType
coral::AttributeList & whereData()
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10

Member Data Documentation

DataElement* ora::OraPtrReadBuffer::m_dataElement
private

Definition at line 102 of file OraPtrStreamer.cc.

Referenced by build(), and read().

DataElement ora::OraPtrReadBuffer::m_localElement
private

Definition at line 100 of file OraPtrStreamer.cc.

Referenced by build().

MappingElement& ora::OraPtrReadBuffer::m_mapping
private

Definition at line 98 of file OraPtrStreamer.cc.

Referenced by build().

Reflex::Type ora::OraPtrReadBuffer::m_objectType
private

Definition at line 97 of file OraPtrStreamer.cc.

Referenced by build(), and read().

SelectOperation ora::OraPtrReadBuffer::m_query
private

Definition at line 101 of file OraPtrStreamer.cc.

Referenced by build(), and read().

std::auto_ptr<IRelationalReader> ora::OraPtrReadBuffer::m_reader
private

Definition at line 103 of file OraPtrStreamer.cc.

Referenced by build(), and read().

ContainerSchema& ora::OraPtrReadBuffer::m_schema
private

Definition at line 99 of file OraPtrStreamer.cc.

Referenced by build().