DatabaseSwitch

The database switch can be used if one needs multiple UDatabase user instances which work within the same logical database transaction, as one database transaction just processes requests from the same UDatabase user.

This implementation stores the UDatabase user from the application inside a queue and always uses the own UDatabase pointer.

File information

Filecommon/lib/database_switch.h

Classes DatabaseSwitch
Examples DatabaseSwitch

Classes

DatabaseSwitch

class DatabaseSwitch : public IDatabase, public UDatabase {
public:
    DatabaseSwitch(class IDatabase * database);
};

Public functions

DatabaseSwitch(class IDatabase * database)
The constructor of the class.

Parameters

class IDatabase * databaseThe IDatabase instance to be used by the switch.

Further functions

All other functions are the functions from IDatabase and can be used in exactly the same manner.

Examples

DatabaseSwitch

class IDatabase * database = databaseProvider->CreateDatabase(iomux, this, this);
class IDatabase * databaseSwitch = new DatabaseSwitch(database); 
databaseSwitch->BeginTransaction(databaseUserA);    // databaseUserA gets the BeginTransactionResult callback
databaseSwitch->ExecSQL(databaseUserB, "...");      // databaseUserB gets the ExecSQLResult callback
databaseSwitch->ExecSQL(databaseUserC, "...");      // databaseUserC gets the ExecSQLResult callback
databaseSwitch->EndTransaction(databaseUserA);      // databaseUserA gets the EndTransactionResult callback