00001
00002 #ifndef ANAPHE_OBJECTIVITYSTORE
00003 #define ANAPHE_OBJECTIVITYSTORE 1
00004
00005 #include <vector>
00006 #include <string>
00007 #include <map>
00008 #include <set>
00009 #include "AIDA_Dev/IStore.h"
00010 #include "AIDA_Dev/IBackingStore.h"
00011
00012 namespace AIDA {
00013 namespace Dev {
00014 class IDevManagedObject;
00015 }
00016 }
00017
00018 class ooSession;
00019 class HepMapTree;
00020 class HepExplorable;
00021 #include "oo.h"
00022
00023 namespace Anaphe {
00024 namespace AIDA_ObjectivityStore {
00025 class ObjectivityOptionParser;
00026 class ObjyTuple;
00027
00029
00030 class AIDA_ObjyStore : virtual public AIDA::Dev::IStore,
00031 virtual public AIDA::Dev::IBackingStore
00032 {
00033 public:
00035 AIDA_ObjyStore( const std::string& name,
00036 bool readOnly,
00037 bool createNew,
00038 const std::string& options );
00040 ~AIDA_ObjyStore();
00041
00043 const std::string& name() const;
00044 bool writeObject( const AIDA::IManagedObject& dataObject,
00045 const std::string& path );
00046 AIDA::IManagedObject* copyAndWrite( const AIDA::IManagedObject& dataObject,
00047 const std::string& path );
00048 AIDA::IManagedObject* retrieveObject( const std::string & path );
00049 bool removeObject( const std::string& path );
00050 bool moveObject(const std::string& from, const std::string& to );
00051 bool commit();
00052 bool close();
00053 std::vector< std::string > listObjectPaths( const std::string directory,
00054 bool recursive = false ) const;
00055 std::vector< std::string > listObjectTypes( const std::string directory,
00056 bool recursive = false ) const;
00057 bool canMoveTuples() const;
00058 bool canCopyTuples() const;
00059
00061 bool writeTupleHeader( AIDA::Dev::ITupleHeader& header );
00062 bool readTupleHeader( AIDA::Dev::ITupleHeader& header );
00063 bool bindVariable( AIDA::Dev::ITupleHeader& header, int variableIndex );
00064 void* variableAddress( AIDA::Dev::ITupleHeader& header, int variableIndex );
00065 const void* variableAddress( const AIDA::Dev::ITupleHeader& header, int variableIndex ) const;
00066 bool clearBindings( const AIDA::Dev::ITupleHeader& header );
00067 bool writeTupleRow( AIDA::Dev::ITupleHeader& header );
00068 bool readTupleRow( AIDA::Dev::ITupleHeader& header );
00069 bool resetTuple( AIDA::Dev::ITupleHeader& header );
00070
00071 private:
00072 std::string m_name;
00073 bool m_isClosed;
00074 ObjectivityOptionParser* m_optionParser;
00075 ooSession* m_ooSession;
00076 HepMapTree* m_hepMapTree;
00077 std::string m_topLevelDatabase;
00078 std::string m_topLevelContainer;
00079
00080
00081 std::map< std::string, std::string > m_objectTypes;
00082 std::map< std::string, AIDA::Dev::IDevManagedObject* > m_objectRefs;
00083 std::map< std::string, ooRef(ooObj) > m_objectSysRefs;
00084 std::map< std::string, HepExplorable* > m_tuples;
00085 std::map< std::string, ObjyTuple* > m_tupleData;
00086
00087 std::set< std::string > m_objectsToAdd;
00088
00089 private:
00090 void collectObjectTypes( const std::string& directory );
00091 void commitAdd();
00092 void registerType( ooRef(ooObj) ref, const ooHandle(ooContObj)& hCont,
00093 const std::string& type );
00094
00095 };
00096
00097 }
00098 }
00099
00100 #endif