#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 | |
const std::vector< std::string > & | m_columns |
DataElement * | m_dataElement |
DataElement * | m_dataElemOId0 |
DataElement * | m_dataElemOId1 |
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.
: m_objectType( objectType ), m_columns( mapping.columnNames() ), m_schema( schema ), m_dataElement( 0 ), m_dataElemOId0( 0 ), m_dataElemOId1( 0 ), m_relationalData( 0 ){ }
ora::OraReferenceStreamerBase::~OraReferenceStreamerBase | ( | ) | [virtual] |
Definition at line 26 of file OraReferenceStreamer.cc.
{ }
void ora::OraReferenceStreamerBase::bindDataForRead | ( | void * | data | ) |
Definition at line 84 of file OraReferenceStreamer.cc.
References ora::IReferenceHandler::onLoad(), and ora::throwException().
{ if(!m_relationalData){ throwException("The streamer has not been built.", "OraReferenceStreamerBase::bindDataForRead"); } if( m_columns.size()<2 ){ throwException("Expected column names have not been found in the mapping.", "OraReferenceStreamerBase::bindDataForRead"); } void* oid0Address = m_dataElemOId0->address( data ); coral::Attribute& oid0Attr = m_relationalData->data()[ m_columns[0] ]; *static_cast<int*>(oid0Address) = oid0Attr.data<int>(); void* oid1Address = m_dataElemOId1->address( data ); coral::Attribute& oid1Attr = m_relationalData->data()[ m_columns[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 67 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_columns[0] ]; oid0Attr.data<int>()= *static_cast<int*>(oid0Address); void* oid1Address = m_dataElemOId1->address( data ); coral::Attribute& oid1Attr = m_relationalData->data()[ m_columns[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 30 of file OraReferenceStreamer.cc.
References ora::DataElement::addChild(), ora::IRelationalData::addData(), ora::ClassUtils::findBaseType(), 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... if( m_columns.size()<2 ){ throwException("Expected column names have not been found in the mapping.", "OraReferenceStreamerBase::buildDataElement"); } const std::type_info& attrType = typeid(int); for( std::vector<std::string>::const_iterator iCol = m_columns.begin(); iCol != m_columns.end(); ++iCol ){ relationalData.addData( *iCol, attrType ); } m_relationalData = &relationalData; return true; }
const std::vector<std::string>& ora::OraReferenceStreamerBase::m_columns [private] |
Definition at line 30 of file OraReferenceStreamer.h.
Definition at line 32 of file OraReferenceStreamer.h.
Definition at line 33 of file OraReferenceStreamer.h.
Definition at line 34 of file OraReferenceStreamer.h.
Reflex::Type ora::OraReferenceStreamerBase::m_objectType [private] |
Definition at line 29 of file OraReferenceStreamer.h.
Definition at line 35 of file OraReferenceStreamer.h.
Definition at line 31 of file OraReferenceStreamer.h.