Sorted Core's header files.
[UnsignedByte.git] / src / DAL / DatabaseMgr.h
blob11a7d00efe3f434069cbe65e44e13296a96c6246
1 /***************************************************************************
2 * Copyright (C) 2008 by Sverre Rabbelier *
3 * sverre@rabbelier.nl *
4 * *
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. *
9 * *
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. *
14 * *
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 ***************************************************************************/
20 #pragma once
22 /**
23 * @file DatabaseMgr.h
24 * This file contains the DatabaseMgr class.
26 * @see DatabaseMgr
27 */
29 #include "Database.h"
30 #include "Types.h"
32 /**
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>.
40 * @see Get
41 * @see Initialize
42 * @see Free
43 */
44 class DatabaseMgr : public Singleton<DatabaseMgr>
46 public:
47 /** Initialize the DatabaseMgr with a specific path. */
48 static void Initialize(const std::string& path);
50 /** Returns a pointer to the Database. */
51 Database* DB();
53 /** Returns a reference to the Database. */
54 Database& DBref();
56 private:
57 /** This is a singleton class, use <code>Get</code> to get the instance. */
58 DatabaseMgr();
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. */
67 ~DatabaseMgr();
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. */