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