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 * This file contains the Initializer class.
33 * This class will check and initialize the database.
35 * It will first check whether the database is already initialized.
36 * If it is not yet initialized it will create the appropriate tables.
37 * Therafter it will verify that the schema is good (regardless of earlier actions).
38 * When all is well it will initialize the Database with some default values.
39 * Also the Colours and Commands table will be filled.
44 /** Constructs an Initializer with the specified database connection. */
45 explicit Initializer(Database
* db
) : m_db(db
) {};
47 /** Destructor, a noop. */
51 /** Whether the database version is the same as the version that was used to build this Initializer. */
52 bool VerifyDatabaseVersion();
54 /** Whether the tables match. */
55 bool VerifyTables(TableImplVector::const_iterator begin
, TableImplVector::const_iterator end
);
58 /** Create the tables in the database. */
59 void InitTables(TableImplVector::const_iterator begin
, TableImplVector::const_iterator end
);
61 /** Fill the tables with some default values. */
64 /** Fill the colour table. */
67 /** Fill the command table. */
70 /** Creates 'the void'. */
73 /** Creates a set of sample chunks. */
74 void InitSampleChunks(int size
);
77 /** Hide the copy constructor. */
78 Initializer(const Initializer
& rhs
);
80 /** Hide the assignment operator. */
81 Initializer
operator=(const Initializer
& rhs
);
83 Database
* m_db
; /**< The database connection to use. */
85 /** A struct to store colour definitions in. */
88 std::string name
; /**< The name of the colour. */
89 std::string code
; /**< The colourcode of the colour. */
90 std::string cstr
; /**< The string value of the colour. */
93 /** A struct to store command definitions in. */
96 std::string name
; /**< The fully qualified ('Editor::Name' format) name of the command. */
97 value_type grantgroup
; /**< The grantgroup this command belongs to. */
98 int highforce
; /**< Whether it is possible to highforce someone to execute this command. */
99 int force
; /**< Whether it is possible to force someone to execute this command. */
100 int lowforce
; /**< Whether it is possible to lowforce someone to execute this command. */
101 std::string help
; /**< A help string describing what the command does. */