Go to the documentation of this file.00001 #ifndef INCLUDE_ORA_OBJECTSTREAMER_H
00002 #define INCLUDE_ORA_OBJECTSTREAMER_H
00003
00004 #include "IRelationalStreamer.h"
00005 #include "RelationalStreamerFactory.h"
00006
00007 #include "Reflex/Type.h"
00008
00009 namespace ora {
00010
00011 class MappingElement;
00012 class ContainerSchema;
00013 class DataElement;
00014
00015 class ObjectStreamerBase {
00016 public:
00017 ObjectStreamerBase( const Reflex::Type& objectType, MappingElement& mapping, ContainerSchema& contSchema );
00018 virtual ~ObjectStreamerBase();
00019 virtual void processDataMember( DataElement& dataElement, IRelationalData& relationalData, Reflex::Type& dataMemberType, MappingElement& dataMemberMapping, RelationalBuffer* operationBuffer ) = 0;
00020 void buildBaseDataMembers( DataElement& dataElement, IRelationalData& relationalData, const Reflex::Type& objType, RelationalBuffer* operationBuffer );
00021 bool buildDataMembers( DataElement& dataElement, IRelationalData& relationalData, RelationalBuffer* operationBuffer );
00022 protected:
00023 RelationalStreamerFactory m_streamerFactory;
00024 private:
00025 Reflex::Type m_objectType;
00026 MappingElement& m_mapping;
00027 };
00028
00029 class ObjectWriter : public ObjectStreamerBase, public IRelationalWriter{
00030
00031 public:
00032
00033 ObjectWriter( const Reflex::Type& objectType, MappingElement& mapping, ContainerSchema& contSchema );
00034
00035 virtual ~ObjectWriter();
00036
00037 bool build(DataElement& dataElement, IRelationalData& relationalData, RelationalBuffer& operationBuffer);
00038
00039 void setRecordId( const std::vector<int>& identity );
00040
00042 void write( int oid, const void* data );
00043
00044 public:
00045
00046 void processDataMember( DataElement& dataElement, IRelationalData& relationalData, Reflex::Type& dataMemberType, MappingElement& dataMemberMapping, RelationalBuffer* operationBuffer );
00047
00048 private:
00049
00050 std::vector< IRelationalWriter* > m_writers;
00051 };
00052
00053 class ObjectUpdater : public ObjectStreamerBase, public IRelationalUpdater {
00054
00055 public:
00056
00057 ObjectUpdater( const Reflex::Type& objectType, MappingElement& mapping, ContainerSchema& contSchema );
00058
00059 virtual ~ObjectUpdater();
00060
00061 bool build(DataElement& dataElement, IRelationalData& relationalData, RelationalBuffer& operationBuffer);
00062
00063 void setRecordId( const std::vector<int>& identity );
00064
00066 void update( int oid,
00067 const void* data );
00068
00069 public:
00070
00071 void processDataMember( DataElement& dataElement, IRelationalData& relationalData, Reflex::Type& dataMemberType, MappingElement& dataMemberMapping, RelationalBuffer* operationBuffer );
00072
00073 private:
00074
00075 std::vector< IRelationalUpdater* > m_updaters;
00076 };
00077
00078 class ObjectReader : public ObjectStreamerBase, public IRelationalReader {
00079
00080 public:
00081
00082 ObjectReader( const Reflex::Type& objectType, MappingElement& mapping, ContainerSchema& contSchema );
00083
00084 virtual ~ObjectReader();
00085
00086 bool build( DataElement& offset, IRelationalData& relationalData);
00087
00088 void select( int oid );
00089
00090 void setRecordId( const std::vector<int>& identity );
00091
00093 void read( void* destination );
00094
00095 void clear();
00096
00097 public:
00098
00099 void processDataMember( DataElement& dataElement, IRelationalData& relationalData, Reflex::Type& dataMemberType, MappingElement& dataMemberMapping, RelationalBuffer* operationBuffer );
00100
00101 private:
00102
00103 std::vector< IRelationalReader* > m_readers;
00104 };
00105
00106 class ObjectStreamer : public IRelationalStreamer
00107 {
00108 public:
00109 ObjectStreamer( const Reflex::Type& objectType, MappingElement& mapping, ContainerSchema& contSchema );
00110
00111 ~ObjectStreamer();
00112
00113 IRelationalWriter* newWriter();
00114
00115 IRelationalUpdater* newUpdater();
00116
00117 IRelationalReader* newReader();
00118
00119 private:
00120 Reflex::Type m_objectType;
00121 MappingElement& m_mapping;
00122 ContainerSchema& m_schema;
00123 };
00124
00125 }
00126 #endif
00127
00128
00129