![]() |
VR-Forces Developer's Guide
|
The base class for all database connections. The database connection is responsible for reading queued up events from the database logger, and then recording those events to the connected database. This is normally done by a dedicated thread that is launched during initialization.
By default the DtVrfNoDatabaseConnection will be created, which does not connect to any database. VR-Forces can be configured to create a DtVrfSqliteDatabaseConnection instead, which will open and write to an SQLite database. Other database implementations could be added via plugins. The databaseConnection example shows how to add a new type of database connection. It adds support for MySQL. The database connection used can be configured in appData/settings/databaseConfig.mtl.

Public Member Functions | |
| virtual | ~DtVrfDatabaseConnection () |
| virtual bool | initialize (const DtRwDatabaseLoggerConfig &config, DtVrfDatabaseLoggerInterface *dbLogger) |
| virtual void | run () |
Protected Member Functions | |
| DtVrfDatabaseConnection () | |
| virtual bool | processConfiguration (const DtRwDatabaseLoggerConfig &config) |
| virtual bool | connect ()=0 |
| virtual bool | createDatabase ()=0 |
| virtual bool | stop () |
| virtual bool | createTableForEvent (const DtVrfDatabaseEvent &event)=0 |
| virtual bool | insertOrIgnoreEntriesForEvents (const DtVrfDatabaseEventVector &events)=0 |
| virtual bool | insertOrUpdateEntriesForEvents (const DtVrfDatabaseEventVector &events)=0 |
| virtual bool | updateEntryForEvent (const DtVrfDatabaseEvent &event)=0 |
| virtual std::string | escapeString (std::string str) |
Protected Attributes | |
| DtVrfDatabaseLoggerInterface * | myDatabaseLogger |
| double | myLogPeriod |
| std::unique_ptr< std::thread > | myThread |
| std::vector< bool > | myCreatedTables |
| std::atomic< bool > | myTimeToStop |
| std::atomic< bool > | myStopped |
| LogToDatabaseTask * | myTask |
Private Member Functions | |
| DtVrfDatabaseConnection (const DtVrfDatabaseConnection &other) | |
| DtVrfDatabaseConnection & | operator= (const DtVrfDatabaseConnection &other) |
|
virtual |
Destructor.
|
protected |
Constructor.
|
private |
Copy Constructor not implemented – Do Not copy.
|
virtual |
Initializes the connection to the database server. Stores the database logger pointer and calls processConfiguration(), connect(), and createDatabase().
|
virtual |
The main processing loop executed by the connection thread. This function will loop until the connection is stopped.
|
protectedvirtual |
Processes the configuration for this connection.
Reimplemented in DtVrfNoDatabaseConnection, DtVrfSqliteDatabaseConnection, and DtVrfMySqlDatabaseConnection.
|
protectedpure virtual |
Connects to the configured server.
Implemented in DtVrfNoDatabaseConnection, DtVrfSqliteDatabaseConnection, and DtVrfMySqlDatabaseConnection.
|
protectedpure virtual |
Creates the database.
Implemented in DtVrfNoDatabaseConnection, DtVrfSqliteDatabaseConnection, and DtVrfMySqlDatabaseConnection.
|
protectedvirtual |
Stops the thread.
|
protectedpure virtual |
Creates a table a database table, if necessary.
Implemented in DtVrfNoDatabaseConnection, DtVrfSqliteDatabaseConnection, and DtVrfMySqlDatabaseConnection.
|
protectedpure virtual |
Logs the given events to the database, ignoring duplicates. NOTE: All events in the list must be of the same event type!
Implemented in DtVrfNoDatabaseConnection, DtVrfSqliteDatabaseConnection, and DtVrfMySqlDatabaseConnection.
|
protectedpure virtual |
Logs the given events to the database, updating duplicates. NOTE: All events in the list must be of the same event type!
Implemented in DtVrfNoDatabaseConnection, DtVrfSqliteDatabaseConnection, and DtVrfMySqlDatabaseConnection.
|
protectedpure virtual |
Updates the given event in the database.
Implemented in DtVrfNoDatabaseConnection, DtVrfSqliteDatabaseConnection, and DtVrfMySqlDatabaseConnection.
|
inlineprotectedvirtual |
Takes the given string and escapes it for use in an SQL statement. Default implementation just returns the input string with no change. Subclasses may implement this.
Reimplemented in DtVrfSqliteDatabaseConnection, and DtVrfMySqlDatabaseConnection.
|
private |
Assignment Operator not implemented – Do Not copy.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |