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::OraReferenceStreamerBase Class Reference

#include <OraReferenceStreamer.h>

Inheritance diagram for ora::OraReferenceStreamerBase:
ora::OraReferenceReader ora::OraReferenceUpdater ora::OraReferenceWriter

Public Member Functions

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

Private Attributes

int m_columnIndexes [2]
 
DataElementm_dataElement
 
DataElementm_dataElemOId0
 
DataElementm_dataElemOId1
 
MappingElementm_mapping
 
edm::TypeWithDict m_objectType
 
IRelationalDatam_relationalData
 
ContainerSchemam_schema
 

Detailed Description

Definition at line 13 of file OraReferenceStreamer.h.

Constructor & Destructor Documentation

ora::OraReferenceStreamerBase::OraReferenceStreamerBase ( const edm::TypeWithDict objectType,
MappingElement mapping,
ContainerSchema schema 
)
explicit

Definition at line 14 of file OraReferenceStreamer.cc.

References m_columnIndexes.

16  :
17  m_objectType( objectType ),
18  m_mapping( mapping ),
19  m_schema( schema ),
20  m_dataElement( 0 ),
21  m_dataElemOId0( 0 ),
22  m_dataElemOId1( 0 ),
23  m_relationalData( 0 ){
24  m_columnIndexes[0] = -1;
25  m_columnIndexes[1] = -1;
26 }
ora::OraReferenceStreamerBase::~OraReferenceStreamerBase ( )
virtual

Definition at line 28 of file OraReferenceStreamer.cc.

28  {
29 }

Member Function Documentation

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

Definition at line 86 of file OraReferenceStreamer.cc.

References ora::IReferenceHandler::onLoad(), and ora::throwException().

86  {
87  if(!m_relationalData){
88  throwException("The streamer has not been built.",
89  "OraReferenceStreamerBase::bindDataForRead");
90  }
91 
92  void* oid0Address = m_dataElemOId0->address( data );
93  coral::Attribute& oid0Attr = m_relationalData->data()[ m_columnIndexes[0] ];
94  *static_cast<int*>(oid0Address) = oid0Attr.data<int>();
95  void* oid1Address = m_dataElemOId1->address( data );
96  coral::Attribute& oid1Attr = m_relationalData->data()[ m_columnIndexes[1] ];
97  *static_cast<int*>( oid1Address ) = oid1Attr.data<int>();
98  IReferenceHandler* refHandler = m_schema.referenceHandler();
99  void* refPtr = m_dataElement->address( data );
100  if(refHandler) refHandler->onLoad( *static_cast<Reference*>( refPtr ) );
101 }
void * address(const void *topLevelAddress) const
Definition: DataElement.cc:49
IReferenceHandler * referenceHandler()
virtual coral::AttributeList & data()=0
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void ora::OraReferenceStreamerBase::bindDataForUpdate ( const void *  data)

Definition at line 69 of file OraReferenceStreamer.cc.

References ora::IReferenceHandler::onSave(), and ora::throwException().

69  {
70  if(!m_relationalData){
71  throwException("The streamer has not been built.",
72  "OraReferenceStreamerBase::bindDataForUpdate");
73  }
74 
75  void* oid0Address = m_dataElemOId0->address( data );
76  coral::Attribute& oid0Attr = m_relationalData->data()[ m_columnIndexes[0] ];
77  oid0Attr.data<int>()= *static_cast<int*>(oid0Address);
78  void* oid1Address = m_dataElemOId1->address( data );
79  coral::Attribute& oid1Attr = m_relationalData->data()[ m_columnIndexes[1] ];
80  oid1Attr.data<int>()= *static_cast<int*>(oid1Address) ;
81  IReferenceHandler* refHandler = m_schema.referenceHandler();
82  void* refPtr = m_dataElement->address( data );
83  if(refHandler) refHandler->onSave( *static_cast<Reference*>( refPtr ) );
84 }
void * address(const void *topLevelAddress) const
Definition: DataElement.cc:49
IReferenceHandler * referenceHandler()
virtual coral::AttributeList & data()=0
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
bool ora::OraReferenceStreamerBase::buildDataElement ( DataElement dataElement,
IRelationalData relationalData 
)

Definition at line 32 of file OraReferenceStreamer.cc.

References ora::DataElement::addChild(), ora::IRelationalData::addData(), edm::TypeWithDict::dataMemberByName(), ora::ClassUtils::findBaseType(), i, edm::MemberWithDict::offset(), and ora::throwException().

33  {
34  m_dataElement = &dataElement;
35  // first resolve the oid0 and oid2 data elements...
36  edm::TypeWithDict refType( typeid(Reference) );
37  //edm::TypeWithDict oidType = edm::TypeWithDict::ByTypeInfo( typeid(OId) );
38  size_t baseOffsetFunc = 0;
39  if( m_objectType != refType ){
40  bool foundRef = ClassUtils::findBaseType( m_objectType, refType, baseOffsetFunc );
41  if(!foundRef){
42  throwException("Type \""+m_objectType.cppName()+"\" is not an Ora Reference.",
43  "OraReferenceStreamerBase::buildDataElement");
44  }
45  }
46  edm::MemberWithDict contIdMember = refType.dataMemberByName("m_containerId");
47  edm::MemberWithDict itemIdMember = refType.dataMemberByName("m_itemId");
48  if( !contIdMember || !itemIdMember ){
49  throwException("Data members for class OId not found.",
50  "OraReferenceStreamerBase::buildDataElement");
51  }
52  m_dataElemOId0 = &dataElement.addChild( contIdMember.offset(), baseOffsetFunc );
53  m_dataElemOId1 = &dataElement.addChild( itemIdMember.offset(), baseOffsetFunc);
54  // then book the columns in the data attribute...
55  const std::vector<std::string>& columns = m_mapping.columnNames();
56  if( columns.size() < 2 ){
57  throwException("Expected column names have not been found in the mapping.",
58  "OraReferenceStreamerBase::buildDataElement");
59  }
60  const std::type_info& attrType = typeid(int);
61  for( size_t i=0; i<2; i++ ){
62  m_columnIndexes[i] = relationalData.addData( columns[i],attrType );
63  }
64  m_relationalData = &relationalData;
65  return true;
66 }
int i
Definition: DBlmapReader.cc:9
size_t offset() const
std::string cppName() const
const std::vector< std::string > & columnNames() const
DataElement & addChild(size_t declaringScopeOffset, size_toffset)
Definition: DataElement.cc:27
bool findBaseType(edm::TypeWithDict &type, edm::TypeWithDict &baseType, size_t &func)
Definition: ClassUtils.cc:136
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10

Member Data Documentation

int ora::OraReferenceStreamerBase::m_columnIndexes[2]
private

Definition at line 31 of file OraReferenceStreamer.h.

Referenced by OraReferenceStreamerBase().

DataElement* ora::OraReferenceStreamerBase::m_dataElement
private

Definition at line 33 of file OraReferenceStreamer.h.

DataElement* ora::OraReferenceStreamerBase::m_dataElemOId0
private

Definition at line 34 of file OraReferenceStreamer.h.

DataElement* ora::OraReferenceStreamerBase::m_dataElemOId1
private

Definition at line 35 of file OraReferenceStreamer.h.

MappingElement& ora::OraReferenceStreamerBase::m_mapping
private

Definition at line 30 of file OraReferenceStreamer.h.

edm::TypeWithDict ora::OraReferenceStreamerBase::m_objectType
private

Definition at line 29 of file OraReferenceStreamer.h.

IRelationalData* ora::OraReferenceStreamerBase::m_relationalData
private

Definition at line 36 of file OraReferenceStreamer.h.

ContainerSchema& ora::OraReferenceStreamerBase::m_schema
private

Definition at line 32 of file OraReferenceStreamer.h.