#include <OraReferenceStreamer.h>
Public Member Functions | |
void | bindDataForRead (void *data) |
void | bindDataForUpdate (const void *data) |
bool | buildDataElement (DataElement &dataElement, IRelationalData &relationalData) |
OraReferenceStreamerBase (const Reflex::Type &objectType, MappingElement &mapping, ContainerSchema &schema) | |
virtual | ~OraReferenceStreamerBase () |
Private Attributes | |
int | m_columnIndexes [2] |
DataElement * | m_dataElement |
DataElement * | m_dataElemOId0 |
DataElement * | m_dataElemOId1 |
MappingElement & | m_mapping |
Reflex::Type | m_objectType |
IRelationalData * | m_relationalData |
ContainerSchema & | m_schema |
Definition at line 13 of file OraReferenceStreamer.h.
ora::OraReferenceStreamerBase::OraReferenceStreamerBase | ( | const Reflex::Type & | objectType, |
MappingElement & | mapping, | ||
ContainerSchema & | schema | ||
) | [explicit] |
Definition at line 14 of file OraReferenceStreamer.cc.
References m_columnIndexes.
: m_objectType( objectType ), m_mapping( mapping ), m_schema( schema ), m_dataElement( 0 ), m_dataElemOId0( 0 ), m_dataElemOId1( 0 ), m_relationalData( 0 ){ m_columnIndexes[0] = -1; m_columnIndexes[1] = -1; }
ora::OraReferenceStreamerBase::~OraReferenceStreamerBase | ( | ) | [virtual] |
Definition at line 28 of file OraReferenceStreamer.cc.
{ }
void ora::OraReferenceStreamerBase::bindDataForRead | ( | void * | data | ) |
Definition at line 86 of file OraReferenceStreamer.cc.
References ora::IReferenceHandler::onLoad(), and ora::throwException().
{ if(!m_relationalData){ throwException("The streamer has not been built.", "OraReferenceStreamerBase::bindDataForRead"); } void* oid0Address = m_dataElemOId0->address( data ); coral::Attribute& oid0Attr = m_relationalData->data()[ m_columnIndexes[0] ]; *static_cast<int*>(oid0Address) = oid0Attr.data<int>(); void* oid1Address = m_dataElemOId1->address( data ); coral::Attribute& oid1Attr = m_relationalData->data()[ m_columnIndexes[1] ]; *static_cast<int*>( oid1Address ) = oid1Attr.data<int>(); IReferenceHandler* refHandler = m_schema.referenceHandler(); void* refPtr = m_dataElement->address( data ); if(refHandler) refHandler->onLoad( *static_cast<Reference*>( refPtr ) ); }
void ora::OraReferenceStreamerBase::bindDataForUpdate | ( | const void * | data | ) |
Definition at line 69 of file OraReferenceStreamer.cc.
References ora::IReferenceHandler::onSave(), and ora::throwException().
{ if(!m_relationalData){ throwException("The streamer has not been built.", "OraReferenceStreamerBase::bindDataForUpdate"); } void* oid0Address = m_dataElemOId0->address( data ); coral::Attribute& oid0Attr = m_relationalData->data()[ m_columnIndexes[0] ]; oid0Attr.data<int>()= *static_cast<int*>(oid0Address); void* oid1Address = m_dataElemOId1->address( data ); coral::Attribute& oid1Attr = m_relationalData->data()[ m_columnIndexes[1] ]; oid1Attr.data<int>()= *static_cast<int*>(oid1Address) ; IReferenceHandler* refHandler = m_schema.referenceHandler(); void* refPtr = m_dataElement->address( data ); if(refHandler) refHandler->onSave( *static_cast<Reference*>( refPtr ) ); }
bool ora::OraReferenceStreamerBase::buildDataElement | ( | DataElement & | dataElement, |
IRelationalData & | relationalData | ||
) |
Definition at line 32 of file OraReferenceStreamer.cc.
References ora::DataElement::addChild(), ora::IRelationalData::addData(), ora::ClassUtils::findBaseType(), i, and ora::throwException().
{ m_dataElement = &dataElement; // first resolve the oid0 and oid2 data elements... Reflex::Type refType = Reflex::Type::ByTypeInfo( typeid(Reference) ); //Reflex::Type oidType = Reflex::Type::ByTypeInfo( typeid(OId) ); Reflex::OffsetFunction baseOffsetFunc = 0; if( m_objectType != refType ){ bool foundRef = ClassUtils::findBaseType( m_objectType, refType, baseOffsetFunc ); if(!foundRef){ throwException("Type \""+m_objectType.Name(Reflex::SCOPED)+"\" is not an Ora Reference.", "OraReferenceStreamerBase::buildDataElement"); } } Reflex::Member contIdMember = refType.DataMemberByName("m_containerId"); Reflex::Member itemIdMember = refType.DataMemberByName("m_itemId"); if( !contIdMember || !itemIdMember ){ throwException("Data members for class OId not found.", "OraReferenceStreamerBase::buildDataElement"); } m_dataElemOId0 = &dataElement.addChild( contIdMember.Offset(), baseOffsetFunc ); m_dataElemOId1 = &dataElement.addChild( itemIdMember.Offset(), baseOffsetFunc); // then book the columns in the data attribute... const std::vector<std::string>& columns = m_mapping.columnNames(); if( columns.size() < 2 ){ throwException("Expected column names have not been found in the mapping.", "OraReferenceStreamerBase::buildDataElement"); } const std::type_info& attrType = typeid(int); for( size_t i=0; i<2; i++ ){ m_columnIndexes[i] = relationalData.addData( columns[i],attrType ); } m_relationalData = &relationalData; return true; }
int ora::OraReferenceStreamerBase::m_columnIndexes[2] [private] |
Definition at line 31 of file OraReferenceStreamer.h.
Referenced by OraReferenceStreamerBase().
Definition at line 33 of file OraReferenceStreamer.h.
Definition at line 34 of file OraReferenceStreamer.h.
Definition at line 35 of file OraReferenceStreamer.h.
Definition at line 30 of file OraReferenceStreamer.h.
Reflex::Type ora::OraReferenceStreamerBase::m_objectType [private] |
Definition at line 29 of file OraReferenceStreamer.h.
Definition at line 36 of file OraReferenceStreamer.h.
Definition at line 32 of file OraReferenceStreamer.h.