iopc::Driver Class Reference
[iopcdb]

The Driver class is an entry point to a database driver in the IOPC library. More...

#include <driver.h>

Inheritance diagram for iopc::Driver:

Inheritance graph
[legend]

List of all members.

Public Member Functions

const std::string & getName ()
 Returns name of this driver.
DatabasegetDatabase (const std::string &dbName)
 Returns an 'Database' object representing a physical database identified by the dbName in the DBMS.
void returnDatabase (Database *db)
 Deallocates the database object and all related resources.
void init (std::map< std::string, DriverExtension * > &extensions)
 Runs the driver initialization block.
void shutdown ()
 Runs the driver termination block.
template<typename T>
void registerFeature (T &feature)
 Registers a new driver feature with implementation.
void setSupportsFeature (const std::string &feature)
 Registers a new driver feature without implementation.
bool supportsFeature (const std::string &feature)
 Checks if the driver supports a feature identified by the name.
template<typename T>
bool supportsFeature ()
 Checks if the driver supports a feature identified by the template parameter.
template<typename T>
T & getFeature () const
 Returns implementation of the feature T.

Protected Member Functions

 Driver (const std::string &driverName)
 This constructor registers the driver at the DriverManager.
virtual DatabaseImplgetDatabaseImpl (const std::string &dbName)=0
 Each database driver must implement this method which returns implementation of an object representing a database instance.
virtual void returnDatabaseImpl (DatabaseImpl *dbImpl)=0
 DatabaseImpl instances created usign getDatabaseImpl are released using this method.
virtual void doInit ()=0
 Driver initialization routine.
virtual void doShutdown ()=0
 Driver termination routine.


Detailed Description

The Driver class is an entry point to a database driver in the IOPC library.

Drivers are managed by the DriverManager class. A Driver is always implemented as a singleton. Its role is to setup and configure underlying libraries and to provide acces to instance of the Database class.

This class is thread safe and its method can be called by more threads concurrently.


Member Function Documentation

const std::string& iopc::Driver::getName (  )  [inline]

Returns name of this driver.

Returns:
Name of this driver

Database * iopc::Driver::getDatabase ( const std::string &  dbName  ) 

Returns an 'Database' object representing a physical database identified by the dbName in the DBMS.

Just calling getDatabase doesn't create connection to the db, but some drivers may do platform-dependent resource allocation and/or environment preparation here.

Parameters:
dbName Name of the physical database
Returns:
Pointer to the database object. The pointer is owned by the caller and caller is responsible for freeing allocated resources by calling the Driver::returnDatabase(Database* db) when the database is no more needed. The returned object is a super-typed BasicDatabase instance.
See also:
Database

BasicDatabase

void iopc::Driver::returnDatabase ( Database db  ) 

Deallocates the database object and all related resources.

This method accepts also decorated instances returned by the Driver::getDatabase(const std::string& dbName) method. Example:

 Database* db = new CachedDatabase(driver.getDatabase(""), cache);
 ...
 driver.returnDatabase(db);  // deletes CachedDatabase instance

Closes all connections to the db database and destroys the Database instance with all decorators.

Parameters:
db Database to be deallocated.

void iopc::Driver::init ( std::map< std::string, DriverExtension * > &  extensions  ) 

Runs the driver initialization block.

This method is called automatically from inside the iopcdb initialization routine (IopcDb::init()) Calls the doInit() method which must be implemented in the database driver.

See also:
DriverManager::initDrivers()

void iopc::Driver::shutdown (  ) 

Runs the driver termination block.

This method is called automatically from inside the iopcdb termination routine (IopcDb::shutdown()) Calls the doShutdown() method which must be implemented in the database driver.

See also:
DriverManager::terminateDrivers()

template<typename T>
void iopc::Driver::registerFeature ( T &  feature  )  [inline]

Registers a new driver feature with implementation.

Called usually from driver extension's initialization routine (DriverExtension::doInit(Driver& driver))

Parameters:
feature Pointer to a feature that this driver will support. The pointer points directly to the implementation of the feature.
See also:
DbFeature

void iopc::Driver::setSupportsFeature ( const std::string &  feature  )  [inline]

Registers a new driver feature without implementation.

This method is used for setting a flag that the driver supports some feature but the feature doesn't need physical implementation.

Parameters:
feature Name of the supported feature
See also:
DbFeature

bool iopc::Driver::supportsFeature ( const std::string &  feature  )  [inline]

Checks if the driver supports a feature identified by the name.

Returns:
true - supports, false - doesn't support feature identified by the name
Parameters:
feature The name of the feature
See also:
DbFeature

template<typename T>
bool iopc::Driver::supportsFeature (  )  [inline]

Checks if the driver supports a feature identified by the template parameter.

Returns:
true - supports, false - doesn't support the feature
See also:
DbFeature

template<typename T>
T& iopc::Driver::getFeature (  )  const [inline]

Returns implementation of the feature T.

See also:
DbFeature

virtual DatabaseImpl* iopc::Driver::getDatabaseImpl ( const std::string &  dbName  )  [protected, pure virtual]

Each database driver must implement this method which returns implementation of an object representing a database instance.

Parameters:
dbName Name of the database instance. Format is defined by a database driver.
Returns:
Implementation of the DatabaseImpl interface

virtual void iopc::Driver::returnDatabaseImpl ( DatabaseImpl dbImpl  )  [protected, pure virtual]

DatabaseImpl instances created usign getDatabaseImpl are released using this method.

Parameters:
dbImpl The driver implementation object.

virtual void iopc::Driver::doInit (  )  [protected, pure virtual]

Driver initialization routine.

Called from the method DriverManager::initDrivers() which is called from IopcDb::init()

virtual void iopc::Driver::doShutdown (  )  [protected, pure virtual]

Driver termination routine.

Called from the method DriverManager::shutdownDrivers() which is called from IopcDb::shutdown()


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

Generated on Tue Apr 14 16:46:40 2009 for IOPC 2 by  doxygen 1.5.6