1// File: MyDb.hpp 2 3#ifndef MYDB_H 4#define MYDB_H 5 6#include <string> 7#include <db_cxx.h> 8 9class MyDb 10{ 11public: 12 // Constructor requires a path to the database, 13 // and a database name. 14 MyDb(std::string &path, std::string &dbName, 15 bool isSecondary = false); 16 17 // Our destructor just calls our private close method. 18 ~MyDb() { close(); } 19 20 inline Db &getDb() {return db_;} 21 22private: 23 Db db_; 24 std::string dbFileName_; 25 u_int32_t cFlags_; 26 27 // Make sure the default constructor is private 28 // We don't want it used. 29 MyDb() : db_(NULL, 0) {} 30 31 // We put our database close activity here. 32 // This is called from our destructor. In 33 // a more complicated example, we might want 34 // to make this method public, but a private 35 // method is more appropriate for this example. 36 void close(); 37}; 38#endif 39