1 /***************************************************************************
2 * Copyright (C) 2008 by Sverre Rabbelier *
3 * sverre@rabbelier.nl *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 3 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
24 * @brief This file contains the DatabaseMgr class.
33 * This class manages the database connection.
35 * Before calling the <code>Get</code> method <code>Initialize</code> should have been called at least once.
36 * <code>Initialize</code> will set the path to the database to use when the instance is created.
37 * Since the path is specific to each instance each call to <code>Free</code> should be followed by <code>Initialize</code>.
38 * Ofcourse, the last call to <code>Free</code> (when shutting down) should not be followed by <code>Initialize</code>.
44 class DatabaseMgr
: public Singleton
<DatabaseMgr
>
47 /** Initialize the DatabaseMgr with a specific path. */
48 static void Initialize(const std::string
& path
);
50 /** Returns a pointer to the Database. */
53 /** Returns a reference to the Database. */
57 /** This is a singleton class, use <code>Get</code> to get the instance. */
60 /** Hide the copy constructor. */
61 DatabaseMgr(const DatabaseMgr
& rhs
);
63 /** Hide the assignment constructor. */
64 DatabaseMgr
operator=(const DatabaseMgr
& rhs
);
66 /** This is a singleton class, use <code>Free</code> to free the instance. */
69 friend class Singleton
<DatabaseMgr
>;
71 std::string m_path
; /**< The path to the database to use. */
72 Database
* m_db
; /**< A pointer to the database. */
74 static std::string m_staticpath
; /**< The path to the database to use for the next instance. */