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

#include <UniqueRefStreamer.h>

Inheritance diagram for ora::UniqueRefReader:
ora::IRelationalReader

Public Member Functions

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

Private Attributes

DataElementm_dataElement
 
std::vector< boost::shared_ptr
< RelationalRefLoader > > 
m_loaders
 
MappingElementm_mappingElement
 
Reflex::Type m_objectType
 
IRelationalDatam_relationalData
 
ContainerSchemam_schema
 

Detailed Description

Definition at line 70 of file UniqueRefStreamer.h.

Constructor & Destructor Documentation

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

Definition at line 277 of file UniqueRefStreamer.cc.

279  :
280  m_objectType( objectType ),
281  m_mappingElement( mapping ),
282  m_schema( contSchema ),
283  m_dataElement( 0 ),
284  m_relationalData( 0 ),
285  m_loaders(){
286 }
std::vector< boost::shared_ptr< RelationalRefLoader > > m_loaders
ContainerSchema & m_schema
IRelationalData * m_relationalData
DataElement * m_dataElement
MappingElement & m_mappingElement
ora::UniqueRefReader::~UniqueRefReader ( )
virtual

Definition at line 288 of file UniqueRefStreamer.cc.

288  {
289  for(std::vector<boost::shared_ptr<RelationalRefLoader> >::const_iterator iL = m_loaders.begin();
290  iL != m_loaders.end(); ++iL ){
291  (*iL)->invalidate();
292  }
293 }
std::vector< boost::shared_ptr< RelationalRefLoader > > m_loaders

Member Function Documentation

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

Implements ora::IRelationalReader.

Definition at line 295 of file UniqueRefStreamer.cc.

References ora::IRelationalData::addData().

296  {
297  m_dataElement = &dataElement;
298  const std::vector<std::string>& columns = m_mappingElement.columnNames();
299  // booking for ref metadata
300  relationalData.addData( columns[0],typeid(std::string) );
301  // booking for ref id
302  relationalData.addData( columns[1],typeid(int) );
303  m_relationalData = &relationalData;
304  return true;
305 }
const std::vector< std::string > & columnNames() const
IRelationalData * m_relationalData
DataElement * m_dataElement
MappingElement & m_mappingElement
void ora::UniqueRefReader::clear ( void  )
virtual
void ora::UniqueRefReader::read ( void *  destination)
virtual

Reads a data element.

Read a data element.

Implements ora::IRelationalReader.

Definition at line 314 of file UniqueRefStreamer.cc.

References ora::DataElement::addChild(), ora::DataElement::address(), className(), ora::ClassUtils::lookupDictionary(), ora::throwException(), and tmp.

Referenced by python.Vispa.Plugins.EdmBrowser.EdmDataAccessor.EdmDataAccessor::goto(), and python.Vispa.Plugins.EdmBrowser.EdmDataAccessor.EdmDataAccessor::setFilterBranches().

314  {
315  if(!m_dataElement){
316  throwException("The streamer has not been built.",
317  "UniqueRefReader::read");
318  }
319  coral::AttributeList& row = m_relationalData->data();
320  std::string className = row[m_mappingElement.columnNames()[0]].data<std::string>();
321  int refId = row[m_mappingElement.columnNames()[1]].data<int>();
322 
323  Reflex::Type refType = ClassUtils::lookupDictionary(className);
324 
325  // building the dependent buffer
326  MappingElement& depMapping = m_schema.mappingForDependentClass( refType );
327 
328  // resolving loader address
329  Reflex::Member loaderMember = m_objectType.MemberByName("m_loader");
330  DataElement& loaderElement = m_dataElement->addChild( loaderMember.Offset(), 0 );
331  void* loaderAddress = loaderElement.address( data );
332  boost::shared_ptr<IPtrLoader>* loaderPtr = static_cast<boost::shared_ptr<IPtrLoader>*>( loaderAddress );
333  // creating new loader
334  boost::shared_ptr<RelationalRefLoader> newLoader( new RelationalRefLoader( refId ) );
335  newLoader->build( refType, depMapping, m_schema );
336  m_loaders.push_back( newLoader );
337  // installing the new loader
338  boost::shared_ptr<IPtrLoader> tmp( newLoader );
339  *loaderPtr = tmp;
340 }
void * address(const void *topLevelAddress) const
Definition: DataElement.cc:48
std::vector< boost::shared_ptr< RelationalRefLoader > > m_loaders
DataElement & addChild(size_t declaringScopeOffset, Reflex::OffsetFunction offsetFunction)
Definition: DataElement.cc:26
ContainerSchema & m_schema
MappingElement & mappingForDependentClass(const Reflex::Type &dependentClass, bool writeEnabled=false)
const std::vector< std::string > & columnNames() const
IRelationalData * m_relationalData
virtual coral::AttributeList & data()=0
DataElement * m_dataElement
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:10
Reflex::Type lookupDictionary(const std::type_info &typeInfo, bool throwFlag=true)
Definition: ClassUtils.cc:84
MappingElement & m_mappingElement
std::string className(const T &t)
Definition: ClassName.h:30
void ora::UniqueRefReader::select ( int  oid)
virtual
void ora::UniqueRefReader::setRecordId ( const std::vector< int > &  identity)
virtual

Implements ora::IRelationalReader.

Definition at line 310 of file UniqueRefStreamer.cc.

310  {
311 }

Member Data Documentation

DataElement* ora::UniqueRefReader::m_dataElement
private

Definition at line 94 of file UniqueRefStreamer.h.

std::vector<boost::shared_ptr<RelationalRefLoader> > ora::UniqueRefReader::m_loaders
private

Definition at line 96 of file UniqueRefStreamer.h.

MappingElement& ora::UniqueRefReader::m_mappingElement
private

Definition at line 92 of file UniqueRefStreamer.h.

Reflex::Type ora::UniqueRefReader::m_objectType
private

Definition at line 91 of file UniqueRefStreamer.h.

IRelationalData* ora::UniqueRefReader::m_relationalData
private

Definition at line 95 of file UniqueRefStreamer.h.

ContainerSchema& ora::UniqueRefReader::m_schema
private

Definition at line 93 of file UniqueRefStreamer.h.