CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/CondCore/ORA/src/UniqueRefStreamer.h

Go to the documentation of this file.
00001 #ifndef INCLUDE_ORA_UNIQUEREFSTREAMER_H
00002 #define INCLUDE_ORA_UNIQUEREFSTREAMER_H
00003 
00004 #include "IRelationalStreamer.h"
00005 #include "DataElement.h"
00006 #include "RelationalBuffer.h"
00007 //
00008 #include <memory>
00009 #include <boost/shared_ptr.hpp>
00010 // externals
00011 #include "Reflex/Type.h"
00012 
00013 
00014 namespace ora {
00015 
00016   class MappingElement;
00017   class ContainerSchema;
00018   class RelationalRefLoader;
00019   class DependentClassReader;
00020 
00021   std::string uniqueRefNullLabel();
00022   
00023   class UniqueRefWriter :  public IRelationalWriter{
00024 
00025     public:
00026 
00027       UniqueRefWriter( const Reflex::Type& objectType, MappingElement& mapping, ContainerSchema& contSchema );
00028 
00029       virtual ~UniqueRefWriter();
00030       
00031       bool build(DataElement& dataElement, IRelationalData& relationalData, RelationalBuffer& operationBuffer);
00032 
00033       void setRecordId( const std::vector<int>& identity );
00034       
00036       void write( int oid, const void* data );
00037 
00038     private:
00039 
00040       Reflex::Type m_objectType;
00041       MappingElement& m_mappingElement;
00042       int m_columnIndexes[2];
00043       ContainerSchema& m_schema;
00044       DataElement* m_dataElement;
00045       IRelationalData* m_relationalData;
00046       RelationalBuffer* m_operationBuffer;
00047   };
00048   
00049   class UniqueRefUpdater :  public IRelationalUpdater {
00050 
00051     public:
00052 
00053       UniqueRefUpdater( const Reflex::Type& objectType, MappingElement& mapping, ContainerSchema& contSchema );
00054 
00055       virtual ~UniqueRefUpdater();
00056       
00057       bool build(DataElement& dataElement, IRelationalData& relationalData, RelationalBuffer& operationBuffer);
00058       
00059       void setRecordId( const std::vector<int>& identity );
00060       
00062       void update( int oid,
00063                    const void* data );
00064 
00065     private:
00066 
00067       UniqueRefWriter m_writer;
00068 
00069   };
00070 
00071   class UniqueRefReader : public IRelationalReader {
00072 
00073       public:
00074 
00075       UniqueRefReader( const Reflex::Type& objectType, MappingElement& mapping, ContainerSchema& contSchema );
00076 
00077       virtual ~UniqueRefReader();
00078       
00079       bool build( DataElement& offset, IRelationalData& relationalData);
00080 
00081       void select( int oid );
00082       
00083       void setRecordId( const std::vector<int>& identity );
00084 
00086       void read( void* destination );
00087 
00088       void clear();
00089 
00090     private:
00091 
00092       Reflex::Type m_objectType;
00093       MappingElement& m_mappingElement;
00094       int m_columnIndexes[2];
00095       ContainerSchema& m_schema;
00096       DataElement* m_dataElement;
00097       IRelationalData* m_relationalData;
00098       std::vector<boost::shared_ptr<RelationalRefLoader> > m_loaders;
00099   };
00100 
00101   class UniqueRefStreamer : public IRelationalStreamer 
00102   {
00103     public:
00104     UniqueRefStreamer( const Reflex::Type& objectType, MappingElement& mapping, ContainerSchema& contSchema );
00105 
00106     ~UniqueRefStreamer();
00107 
00108     IRelationalWriter* newWriter();
00109 
00110     IRelationalUpdater* newUpdater();
00111 
00112     IRelationalReader* newReader();
00113     
00114     private:
00115     Reflex::Type m_objectType;
00116     MappingElement& m_mapping;
00117     ContainerSchema& m_schema;
00118   }; 
00119 
00120 }
00121 #endif
00122 
00123     
00124