CMS 3D CMS Logo

Public Member Functions | Private Attributes

ora::UniqueRefReader Class Reference

#include <UniqueRefStreamer.h>

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

List of all members.

Public Member Functions

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

Private Attributes

int m_columnIndexes [2]
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 71 of file UniqueRefStreamer.h.


Constructor & Destructor Documentation

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

Definition at line 284 of file UniqueRefStreamer.cc.

References m_columnIndexes.

                                                                    :
  m_objectType( objectType ),
  m_mappingElement( mapping ),
  m_schema( contSchema ),
  m_dataElement( 0 ),
  m_relationalData( 0 ),
  m_loaders(){
  m_columnIndexes[0]=-1;  
  m_columnIndexes[1]=-1;  
}
ora::UniqueRefReader::~UniqueRefReader ( ) [virtual]

Definition at line 297 of file UniqueRefStreamer.cc.

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

Member Function Documentation

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

Implements ora::IRelationalReader.

Definition at line 304 of file UniqueRefStreamer.cc.

References ora::IRelationalData::addData(), AlCaHLTBitMon_QueryRunRegistry::string, and ora::throwException().

                                                                  {
  m_dataElement = &dataElement;
  const std::vector<std::string>& columns = m_mappingElement.columnNames();
  if( columns.size() < 2 ){
    throwException("Expected column names have not been found in the mapping.",
                   "UniqueRefReader::build");    
  }
  // booking for ref metadata 
  m_columnIndexes[0] = relationalData.addData( columns[0],typeid(std::string) );
  // booking for ref id 
  m_columnIndexes[1] = relationalData.addData( columns[1],typeid(int) );
  m_relationalData = &relationalData;
  return true;
}
void ora::UniqueRefReader::clear ( void  ) [virtual]

Implements ora::IRelationalReader.

Definition at line 355 of file UniqueRefStreamer.cc.

                              {
}
void ora::UniqueRefReader::read ( void *  destination) [virtual]

Reads a data element.

Read a data element.

Implements ora::IRelationalReader.

Definition at line 327 of file UniqueRefStreamer.cc.

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

                                         {
  if(!m_dataElement){
    throwException("The streamer has not been built.",
                   "UniqueRefReader::read");
  }
  coral::AttributeList& row = m_relationalData->data();
  std::string className = row[m_columnIndexes[0]].data<std::string>();
  int refId = row[m_columnIndexes[1]].data<int>();

  Reflex::Type refType = ClassUtils::lookupDictionary(className);
  
  // building the dependent buffer
  MappingElement& depMapping =  m_schema.mappingForDependentClass( refType );
  
  // resolving loader address
  Reflex::Member loaderMember = m_objectType.MemberByName("m_loader");
  DataElement& loaderElement = m_dataElement->addChild( loaderMember.Offset(), 0 );
  void* loaderAddress = loaderElement.address( data );
  boost::shared_ptr<IPtrLoader>* loaderPtr = static_cast<boost::shared_ptr<IPtrLoader>*>( loaderAddress );
  // creating new loader
  boost::shared_ptr<RelationalRefLoader> newLoader( new RelationalRefLoader( refId ) );
  newLoader->build( refType, depMapping, m_schema );
  m_loaders.push_back( newLoader );
  // installing the new loader
  boost::shared_ptr<IPtrLoader> tmp( newLoader );
  *loaderPtr = tmp;
}
void ora::UniqueRefReader::select ( int  oid) [virtual]

Implements ora::IRelationalReader.

Definition at line 320 of file UniqueRefStreamer.cc.

                                    {
}
void ora::UniqueRefReader::setRecordId ( const std::vector< int > &  identity) [virtual]

Implements ora::IRelationalReader.

Definition at line 323 of file UniqueRefStreamer.cc.

                                                           {
}

Member Data Documentation

Definition at line 94 of file UniqueRefStreamer.h.

Referenced by UniqueRefReader().

Definition at line 96 of file UniqueRefStreamer.h.

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

Definition at line 98 of file UniqueRefStreamer.h.

Definition at line 93 of file UniqueRefStreamer.h.

Reflex::Type ora::UniqueRefReader::m_objectType [private]

Definition at line 92 of file UniqueRefStreamer.h.

Definition at line 97 of file UniqueRefStreamer.h.

Definition at line 95 of file UniqueRefStreamer.h.