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