CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/CondCore/ORA/src/DatabaseContainer.h

Go to the documentation of this file.
00001 #ifndef INCLUDE_ORA_DATABASECONTAINER_H
00002 #define INCLUDE_ORA_DATABASECONTAINER_H
00003 
00004 #include "CondCore/ORA/interface/Handle.h"
00005 #include "RelationalOperation.h"
00006 //
00007 #include <string>
00008 #include <vector>
00009 #include <memory>
00010 #include <typeinfo>
00011 
00012 namespace Reflex {
00013   class Type;
00014 }
00015 
00016 namespace ora {
00017 
00018   class ContainerSchema;
00019   class DatabaseSession;
00020   class ContainerUpdateTable;
00021   class WriteBuffer;
00022   class UpdateBuffer;
00023   class ReadBuffer;
00024   class DeleteBuffer;
00025 
00026   class IteratorBuffer{
00027     public:
00028     IteratorBuffer( ContainerSchema& schema, ReadBuffer& buffer );
00029 
00030     ~IteratorBuffer();
00031 
00032     void reset();
00033 
00034     bool next();
00035 
00036     void* getItem();
00037 
00038     void* getItemAsType( const Reflex::Type& type );
00039 
00040     int itemId();
00041 
00042     const Reflex::Type& type();
00043       
00044     private:
00045     SelectOperation m_query;
00046     int m_itemId;
00047     ReadBuffer& m_readBuffer;
00048   };
00049   
00050   class DatabaseContainer {
00051     
00052     public:
00053     DatabaseContainer( int contId, const std::string& containerName, const std::string& className,
00054                        unsigned int containerSize, DatabaseSession& session );
00055 
00056     DatabaseContainer( int contId, const std::string& containerName, const Reflex::Type& containerType,
00057                        DatabaseSession& session );                  
00058     
00059     virtual ~DatabaseContainer();
00060 
00061     int id();
00062 
00063     const std::string& name();
00064 
00065     const std::string& className();
00066 
00067     const Reflex::Type& type();
00068 
00069     const std::string& mappingVersion();
00070 
00071     size_t size();
00072 
00073     void create();
00074 
00075     void drop();
00076 
00077     void extendSchema( const Reflex::Type& dependentType );
00078 
00079     Handle<IteratorBuffer> iteratorBuffer();
00080     
00081     void* fetchItem(int itemId);
00082 
00083     void* fetchItemAsType(int itemId, const Reflex::Type& asType);
00084     
00085     int insertItem( const void* data, const Reflex::Type& type );
00086     
00087     void updateItem( int itemId, const void* data, const Reflex::Type& type );    
00088 
00089     void erase( int itemId );
00090     
00091     void flush();
00092 
00093     void setItemName( const std::string& name, int itemId );
00094 
00095     bool getNames( std::vector<std::string>& destination );
00096 
00097     private:
00098     std::auto_ptr<ContainerSchema> m_schema;
00099     std::auto_ptr<WriteBuffer> m_writeBuffer;
00100     std::auto_ptr<UpdateBuffer> m_updateBuffer;
00101     std::auto_ptr<ReadBuffer>   m_readBuffer;
00102     std::auto_ptr<DeleteBuffer> m_deleteBuffer;
00103     Handle<IteratorBuffer> m_iteratorBuffer;
00104     size_t m_size;
00105     ContainerUpdateTable& m_containerUpdateTable;
00106   };
00107 
00108 }
00109 
00110 #endif