#include <ObjectStreamer.h>
Public Member Functions | |
void | buildBaseDataMembers (DataElement &dataElement, IRelationalData &relationalData, const Reflex::Type &objType, RelationalBuffer *operationBuffer) |
bool | buildDataMembers (DataElement &dataElement, IRelationalData &relationalData, RelationalBuffer *operationBuffer) |
ObjectStreamerBase (const Reflex::Type &objectType, MappingElement &mapping, ContainerSchema &contSchema) | |
virtual void | processDataMember (DataElement &dataElement, IRelationalData &relationalData, Reflex::Type &dataMemberType, MappingElement &dataMemberMapping, RelationalBuffer *operationBuffer)=0 |
virtual | ~ObjectStreamerBase () |
Protected Attributes | |
RelationalStreamerFactory | m_streamerFactory |
Private Attributes | |
MappingElement & | m_mapping |
Reflex::Type | m_objectType |
Definition at line 15 of file ObjectStreamer.h.
ora::ObjectStreamerBase::ObjectStreamerBase | ( | const Reflex::Type & | objectType, |
MappingElement & | mapping, | ||
ContainerSchema & | contSchema | ||
) |
Definition at line 24 of file ObjectStreamer.cc.
: m_streamerFactory( contSchema ), m_objectType( objectType ), m_mapping( mapping ){ }
ora::ObjectStreamerBase::~ObjectStreamerBase | ( | ) | [virtual] |
Definition at line 32 of file ObjectStreamer.cc.
{ }
void ora::ObjectStreamerBase::buildBaseDataMembers | ( | DataElement & | dataElement, |
IRelationalData & | relationalData, | ||
const Reflex::Type & | objType, | ||
RelationalBuffer * | operationBuffer | ||
) |
Definition at line 35 of file ObjectStreamer.cc.
References ora::DataElement::addChild(), CustomConfigs::Base(), ora::ClassUtils::checkMappedType(), i, ora::isLoosePersistencyDataMember(), j, ora::ClassUtils::resolvedType(), ora::MappingRules::scopedVariableName(), ora::throwException(), and ora::MappingElement::variableType().
{ for ( unsigned int i=0;i<objType.BaseSize();i++){ Reflex::Base base = objType.BaseAt(i); Reflex::Type baseType = ClassUtils::resolvedType( base.ToType() ); buildBaseDataMembers( dataElement, relationalData, baseType, operationBuffer ); for ( unsigned int j=0;j<baseType.DataMemberSize();j++){ Reflex::Member dataMember = baseType.DataMemberAt(j); DataElement& dataMemberElement = dataElement.addChild( dataMember.Offset(), base.OffsetFP() ); // Ignore the transients and the statics (how to deal with non-const statics?) if ( dataMember.IsTransient() || dataMember.IsStatic() ) continue; // Get the member type and resolve possible typedef chains Reflex::Type dataMemberType = ClassUtils::resolvedType( dataMember.TypeOf() ); if ( ! dataMemberType ) { throwException( "Missing dictionary information for data member \"" + dataMember.Name() + "\" of class \"" + baseType.Name(Reflex::SCOPED|Reflex::FINAL) + "\"", "ObjectStreamerBase::buildBaseDataMembers" ); } // check if the member is from a class in the inheritance tree Reflex::Type declaringType = ClassUtils::resolvedType( dataMember.DeclaringType()); std::string scope = declaringType.Name(Reflex::SCOPED|Reflex::FINAL); // Get the data member name std::string dataMemberName = MappingRules::scopedVariableName( dataMember.Name(), scope ); // Retrieve the relevant mapping element MappingElement::iterator iDataMemberMapping = m_mapping.find( dataMemberName ); if ( iDataMemberMapping != m_mapping.end() ) { MappingElement& dataMemberMapping = iDataMemberMapping->second; if( !ClassUtils::checkMappedType(dataMemberType,dataMemberMapping.variableType()) ){ throwException( "Data member \""+dataMemberName +"\" type \"" + dataMemberType.Name(Reflex::SCOPED|Reflex::FINAL) + "\" does not match with the expected type in the mapping \""+dataMemberMapping.variableType()+"\".", "ObjectStreamerBase::buildBaseDataMembers" ); } processDataMember( dataMemberElement, relationalData, dataMemberType, dataMemberMapping, operationBuffer ); } else { if( !isLoosePersistencyDataMember( dataMember ) ){ throwException( "Data member \"" + dataMemberName + "\" not found in the mapping element of variable \""+m_mapping.variableName()+"\".", "ObjectStreamerBase::buildBaseDataMembers" ); } } } } }
bool ora::ObjectStreamerBase::buildDataMembers | ( | DataElement & | dataElement, |
IRelationalData & | relationalData, | ||
RelationalBuffer * | operationBuffer | ||
) |
Definition at line 85 of file ObjectStreamer.cc.
References ora::DataElement::addChild(), ora::ClassUtils::checkMappedType(), i, ora::isLoosePersistencyDataMember(), ora::ClassUtils::resolvedType(), ora::MappingRules::scopedVariableName(), ora::throwException(), and ora::MappingElement::variableType().
{ buildBaseDataMembers( dataElement, relationalData, m_objectType, operationBuffer ); // Loop over the data members of the class. for ( unsigned int i=0;i<m_objectType.DataMemberSize();i++){ Reflex::Member dataMember = m_objectType.DataMemberAt(i); DataElement& dataMemberElement = dataElement.addChild( dataMember.Offset(), 0 ); Reflex::Type declaringType = ClassUtils::resolvedType( dataMember.DeclaringType()); if( declaringType != m_objectType ){ continue; } // Ignore the transients and the statics (how to deal with non-const statics?) if ( dataMember.IsTransient() || dataMember.IsStatic() ) continue; // Get the member type and resolve possible typedef chains Reflex::Type dataMemberType = ClassUtils::resolvedType( dataMember.TypeOf() ); if ( ! dataMemberType ) { throwException( "Missing dictionary information for data member \"" + dataMember.Name() + "\" of class \"" + m_objectType.Name(Reflex::SCOPED|Reflex::FINAL) + "\"", "ObjectStreamerBase::buildDataMembers" ); } // check if the member is from a class in the inheritance tree std::string scope(""); // Get the data member name std::string dataMemberName = MappingRules::scopedVariableName( dataMember.Name(), scope ); // Retrieve the relevant mapping element MappingElement::iterator idataMemberMapping = m_mapping.find( dataMemberName ); if ( idataMemberMapping != m_mapping.end() ) { MappingElement& dataMemberMapping = idataMemberMapping->second; if( !ClassUtils::checkMappedType(dataMemberType,dataMemberMapping.variableType())){ throwException( "Data member \""+dataMemberName +"\" type \"" + dataMemberType.Name(Reflex::SCOPED|Reflex::FINAL) + "\" does not match with the expected type in the mapping \""+dataMemberMapping.variableType()+"\".", "ObjectStreamerBase::buildDataMembers" ); } processDataMember( dataMemberElement, relationalData, dataMemberType, dataMemberMapping, operationBuffer ); } else { if(!isLoosePersistencyDataMember( dataMember ) ){ throwException( "Data member \"" + dataMemberName + "\" not found in the mapping element of variable \""+m_mapping.variableName()+"\".", "ObjectStreamerBase::buildDataMembers" ); } } } return true; }
virtual void ora::ObjectStreamerBase::processDataMember | ( | DataElement & | dataElement, |
IRelationalData & | relationalData, | ||
Reflex::Type & | dataMemberType, | ||
MappingElement & | dataMemberMapping, | ||
RelationalBuffer * | operationBuffer | ||
) | [pure virtual] |
Implemented in ora::ObjectWriter, ora::ObjectUpdater, and ora::ObjectReader.
MappingElement& ora::ObjectStreamerBase::m_mapping [private] |
Definition at line 26 of file ObjectStreamer.h.
Reflex::Type ora::ObjectStreamerBase::m_objectType [private] |
Definition at line 25 of file ObjectStreamer.h.
Definition at line 23 of file ObjectStreamer.h.