UMCD
Contents
User Made Content Daemon (UMCD)
This page will give information on the UMCD.
Installation
Dependencies on Linux
We must first install some required packets:
sudo apt-get install mysql-server unixodbc-dev libmyodbc libboost-iostreams-dev libboost-program-options-dev libboost-regex-dev libboost-system-dev libboost-thread-dev libboost-date-time-dev
- mysql-server is the MySQL database.
- unixodbc is a middleware API to access database (see http://en.wikipedia.org/wiki/ODBC).
- libmyodbc is the MySQL driver to access the MySQL database.
- Boost libraries are used to ease the development.
Database setup
We'll explain this step for the MySQL database but you can use any database that is ODBC compliant.
Initialize the MySQL database
Enter the MySQL prompt with:
mysql -u root -p
Then, we create the database:
mysql> CREATE DATABASE IF NOT EXISTS umcd; mysql> USE umcd;
We create the tables:
mysql> source {wesnoth-directory}/data/umcd/database/create_database.sql
We populate the database:
mysql> source {wesnoth-directory}/data/umcd/database/populate_database.sql
You can check that the tables are added with:
mysql> show tables;
Now we quit the mysql prompt:
mysql> exit;
Install the ODBC driver
We must link the database to ODBC, so we'll retrieve the database connexion via a Data source name (DSN).
First we must find the odbc.ini file:
odbcinst -j
In my computer it's in /etc/odbc.ini so I'll refer to this location. We must edit this file:
sudo vim /etc/odbc.ini
The file can be empty, we'll add these data:
; ; odbc.ini configuration for Connector/ODBC ; [ODBC Data Sources] dbumcd = MyODBC Driver DSN for the UMCD database [dbumcd] Driver = /usr/lib/libmyodbc.so Description = Connector/ODBC Driver DSN for the UMCD database SERVER = localhost PORT = USER = Password = Database = umcd OPTION = 3 SOCKET =
The DSN of the umcd database will be "dbumcd". You can change the SERVER and PORT entry if it's an external database. Otherwise, let all the fields with a blank like in the example.
Next we must install the driver with:
odbcinst -f /etc/odbc.ini -d -i
You can list all the ODBC drivers installed with:
odbcinst -s -q
That's all!
Configuration
Want to join the development?
Everyone can join the development of the UMCD, but the most difficult task is to get in. We want to simplify this process and have written some tutorials and articles that will help you to understand the spirit of the code. Of course the Doxygen documentation is the reference and it's where you will search for class details.
TODO list
Building and installation script
As you noticed, the installation is not as simple as it could be. We would like to launch a simple command, such as make install to launch the process. A good building script would be really nice, I can think of several steps for it:
- Install dependencies (such as unixODBC, Boost, ...).
- Configure and install the database.
- Configure and install the ODBC driver.
- Building the code of the UMCD.
- Building the code of the UMCD tests.
- Test the code.
- Use this script with Travis to automate the building and tests with each commits.
All these little steps should be implemented in different script files if possible. And one command/script should put together all these steps.
There is room for improvement:
- Support multi-platform (especially Windows)
- Support multi-database configuration (you'll need to modify the OTL header too), this can be a bit tricky to automate.
- Whatever you find useful.
Always try to make these scripts generic enough to be re-usable with other server and/or application.
C++ code generator from SQL schema
- Where? {wesnoth-source-tree}/src/tools/code_generator/sql2cpp/
- Ressources?
The classes that contains the database table are automatically generated from the SQL schema. So we only have one representation of our database and we are automatically in synchronization.
This is an aside project, not related to Wesnoth code, and I wish to keep this independence. There is a big room for improvement:
- (easy-medium) The code doesn't support all the SQL grammar, of course it shouldn't, but a lot of keywords (not related to the generation) are missing, such as the index keywords. Improve the grammar!
- (medium) The SQL parser is specific to the MySQL dialect, we should use a base class for standard SQL dialect and inherits from this parser to handle other dialect such as the MySQL, Oracle, ... For example the keyword AUTO_INCREMENT isn't standard.
Improve the code generation:
- (medium) Add CRUD operation inside the POD classes.
- (hard) Maybe use Boost.Fusion to make any SQL statements generic.
- (medium) Add an option for the underlying database access library, here it's OTL, but it could be others such as SOCI.
Some simple improvements:
- (easy) Add a namespace options, so we can generate the code in a custom namespace, try to allow nested namespace (such as umcd::pod).