#include <UniqueRefStreamer.h>
Public Member Functions | |
bool | build (DataElement &dataElement, IRelationalData &relationalData, RelationalBuffer &operationBuffer) |
void | setRecordId (const std::vector< int > &identity) |
UniqueRefWriter (const Reflex::Type &objectType, MappingElement &mapping, ContainerSchema &contSchema) | |
void | write (int oid, const void *data) |
Writes a data element. | |
virtual | ~UniqueRefWriter () |
Private Attributes | |
int | m_columnIndexes [2] |
DataElement * | m_dataElement |
MappingElement & | m_mappingElement |
Reflex::Type | m_objectType |
RelationalBuffer * | m_operationBuffer |
IRelationalData * | m_relationalData |
ContainerSchema & | m_schema |
Definition at line 23 of file UniqueRefStreamer.h.
ora::UniqueRefWriter::UniqueRefWriter | ( | const Reflex::Type & | objectType, |
MappingElement & | mapping, | ||
ContainerSchema & | contSchema | ||
) |
Definition at line 171 of file UniqueRefStreamer.cc.
References m_columnIndexes.
: m_objectType( objectType ), m_mappingElement( mapping ), m_schema( contSchema ), m_dataElement( 0 ), m_relationalData( 0 ), m_operationBuffer( 0 ){ m_columnIndexes[0]=-1; m_columnIndexes[1]=-1; }
ora::UniqueRefWriter::~UniqueRefWriter | ( | ) | [virtual] |
Definition at line 189 of file UniqueRefStreamer.cc.
{ }
bool ora::UniqueRefWriter::build | ( | DataElement & | dataElement, |
IRelationalData & | relationalData, | ||
RelationalBuffer & | operationBuffer | ||
) | [virtual] |
Implements ora::IRelationalWriter.
Definition at line 192 of file UniqueRefStreamer.cc.
References ora::IRelationalData::addData(), and ora::throwException().
{ m_dataElement = &dataElement; const std::vector<std::string>& columns = m_mappingElement.columnNames(); if( columns.size() < 2 ){ throwException("Expected column names have not been found in the mapping.", "UniqueRefWriter::build"); } // booking for ref metadata m_columnIndexes[0] = relationalData.addData( columns[0],typeid(std::string) ); // booking for ref id m_columnIndexes[1] = relationalData.addData( columns[1],typeid(int) ); m_relationalData = &relationalData; m_operationBuffer = &buffer; return true; }
void ora::UniqueRefWriter::setRecordId | ( | const std::vector< int > & | identity | ) | [virtual] |
void ora::UniqueRefWriter::write | ( | int | oid, |
const void * | data | ||
) | [virtual] |
Writes a data element.
Implements ora::IRelationalWriter.
Definition at line 215 of file UniqueRefStreamer.cc.
References ora::DependentClassWriter::build(), className(), ora::ClassUtils::lookupDictionary(), ora::MappingRules::sequenceNameForDependentClass(), ora::throwException(), ora::uniqueRefNullLabel(), and ora::DependentClassWriter::write().
{ if(!m_dataElement){ throwException("The streamer has not been built.", "UniqueRefWriter::write"); } void* refAddress = m_dataElement->address( data ); Reflex::Object refObj( m_objectType, const_cast<void*>(refAddress)); bool isNull; refObj.Invoke("operator!",isNull); int refId = 0; std::string className = uniqueRefNullLabel(); if(!isNull){ // resolving the ref type std::type_info* refTypeInfo = 0; refObj.Invoke("typeInfo",refTypeInfo); Reflex::Type refType = ClassUtils::lookupDictionary(*refTypeInfo); className = refType.Name(Reflex::SCOPED); // building the dependent buffer MappingElement& depMapping = m_schema.mappingForDependentClass( refType, true ); // getting a new valid ref id refId = m_schema.containerSequences().getNextId( MappingRules::sequenceNameForDependentClass( m_schema.containerName(),className )); DependentClassWriter writer; writer.build( refType, depMapping, m_schema, m_operationBuffer->addVolatileBuffer() ); void* refData; refObj.Invoke("operator*",refData); writer.write( oid, refId, refData ); } // writing in the parent table coral::AttributeList& parentData = m_relationalData->data(); parentData[m_columnIndexes[0]].data<std::string>()=className; parentData[m_columnIndexes[1]].data<int>()=refId; }
int ora::UniqueRefWriter::m_columnIndexes[2] [private] |
Definition at line 42 of file UniqueRefStreamer.h.
Referenced by UniqueRefWriter().
DataElement* ora::UniqueRefWriter::m_dataElement [private] |
Definition at line 44 of file UniqueRefStreamer.h.
Definition at line 41 of file UniqueRefStreamer.h.
Reflex::Type ora::UniqueRefWriter::m_objectType [private] |
Definition at line 40 of file UniqueRefStreamer.h.
Definition at line 46 of file UniqueRefStreamer.h.
Definition at line 45 of file UniqueRefStreamer.h.
ContainerSchema& ora::UniqueRefWriter::m_schema [private] |
Definition at line 43 of file UniqueRefStreamer.h.