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

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.

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

Definition at line 288 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 295 of file UniqueRefStreamer.cc.

References ora::IRelationalData::addData().

                                                                  {
  m_dataElement = &dataElement;
  const std::vector<std::string>& columns = m_mappingElement.columnNames();
  // booking for ref metadata 
  relationalData.addData( columns[0],typeid(std::string) );
  // booking for ref id 
  relationalData.addData( columns[1],typeid(int) );
  m_relationalData = &relationalData;
  return true;
}
void ora::UniqueRefReader::clear ( void  ) [virtual]

Implements ora::IRelationalReader.

Definition at line 342 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 314 of file UniqueRefStreamer.cc.

References ora::DataElement::addChild(), ora::DataElement::address(), className(), ora::ClassUtils::lookupDictionary(), 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_mappingElement.columnNames()[0]].data<std::string>();
  int refId = row[m_mappingElement.columnNames()[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 307 of file UniqueRefStreamer.cc.

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

Implements ora::IRelationalReader.

Definition at line 310 of file UniqueRefStreamer.cc.

                                                           {
}

Member Data Documentation

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.

Definition at line 92 of file UniqueRefStreamer.h.

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

Definition at line 91 of file UniqueRefStreamer.h.

Definition at line 95 of file UniqueRefStreamer.h.

Definition at line 93 of file UniqueRefStreamer.h.