11 #include "CoralBase/Attribute.h"
17 m_objectType( objectType ),
23 m_relationalData( 0 ){
34 m_dataElement = &dataElement;
38 size_t baseOffsetFunc = 0;
39 if( m_objectType != refType ){
42 throwException(
"Type \""+m_objectType.cppName()+
"\" is not an Ora Reference.",
43 "OraReferenceStreamerBase::buildDataElement");
48 if( !contIdMember || !itemIdMember ){
50 "OraReferenceStreamerBase::buildDataElement");
52 m_dataElemOId0 = &dataElement.
addChild( contIdMember.
offset(), baseOffsetFunc );
53 m_dataElemOId1 = &dataElement.
addChild( itemIdMember.
offset(), baseOffsetFunc);
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");
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 );
64 m_relationalData = &relationalData;
70 if(!m_relationalData){
72 "OraReferenceStreamerBase::bindDataForUpdate");
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) ;
82 void* refPtr = m_dataElement->address( data );
83 if(refHandler) refHandler->
onSave( *static_cast<Reference*>( refPtr ) );
87 if(!m_relationalData){
89 "OraReferenceStreamerBase::bindDataForRead");
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>();
99 void* refPtr = m_dataElement->address( data );
100 if(refHandler) refHandler->
onLoad( *static_cast<Reference*>( refPtr ) );
115 return buildDataElement( dataElement, relationalData );
123 bindDataForUpdate( data );
138 return buildDataElement( dataElement, relationalData );
146 bindDataForUpdate( data );
160 return buildDataElement( dataElement, relationalData );
170 bindDataForRead( data );
180 m_objectType( objectType ),
181 m_mapping( mapping ),
bool build(DataElement &dataElement, IRelationalData &relationalData)
void write(int oid, const void *data)
Writes a data element.
OraReferenceWriter(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &schema)
virtual ~OraReferenceWriter()
OraReferenceUpdater(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &schema)
virtual bool onLoad(ora::Reference &ref)=0
virtual int addData(const std::string &columnName, const std::type_info &columnType)=0
IRelationalWriter * newWriter()
OraReferenceStreamer(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &schema)
bool build(DataElement &dataElement, IRelationalData &relationalData, RelationalBuffer &operationBuffer)
MemberWithDict dataMemberByName(std::string const &) const
virtual ~OraReferenceReader()
void setRecordId(const std::vector< int > &identity)
OraReferenceStreamerBase(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &schema)
virtual bool onSave(ora::Reference &ref)=0
bool buildDataElement(DataElement &dataElement, IRelationalData &relationalData)
bool build(DataElement &dataElement, IRelationalData &relationalData, RelationalBuffer &operationBuffer)
void read(void *data)
Reads a data element.
void setRecordId(const std::vector< int > &identity)
void update(int oid, const void *data)
Updates a data element.
DataElement & addChild(size_t declaringScopeOffset, size_toffset)
OraReferenceReader(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &schema)
void setRecordId(const std::vector< int > &identity)
bool findBaseType(edm::TypeWithDict &type, edm::TypeWithDict &baseType, size_t &func)
virtual ~OraReferenceStreamerBase()
void bindDataForRead(void *data)
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
char data[epos_bytes_allocation]
void bindDataForUpdate(const void *data)
IRelationalUpdater * newUpdater()
virtual ~OraReferenceUpdater()
IRelationalReader * newReader()