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

const std::vector< std::string > & m_columns
DataElementm_dataElement
DataElementm_flagDataElement
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.

                                                                                     :
  m_objectType( objectType ),
  m_columns( mapping.columnNames() ),
  m_schema( schema ),
  m_dataElement( 0 ),
  m_refNameDataElement( 0 ),
  m_ptrDataElement( 0 ),
  m_flagDataElement( 0 ),
  m_relationalData( 0 ){
}
ora::NamedReferenceStreamerBase::~NamedReferenceStreamerBase ( ) [virtual]

Definition at line 32 of file NamedRefStreamer.cc.

                                                          {
}

Member Function Documentation

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

Definition at line 81 of file NamedRefStreamer.cc.

References mergeVDriftHistosByStation::name, ora::namedRefNullLabel(), 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_columns[0] ];
  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 68 of file NamedRefStreamer.cc.

References mergeVDriftHistosByStation::name, ora::namedRefNullLabel(), 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_columns[0] ];
  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 36 of file NamedRefStreamer.cc.

References ora::DataElement::addChild(), ora::IRelationalData::addData(), 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...  
  if( m_columns.size()==0 ){
      throwException("No columns found in the mapping element",
                     "NamedReferenceStreamerBase::buildDataElement");    
  }  
  relationalData.addData( m_columns[0],  typeid(std::string) );
  m_relationalData = &relationalData;
  return true;
}

Member Data Documentation

const std::vector<std::string>& ora::NamedReferenceStreamerBase::m_columns [private]

Definition at line 37 of file NamedRefStreamer.h.

Definition at line 39 of file NamedRefStreamer.h.

Definition at line 42 of file NamedRefStreamer.h.

Definition at line 36 of file NamedRefStreamer.h.

Definition at line 41 of file NamedRefStreamer.h.

Definition at line 40 of file NamedRefStreamer.h.

Definition at line 43 of file NamedRefStreamer.h.

Definition at line 38 of file NamedRefStreamer.h.