CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_6/src/CondCore/ORA/src/STLContainerStreamer.h

Go to the documentation of this file.
00001 #ifndef INCLUDE_ORA_STLCONTAINERSTREAMER_H
00002 #define INCLUDE_ORA_STLCONTAINERSTREAMER_H
00003 
00004 #include "DataElement.h"
00005 #include "IRelationalStreamer.h"
00006 #include "RelationalDeleter.h"
00007 //
00008 #include <memory>
00009 // externals
00010 #include "Reflex/Type.h"
00011 
00012 namespace ora {
00013 
00014   class MappingElement;
00015   class ContainerSchema;
00016 
00017   class IArrayHandler;
00018   class MultiRecordInsertOperation;
00019   class MultiRecordSelectOperation;
00020 
00021   class STLContainerWriter : public IRelationalWriter {
00022     
00023     public:
00025       STLContainerWriter( const Reflex::Type& objectType, MappingElement& mapping, ContainerSchema& contSchema );
00026       virtual ~STLContainerWriter();
00027 
00028       MappingElement& mapping();
00029       DataElement* dataElement();
00030       IArrayHandler* arrayHandler();
00031 
00032     public:
00033 
00034       bool build( DataElement& offset, IRelationalData& relationalData, RelationalBuffer& operationBuffer );
00035       
00036       void setRecordId( const std::vector<int>& identity );
00037 
00039       void write( int oid,const void* data );
00040 
00041     private:
00042       Reflex::Type m_objectType;
00043       MappingElement& m_mappingElement;
00044       ContainerSchema& m_schema;
00045       std::vector<int> m_recordId;
00046       DataElement m_localElement;
00047 
00048     private:
00049       bool m_associative;
00050       DataElement* m_offset;
00051       MultiRecordInsertOperation* m_insertOperation;
00052       std::auto_ptr<IArrayHandler> m_arrayHandler;
00053       std::auto_ptr<IRelationalWriter> m_keyWriter; 
00054       std::auto_ptr<IRelationalWriter> m_dataWriter;
00055   };
00056   
00057   class STLContainerUpdater : public IRelationalUpdater {
00058 
00059     public:
00060 
00062     STLContainerUpdater(const Reflex::Type& objectType, MappingElement& mapping, ContainerSchema& contSchema );
00063 
00064     virtual ~STLContainerUpdater();
00065 
00066     bool build( DataElement& offset, IRelationalData& relationalData, RelationalBuffer& operationBuffer);
00067 
00068     void setRecordId( const std::vector<int>& identity );
00069 
00071     void update( int oid,const void* data );
00072 
00073    private:
00074 
00075     RelationalDeleter m_deleter;
00076     STLContainerWriter m_writer;
00077   };
00078 
00079   class STLContainerReader : public IRelationalReader {
00080 
00081     public:
00082     
00084     STLContainerReader(const Reflex::Type& objectType, MappingElement& mapping, ContainerSchema& contSchema );
00085 
00086     virtual ~STLContainerReader();
00087     
00088     bool build( DataElement& offset, IRelationalData& relationalData );
00089 
00090     void select( int oid );
00091     
00092     void setRecordId( const std::vector<int>& identity );
00093 
00095     void read( void* address );
00096 
00097     void clear();
00098 
00099     private:
00100       Reflex::Type m_objectType;
00101       MappingElement& m_mappingElement;
00102       ContainerSchema& m_schema;
00103       std::vector<int> m_recordId;
00104       DataElement m_localElement;
00105       
00106     private:
00107       bool m_associative;
00108       DataElement* m_offset;
00109       std::auto_ptr<MultiRecordSelectOperation> m_query;
00110       std::auto_ptr<IArrayHandler> m_arrayHandler;
00111       std::auto_ptr<IRelationalReader> m_keyReader;
00112       std::auto_ptr<IRelationalReader> m_dataReader;
00113   };
00114 
00115   class STLContainerStreamer : public IRelationalStreamer 
00116   {
00117     public:
00118     STLContainerStreamer( const Reflex::Type& objectType, MappingElement& mapping, ContainerSchema& contSchema );
00119 
00120     ~STLContainerStreamer();
00121 
00122     IRelationalWriter* newWriter();
00123 
00124     IRelationalUpdater* newUpdater();
00125 
00126     IRelationalReader* newReader();
00127     
00128     private:
00129     Reflex::Type m_objectType;
00130     MappingElement& m_mapping;
00131     ContainerSchema& m_schema;
00132   }; 
00133 
00134   
00135 }
00136 
00137 inline
00138 ora::MappingElement&
00139 ora::STLContainerWriter::mapping(){
00140   return m_mappingElement;
00141 }
00142 
00143 inline
00144 ora::DataElement*
00145 ora::STLContainerWriter::dataElement(){
00146   return m_offset;
00147 }
00148 
00149 inline
00150 ora::IArrayHandler*
00151 ora::STLContainerWriter::arrayHandler(){
00152   return m_arrayHandler.get();
00153 }
00154 
00155 #endif
00156 
00157