Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

MyDb.hpp

00001 // File: MyDb.hpp
00002 
00003 #ifndef MYDB_H
00004 #define MYDB_H
00005 
00006 #include <string>
00007 #include <db_cxx.h>
00008 
00009 class MyDb
00010 {
00011 public:
00012     // Constructor requires a path to the database,
00013     // and a database name.
00014     MyDb(std::string &path, std::string &dbName,
00015          bool isSecondary = false);
00016 
00017     // Our destructor just calls our private close method.
00018     ~MyDb() { close(); }
00019 
00020     inline Db &getDb() {return db_;}
00021 
00022 private:
00023     Db db_;
00024     std::string dbFileName_;
00025     u_int32_t cFlags_;
00026 
00027     // Make sure the default constructor is private
00028     // We don't want it used.
00029     MyDb() : db_(NULL, 0) {}
00030 
00031     // We put our database close activity here.
00032     // This is called from our destructor. In
00033     // a more complicated example, we might want
00034     // to make this method public, but a private
00035     // method is more appropriate for this example.
00036     void close();
00037 };
00038 #endif

Generated on Sun Dec 25 12:14:25 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2