#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 | |
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 170 of file UniqueRefStreamer.cc.
: m_objectType( objectType ), m_mappingElement( mapping ), m_schema( contSchema ), m_dataElement( 0 ), m_relationalData( 0 ), m_operationBuffer( 0 ){ }
ora::UniqueRefWriter::~UniqueRefWriter | ( | ) | [virtual] |
Definition at line 186 of file UniqueRefStreamer.cc.
{ }
bool ora::UniqueRefWriter::build | ( | DataElement & | dataElement, |
IRelationalData & | relationalData, | ||
RelationalBuffer & | operationBuffer | ||
) | [virtual] |
Implements ora::IRelationalWriter.
Definition at line 189 of file UniqueRefStreamer.cc.
References ora::IRelationalData::addData().
{ m_dataElement = &dataElement; const std::vector<std::string>& columns = m_mappingElement.columnNames(); // booking for ref metadata relationalData.addData( columns[0],typeid(std::string) ); // booking for ref id 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 208 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); // getting a new valid ref id refId = m_schema.containerSequences().getNextId( MappingRules::sequenceNameForDependentClass( m_schema.containerName(),className )); // building the dependent buffer MappingElement& depMapping = m_schema.mappingForDependentClass( refType, true ); 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_mappingElement.columnNames()[0]].data<std::string>()=className; parentData[m_mappingElement.columnNames()[1]].data<int>()=refId; }
DataElement* ora::UniqueRefWriter::m_dataElement [private] |
Definition at line 43 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 45 of file UniqueRefStreamer.h.
Definition at line 44 of file UniqueRefStreamer.h.
ContainerSchema& ora::UniqueRefWriter::m_schema [private] |
Definition at line 42 of file UniqueRefStreamer.h.