CMS 3D CMS Logo

Public Member Functions | Private Attributes

ora::NamedReferenceStreamerBase Class Reference

#include <NamedRefStreamer.h>

Inheritance diagram for ora::NamedReferenceStreamerBase:
ora::NamedRefReader ora::NamedRefUpdater ora::NamedRefWriter

List of all members.

Public Member Functions

void bindDataForRead (void *data)
void bindDataForUpdate (const void *data)
bool buildDataElement (DataElement &dataElement, IRelationalData &relationalData)
 NamedReferenceStreamerBase (const Reflex::Type &objectType, MappingElement &mapping, ContainerSchema &schema)
virtual ~NamedReferenceStreamerBase ()

Private Attributes

int m_columnIndex
DataElementm_dataElement
DataElementm_flagDataElement
MappingElementm_mapping
Reflex::Type m_objectType
DataElementm_ptrDataElement
DataElementm_refNameDataElement
IRelationalDatam_relationalData
ContainerSchemam_schema

Detailed Description

Definition at line 20 of file NamedRefStreamer.h.


Constructor & Destructor Documentation

ora::NamedReferenceStreamerBase::NamedReferenceStreamerBase ( const Reflex::Type &  objectType,
MappingElement mapping,
ContainerSchema schema 
) [explicit]

Definition at line 19 of file NamedRefStreamer.cc.

ora::NamedReferenceStreamerBase::~NamedReferenceStreamerBase ( ) [virtual]

Definition at line 33 of file NamedRefStreamer.cc.

                                                          {
}

Member Function Documentation

void ora::NamedReferenceStreamerBase::bindDataForRead ( void *  data)

Definition at line 83 of file NamedRefStreamer.cc.

References mergeVDriftHistosByStation::name, ora::namedRefNullLabel(), AlCaHLTBitMon_QueryRunRegistry::string, and ora::throwException().

                                                               {
  if(!m_relationalData){
    throwException("The streamer has not been built.",
                   "NamedReferenceStreamerBase::bindDataForRead");
  }
  void* refNameAddress = m_refNameDataElement->address( data );
  void* ptrAddress = m_ptrDataElement->address( data );
  void* flagAddress = m_flagDataElement->address( data );
  coral::Attribute& refNameAttr = m_relationalData->data()[ m_columnIndex ];
  std::string name = refNameAttr.data<std::string>();
  if( name == namedRefNullLabel() ){
    name = std::string("");
  }
  if(!name.empty()){
    Reflex::Type namedRefType = m_objectType.TemplateArgumentAt(0);
    boost::shared_ptr<void> ptr = m_schema.dbSession().fetchTypedObjectByName( name, namedRefType );
    *static_cast<boost::shared_ptr<void>*>(ptrAddress) = ptr;
    *static_cast<bool*>(flagAddress) = true;
  }
  *static_cast<std::string*>(refNameAddress) = name;
}
void ora::NamedReferenceStreamerBase::bindDataForUpdate ( const void *  data)

Definition at line 70 of file NamedRefStreamer.cc.

References mergeVDriftHistosByStation::name, ora::namedRefNullLabel(), AlCaHLTBitMon_QueryRunRegistry::string, and ora::throwException().

                                                                       {
  if(!m_relationalData){
    throwException("The streamer has not been built.",
                   "NamedReferenceStreamerBase::bindDataForUpdate");
  }
  
  void* refNameAddress = m_refNameDataElement->address( data );
  coral::Attribute& refNameAttr = m_relationalData->data()[ m_columnIndex ];
  std::string name = *static_cast<std::string*>(refNameAddress);
  if( name.empty() ) name = namedRefNullLabel();
  refNameAttr.data<std::string>()= name;
}
bool ora::NamedReferenceStreamerBase::buildDataElement ( DataElement dataElement,
IRelationalData relationalData 
)

Definition at line 37 of file NamedRefStreamer.cc.

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

                                                                                       {
  m_dataElement = &dataElement;
  m_objectType.UpdateMembers();
  Reflex::Member nameMember = m_objectType.DataMemberByName("m_name");
  if( !nameMember ){
    throwException("Data member \"m_name\" not found in class \""+m_objectType.Name()+"\".",
                   "NamedReferenceStreamerBase::buildDataElement");
  }
  m_refNameDataElement = &dataElement.addChild( nameMember.Offset(), 0 );
  Reflex::Member ptrMember = m_objectType.DataMemberByName("m_ptr");
  if( !ptrMember ){
    throwException("Data member \"m_ptr\" not found in class \""+m_objectType.Name()+"\".",
                   "NamedReferenceStreamerBase::buildDataElement");
  }
  m_ptrDataElement = &dataElement.addChild( ptrMember.Offset(), 0 );
  Reflex::Member flagMember = m_objectType.DataMemberByName("m_isPersistent");
  if( !flagMember ){
    throwException("Data member \"m_isPersistent\" not found in class \""+m_objectType.Name()+"\".",
                   "NamedReferenceStreamerBase::buildDataElement");
  }
  m_flagDataElement = &dataElement.addChild( flagMember.Offset(), 0 );
  // then book the column in the data attribute... 
  const std::vector<std::string>& columns =  m_mapping.columnNames();
  if( columns.size()==0 ){
      throwException("No columns found in the mapping element",
                     "NamedReferenceStreamerBase::buildDataElement");    
  }  
  m_columnIndex = relationalData.addData( columns[0],  typeid(std::string) );
  m_relationalData = &relationalData;
  return true;
}

Member Data Documentation

Definition at line 38 of file NamedRefStreamer.h.

Definition at line 40 of file NamedRefStreamer.h.

Definition at line 43 of file NamedRefStreamer.h.

Definition at line 37 of file NamedRefStreamer.h.

Definition at line 36 of file NamedRefStreamer.h.

Definition at line 42 of file NamedRefStreamer.h.

Definition at line 41 of file NamedRefStreamer.h.

Definition at line 44 of file NamedRefStreamer.h.

Definition at line 39 of file NamedRefStreamer.h.