00001 #ifndef LUX_INDEX_IDMANAGER_H
00002 #define LUX_INDEX_IDMANAGER_H
00003
00004 #include "lux/lux.h"
00005 #include "lux/storage/storage_engine.h"
00006 #include <string>
00007
00008 #ifdef HAVE_TR1_MEMORY
00009 #include <tr1/memory>
00010 #elif HAVE_BOOST_SHARED_PTR_HPP
00011 #include <boost/shared_ptr.hpp>
00012 #endif
00013
00014 #define IID "__IID__"
00015
00016 namespace Lux {
00017
00018 class Document;
00019
00020 class IDManager {
00021 public:
00022 IDManager(void);
00023 ~IDManager();
00024 bool open(std::string dir, db_flags_t oflags = DB_CREAT);
00025 bool close(void);
00026 id_status_t set_id(Document *doc, bool create_if_new = true);
00027 id_status_t set_id(Document &doc, bool create_if_new = true);
00028
00029 private:
00030 doc_id_t curr_id_;
00031 LuxDataUnit id_key_;
00032 db_flags_t oflags_;
00033 #ifdef HAVE_TR1_MEMORY
00034 std::tr1::shared_ptr<LuxBtreeStorage> manager_;
00035 #elif HAVE_BOOST_SHARED_PTR_HPP
00036 boost::shared_ptr<LuxBtreeStorage> manager_;
00037 #endif
00038 };
00039 }
00040
00041 #endif