11 #include "CoralBase/Attribute.h"
15 static const std::string nullLabel(
"ora::NamedRef::Null");
22 m_objectType( objectType ),
27 m_refNameDataElement( 0 ),
28 m_ptrDataElement( 0 ),
29 m_flagDataElement( 0 ),
30 m_relationalData( 0 ){
39 m_dataElement = &dataElement;
43 throwException(
"Data member \"m_name\" not found in class \""+m_objectType.name()+
"\".",
44 "NamedReferenceStreamerBase::buildDataElement");
46 m_refNameDataElement = &dataElement.
addChild( nameMember.
offset(), 0 );
49 throwException(
"Data member \"m_ptr\" not found in class \""+m_objectType.name()+
"\".",
50 "NamedReferenceStreamerBase::buildDataElement");
55 throwException(
"Data member \"m_isPersistent\" not found in class \""+m_objectType.name()+
"\".",
56 "NamedReferenceStreamerBase::buildDataElement");
58 m_flagDataElement = &dataElement.
addChild( flagMember.
offset(), 0 );
60 const std::vector<std::string>& columns = m_mapping.columnNames();
61 if( columns.size()==0 ){
63 "NamedReferenceStreamerBase::buildDataElement");
66 m_relationalData = &relationalData;
71 if(!m_relationalData){
73 "NamedReferenceStreamerBase::bindDataForUpdate");
76 void* refNameAddress = m_refNameDataElement->address( data );
77 coral::Attribute& refNameAttr = m_relationalData->data()[ m_columnIndex ];
84 if(!m_relationalData){
86 "NamedReferenceStreamerBase::bindDataForRead");
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 ];
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;
117 return buildDataElement( dataElement, relationalData );
126 bindDataForUpdate( data );
141 return buildDataElement( dataElement, relationalData );
150 bindDataForUpdate( data );
164 return buildDataElement( dataElement, relationalData );
175 bindDataForRead( data );
185 m_objectType( objectType ),
186 m_mapping( mapping ),
187 m_schema( contSchema ){
void update(int oid, const void *data)
Updates a data element.
std::string namedRefNullLabel()
void read(void *destination)
Reads a data element.
NamedRefStreamer(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &contSchema)
void bindDataForUpdate(const void *data)
void setRecordId(const std::vector< int > &identity)
virtual int addData(const std::string &columnName, const std::type_info &columnType)=0
bool build(DataElement &dataElement, IRelationalData &relationalData, RelationalBuffer &operationBuffer)
IRelationalUpdater * newUpdater()
void bindDataForRead(void *data)
TypeWithDict templateArgumentAt(size_t index) const
bool build(DataElement &offset, IRelationalData &relationalData)
bool build(DataElement &dataElement, IRelationalData &relationalData, RelationalBuffer &operationBuffer)
virtual ~NamedRefWriter()
virtual ~NamedRefReader()
NamedRefUpdater(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &contSchema)
NamedRefWriter(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &contSchema)
DataElement & addChild(size_t declaringScopeOffset, size_toffset)
IRelationalWriter * newWriter()
void write(int oid, const void *data)
Writes a data element.
IRelationalReader * newReader()
bool buildDataElement(DataElement &dataElement, IRelationalData &relationalData)
NamedRefReader(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &contSchema)
virtual ~NamedRefUpdater()
void setRecordId(const std::vector< int > &identity)
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
void setRecordId(const std::vector< int > &identity)
virtual ~NamedReferenceStreamerBase()
NamedReferenceStreamerBase(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &schema)