VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions
DtVrfDatabaseConnection Class Referenceabstract

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 database connection used can be configured in appData/settings/databaseConfig.mtl.

Inheritance diagram for DtVrfDatabaseConnection:
Inheritance graph
[legend]

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
 

Protected Attributes

DtVrfDatabaseLoggerInterfacemyDatabaseLogger
 
double myLogPeriod
 
std::vector< boolmyCreatedTables
 
std::atomic< boolmyTimeToStop
 
std::atomic< boolmyStopped
 
LogToDatabaseTask * myTask
 

Private Member Functions

 DtVrfDatabaseConnection (const DtVrfDatabaseConnection &other)
 
DtVrfDatabaseConnectionoperator= (const DtVrfDatabaseConnection &other)
 

Constructor & Destructor Documentation

virtual DtVrfDatabaseConnection::~DtVrfDatabaseConnection ( )
virtual

Destructor.

DtVrfDatabaseConnection::DtVrfDatabaseConnection ( )
protected

Constructor.

DtVrfDatabaseConnection::DtVrfDatabaseConnection ( const DtVrfDatabaseConnection other)
private

Copy Constructor not implemented – Do Not copy.

Member Function Documentation

virtual bool DtVrfDatabaseConnection::initialize ( const DtRwDatabaseLoggerConfig config,
DtVrfDatabaseLoggerInterface dbLogger 
)
virtual

Initializes the connection to the database server. Stores the database logger pointer and calls processConfiguration(), connect(), and createDatabase().

virtual void DtVrfDatabaseConnection::run ( )
virtual

The main processing loop executed by the connection thread. This function will loop until the connection is stopped.

virtual bool DtVrfDatabaseConnection::processConfiguration ( const DtRwDatabaseLoggerConfig config)
protectedvirtual

Processes the configuration for this connection.

Reimplemented in DtVrfNoDatabaseConnection, and DtVrfSqliteDatabaseConnection.

virtual bool DtVrfDatabaseConnection::connect ( )
protectedpure virtual

Connects to the configured server.

Implemented in DtVrfNoDatabaseConnection, and DtVrfSqliteDatabaseConnection.

virtual bool DtVrfDatabaseConnection::createDatabase ( )
protectedpure virtual

Creates the database.

Implemented in DtVrfNoDatabaseConnection, and DtVrfSqliteDatabaseConnection.

virtual bool DtVrfDatabaseConnection::stop ( )
protectedvirtual

Stops the thread.

virtual bool DtVrfDatabaseConnection::createTableForEvent ( const DtVrfDatabaseEvent event)
protectedpure virtual

Creates a table a database table, if necessary.

Implemented in DtVrfNoDatabaseConnection, and DtVrfSqliteDatabaseConnection.

virtual bool DtVrfDatabaseConnection::insertOrIgnoreEntriesForEvents ( const DtVrfDatabaseEventVector events)
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, and DtVrfSqliteDatabaseConnection.

virtual bool DtVrfDatabaseConnection::insertOrUpdateEntriesForEvents ( const DtVrfDatabaseEventVector events)
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, and DtVrfSqliteDatabaseConnection.

virtual bool DtVrfDatabaseConnection::updateEntryForEvent ( const DtVrfDatabaseEvent event)
protectedpure virtual

Updates the given event in the database.

Implemented in DtVrfNoDatabaseConnection, and DtVrfSqliteDatabaseConnection.

DtVrfDatabaseConnection& DtVrfDatabaseConnection::operator= ( const DtVrfDatabaseConnection other)
private

Assignment Operator not implemented – Do Not copy.

Member Data Documentation

DtVrfDatabaseLoggerInterface* DtVrfDatabaseConnection::myDatabaseLogger
protected
double DtVrfDatabaseConnection::myLogPeriod
protected
std::vector<bool> DtVrfDatabaseConnection::myCreatedTables
protected
std::atomic<bool> DtVrfDatabaseConnection::myTimeToStop
protected
std::atomic<bool> DtVrfDatabaseConnection::myStopped
protected
LogToDatabaseTask* DtVrfDatabaseConnection::myTask
protected

The documentation for this class was generated from the following file:

Document ID: Generated on Tue Sep 24 19:28:17 EDT 2024 from SVN revision 269799
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)