8 #include "Reflex/Base.h"
9 #include "Reflex/Member.h"
15 Reflex::PropertyList memberProps = dataMember.Properties();
27 m_streamerFactory( contSchema ),
28 m_objectType( objectType ),
40 for (
unsigned int i=0;
i<objType.BaseSize();
i++){
43 buildBaseDataMembers( dataElement, relationalData, baseType, operationBuffer );
44 for (
unsigned int j=0;
j<baseType.DataMemberSize();
j++){
45 Reflex::Member dataMember = baseType.DataMemberAt(
j);
46 DataElement& dataMemberElement = dataElement.
addChild( dataMember.Offset(), base.OffsetFP() );
48 if ( dataMember.IsTransient() || dataMember.IsStatic() )
continue;
51 if ( ! dataMemberType ) {
52 throwException(
"Missing dictionary information for data member \"" +
53 dataMember.Name() +
"\" of class \"" +
54 baseType.Name(Reflex::SCOPED|Reflex::FINAL) +
"\"",
55 "ObjectStreamerBase::buildBaseDataMembers" );
60 std::string scope = declaringType.Name(Reflex::SCOPED|Reflex::FINAL);
65 if ( iDataMemberMapping != m_mapping.end() ) {
68 throwException(
"Data member \""+dataMemberName +
"\" type \"" + dataMemberType.Name(Reflex::SCOPED|Reflex::FINAL) +
69 "\" does not match with the expected type in the mapping \""+dataMemberMapping.
variableType()+
"\".",
70 "ObjectStreamerBase::buildBaseDataMembers" );
72 processDataMember( dataMemberElement, relationalData, dataMemberType, dataMemberMapping, operationBuffer );
76 "\" not found in the mapping element of variable \""+m_mapping.variableName()+
"\".",
77 "ObjectStreamerBase::buildBaseDataMembers" );
88 buildBaseDataMembers( dataElement, relationalData, m_objectType, operationBuffer );
90 for (
unsigned int i=0;
i<m_objectType.DataMemberSize();
i++){
92 Reflex::Member dataMember = m_objectType.DataMemberAt(
i);
96 if( declaringType != m_objectType ){
101 if ( dataMember.IsTransient() || dataMember.IsStatic() )
continue;
105 if ( ! dataMemberType ) {
106 throwException(
"Missing dictionary information for data member \"" +
107 dataMember.Name() +
"\" of class \"" +
108 m_objectType.Name(Reflex::SCOPED|Reflex::FINAL) +
"\"",
109 "ObjectStreamerBase::buildDataMembers" );
119 if ( idataMemberMapping != m_mapping.end() ) {
122 throwException(
"Data member \""+dataMemberName +
"\" type \"" + dataMemberType.Name(Reflex::SCOPED|Reflex::FINAL) +
123 "\" does not match with the expected type in the mapping \""+dataMemberMapping.
variableType()+
"\".",
124 "ObjectStreamerBase::buildDataMembers" );
126 processDataMember( dataMemberElement, relationalData, dataMemberType, dataMemberMapping, operationBuffer );
130 "\" not found in the mapping element of variable \""+m_mapping.variableName()+
"\".",
131 "ObjectStreamerBase::buildDataMembers" );
146 for( std::vector< IRelationalWriter* >::iterator iW = m_writers.begin();
147 iW != m_writers.end(); ++iW ){
156 return buildDataMembers( dataElement, relationalData, &operationBuffer );
160 for( std::vector< IRelationalWriter* >::iterator iW = m_writers.begin();
161 iW != m_writers.end(); ++iW ){
162 (*iW)->setRecordId( identity );
169 for( std::vector< IRelationalWriter* >::iterator iW = m_writers.begin();
170 iW != m_writers.end(); ++iW ){
171 (*iW)->write( oid, data );
180 IRelationalWriter* dataMemberWriter = m_streamerFactory.newWriter( dataMemberType, dataMemberMapping );
181 m_writers.push_back( dataMemberWriter );
182 dataMemberWriter->
build( dataMemberElement, relationalData, *operationBuffer );
194 for( std::vector< IRelationalUpdater* >::iterator iU = m_updaters.begin();
195 iU != m_updaters.end(); ++iU ){
204 return buildDataMembers( dataElement, relationalData, &operationBuffer );
208 for( std::vector< IRelationalUpdater* >::iterator iU = m_updaters.begin();
209 iU != m_updaters.end(); ++iU){
210 (*iU)->setRecordId( identity );
217 for( std::vector< IRelationalUpdater* >::iterator iU = m_updaters.begin();
218 iU != m_updaters.end(); ++iU ){
219 (*iU)->update( oid, data );
228 IRelationalUpdater* dataMemberUpdater = m_streamerFactory.newUpdater( dataMemberType, dataMemberMapping );
229 m_updaters.push_back( dataMemberUpdater );
230 dataMemberUpdater->
build( dataMemberElement, relationalData, *operationBuffer );
241 for( std::vector< IRelationalReader* >::iterator iStr = m_readers.begin();
242 iStr != m_readers.end(); ++iStr ){
250 return buildDataMembers( dataElement, relationalData, 0 );
254 for( std::vector< IRelationalReader* >::iterator iDepReader = m_readers.begin();
255 iDepReader != m_readers.end(); ++iDepReader ){
256 (*iDepReader)->select( oid );
261 for( std::vector< IRelationalReader* >::iterator iDepReader = m_readers.begin();
262 iDepReader != m_readers.end(); ++iDepReader ){
263 (*iDepReader)->setRecordId( identity );
269 for( std::vector< IRelationalReader* >::iterator iDepReader = m_readers.begin();
270 iDepReader != m_readers.end(); ++iDepReader ){
271 (*iDepReader)->read( data );
276 for( std::vector< IRelationalReader* >::iterator iDepReader = m_readers.begin();
277 iDepReader != m_readers.end(); ++iDepReader ){
278 (*iDepReader)->clear();
287 IRelationalReader* dataMemberReader = m_streamerFactory.newReader( dataMemberType, dataMemberMapping );
288 m_readers.push_back( dataMemberReader );
289 dataMemberReader->
build( dataMemberElement, relationalData );
296 m_objectType( objectType ),
297 m_mapping( mapping ),
298 m_schema( contSchema ){
305 return new ObjectWriter( m_objectType, m_mapping, m_schema );
309 return new ObjectUpdater( m_objectType, m_mapping, m_schema );
313 return new ObjectReader( m_objectType, m_mapping, m_schema );
void processDataMember(DataElement &dataElement, IRelationalData &relationalData, Reflex::Type &dataMemberType, MappingElement &dataMemberMapping, RelationalBuffer *operationBuffer)
void setRecordId(const std::vector< int > &identity)
ObjectStreamer(const Reflex::Type &objectType, MappingElement &mapping, ContainerSchema &contSchema)
bool build(DataElement &offset, IRelationalData &relationalData)
void processDataMember(DataElement &dataElement, IRelationalData &relationalData, Reflex::Type &dataMemberType, MappingElement &dataMemberMapping, RelationalBuffer *operationBuffer)
static std::string scopedVariableName(const std::string &variableName, const std::string &scope)
variable name manipulation
void update(int oid, const void *data)
Updates a data element.
static std::string persistencyPropertyNameInDictionary()
virtual bool build(DataElement &offset, IRelationalData &relationalData, RelationalBuffer &operationBuffer)=0
IRelationalWriter * newWriter()
DataElement & addChild(size_t declaringScopeOffset, Reflex::OffsetFunction offsetFunction)
bool isLoosePersistencyDataMember(const Reflex::Member &dataMember)
IRelationalUpdater * newUpdater()
void setRecordId(const std::vector< int > &identity)
void read(void *destination)
Reads a data element.
ObjectReader(const Reflex::Type &objectType, MappingElement &mapping, ContainerSchema &contSchema)
virtual ~ObjectStreamerBase()
bool checkMappedType(const Reflex::Type &type, const std::string &mappedTypeName)
ObjectWriter(const Reflex::Type &objectType, MappingElement &mapping, ContainerSchema &contSchema)
void setRecordId(const std::vector< int > &identity)
bool build(DataElement &dataElement, IRelationalData &relationalData, RelationalBuffer &operationBuffer)
virtual bool build(DataElement &offset, IRelationalData &relationalData)=0
bool buildDataMembers(DataElement &dataElement, IRelationalData &relationalData, RelationalBuffer *operationBuffer)
void buildBaseDataMembers(DataElement &dataElement, IRelationalData &relationalData, const Reflex::Type &objType, RelationalBuffer *operationBuffer)
static bool isLooseOnReading(const std::string &persistencyProperty)
std::map< std::string, MappingElement >::iterator iterator
Iterator definition.
void processDataMember(DataElement &dataElement, IRelationalData &relationalData, Reflex::Type &dataMemberType, MappingElement &dataMemberMapping, RelationalBuffer *operationBuffer)
Reflex::Type resolvedType(const Reflex::Type &typ)
static bool isLooseOnWriting(const std::string &persistencyProperty)
ObjectStreamerBase(const Reflex::Type &objectType, MappingElement &mapping, ContainerSchema &contSchema)
ObjectUpdater(const Reflex::Type &objectType, MappingElement &mapping, ContainerSchema &contSchema)
const std::string & variableType() const
virtual bool build(DataElement &offset, IRelationalData &relationalData, RelationalBuffer &operationBuffer)=0
IRelationalReader * newReader()
char data[epos_bytes_allocation]
bool build(DataElement &dataElement, IRelationalData &relationalData, RelationalBuffer &operationBuffer)
void throwException(const std::string &message, const std::string &methodName)
void write(int oid, const void *data)
Writes a data element.