test
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::NamedReferenceStreamerBase Class Reference

#include <NamedRefStreamer.h>

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

Public Member Functions

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

Private Attributes

int m_columnIndex
 
DataElementm_dataElement
 
DataElementm_flagDataElement
 
MappingElementm_mapping
 
edm::TypeWithDict 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 edm::TypeWithDict objectType,
MappingElement mapping,
ContainerSchema schema 
)
explicit

Definition at line 19 of file NamedRefStreamer.cc.

21  :
22  m_objectType( objectType ),
23  m_mapping( mapping ),
24  m_columnIndex( -1 ),
25  m_schema( schema ),
26  m_dataElement( 0 ),
28  m_ptrDataElement( 0 ),
29  m_flagDataElement( 0 ),
30  m_relationalData( 0 ){
31 }
tuple schema
Definition: dataDML.py:2334
ora::NamedReferenceStreamerBase::~NamedReferenceStreamerBase ( )
virtual

Definition at line 33 of file NamedRefStreamer.cc.

33  {
34 }

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, edm::TypeWithDict::templateArgumentAt(), and ora::throwException().

83  {
84  if(!m_relationalData){
85  throwException("The streamer has not been built.",
86  "NamedReferenceStreamerBase::bindDataForRead");
87  }
88  void* refNameAddress = m_refNameDataElement->address( data );
89  void* ptrAddress = m_ptrDataElement->address( data );
90  void* flagAddress = m_flagDataElement->address( data );
91  coral::Attribute& refNameAttr = m_relationalData->data()[ m_columnIndex ];
92  std::string name = refNameAttr.data<std::string>();
93  if( name == namedRefNullLabel() ){
94  name = std::string("");
95  }
96  if(!name.empty()){
98  boost::shared_ptr<void> ptr = m_schema.dbSession().fetchTypedObjectByName( name, namedRefType );
99  *static_cast<boost::shared_ptr<void>*>(ptrAddress) = ptr;
100  *static_cast<bool*>(flagAddress) = true;
101  }
102  *static_cast<std::string*>(refNameAddress) = name;
103 }
std::string namedRefNullLabel()
void * address(const void *topLevelAddress) const
Definition: DataElement.cc:49
TypeWithDict templateArgumentAt(size_t index) const
DatabaseSession & dbSession()
virtual coral::AttributeList & data()=0
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
boost::shared_ptr< void > fetchTypedObjectByName(const std::string &name, const edm::TypeWithDict &asType)
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().

70  {
71  if(!m_relationalData){
72  throwException("The streamer has not been built.",
73  "NamedReferenceStreamerBase::bindDataForUpdate");
74  }
75 
76  void* refNameAddress = m_refNameDataElement->address( data );
77  coral::Attribute& refNameAttr = m_relationalData->data()[ m_columnIndex ];
78  std::string name = *static_cast<std::string*>(refNameAddress);
79  if( name.empty() ) name = namedRefNullLabel();
80  refNameAttr.data<std::string>()= name;
81 }
std::string namedRefNullLabel()
void * address(const void *topLevelAddress) const
Definition: DataElement.cc:49
virtual coral::AttributeList & data()=0
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
bool ora::NamedReferenceStreamerBase::buildDataElement ( DataElement dataElement,
IRelationalData relationalData 
)

Definition at line 37 of file NamedRefStreamer.cc.

References ora::DataElement::addChild(), ora::IRelationalData::addData(), mps_check::columns, edm::MemberWithDict::offset(), AlCaHLTBitMon_QueryRunRegistry::string, and ora::throwException().

38  {
39  m_dataElement = &dataElement;
40  //-ap m_objectType.UpdateMembers();
41  edm::MemberWithDict nameMember = m_objectType.dataMemberByName("m_name");
42  if( !nameMember ){
43  throwException("Data member \"m_name\" not found in class \""+m_objectType.name()+"\".",
44  "NamedReferenceStreamerBase::buildDataElement");
45  }
46  m_refNameDataElement = &dataElement.addChild( nameMember.offset(), 0 );
48  if( !ptrMember ){
49  throwException("Data member \"m_ptr\" not found in class \""+m_objectType.name()+"\".",
50  "NamedReferenceStreamerBase::buildDataElement");
51  }
52  m_ptrDataElement = &dataElement.addChild( ptrMember.offset(), 0 );
53  edm::MemberWithDict flagMember = m_objectType.dataMemberByName("m_isPersistent");
54  if( !flagMember ){
55  throwException("Data member \"m_isPersistent\" not found in class \""+m_objectType.name()+"\".",
56  "NamedReferenceStreamerBase::buildDataElement");
57  }
58  m_flagDataElement = &dataElement.addChild( flagMember.offset(), 0 );
59  // then book the column in the data attribute...
60  const std::vector<std::string>& columns = m_mapping.columnNames();
61  if( columns.size()==0 ){
62  throwException("No columns found in the mapping element",
63  "NamedReferenceStreamerBase::buildDataElement");
64  }
65  m_columnIndex = relationalData.addData( columns[0], typeid(std::string) );
66  m_relationalData = &relationalData;
67  return true;
68 }
size_t offset() const
MemberWithDict dataMemberByName(std::string const &) const
std::string name() const
const std::vector< std::string > & columnNames() const
DataElement & addChild(size_t declaringScopeOffset, size_toffset)
Definition: DataElement.cc:27
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
tuple columns
Definition: mps_check.py:210

Member Data Documentation

int ora::NamedReferenceStreamerBase::m_columnIndex
private

Definition at line 38 of file NamedRefStreamer.h.

DataElement* ora::NamedReferenceStreamerBase::m_dataElement
private

Definition at line 40 of file NamedRefStreamer.h.

DataElement* ora::NamedReferenceStreamerBase::m_flagDataElement
private

Definition at line 43 of file NamedRefStreamer.h.

MappingElement& ora::NamedReferenceStreamerBase::m_mapping
private

Definition at line 37 of file NamedRefStreamer.h.

edm::TypeWithDict ora::NamedReferenceStreamerBase::m_objectType
private

Definition at line 36 of file NamedRefStreamer.h.

DataElement* ora::NamedReferenceStreamerBase::m_ptrDataElement
private

Definition at line 42 of file NamedRefStreamer.h.

DataElement* ora::NamedReferenceStreamerBase::m_refNameDataElement
private

Definition at line 41 of file NamedRefStreamer.h.

IRelationalData* ora::NamedReferenceStreamerBase::m_relationalData
private

Definition at line 44 of file NamedRefStreamer.h.

ContainerSchema& ora::NamedReferenceStreamerBase::m_schema
private

Definition at line 39 of file NamedRefStreamer.h.