Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

Database Class Reference

Abstract class that represents a database. More...

#include <cDatabase.h>

Inheritance diagram for Database:

Inheritance graph
Collaboration diagram for Database:

Collaboration graph
List of all members.

Public Member Functions

 Database (const char *ConnectString=NULL)
virtual ~Database ()
virtual bool Commit ()
virtual bool Rollback ()
virtual class ConnectionConnect (const char *UserName, const char *Password)=0
virtual bool WriteDDL (std::ofstream &S)=0
virtual char * ColumnTypeDDL (char colType, int colLength)=0
virtual bool Assign (const char *ConnectString)
virtual enum UpdatingStrategy CurrentUpdatingStrategy () const
virtual bool SetUpdatingStrategy (enum UpdatingStrategy anUpdateStrategy)
virtual enum WaitingStrategy CurrentWaitingStrategy () const
virtual bool SetWaitingStrategy (enum WaitingStrategy aWaitingStrategy)
virtual enum LockingStrategy CurrentLockingStrategy () const
virtual bool SetLockingStrategy (enum LockingStrategy aLockingStrategy)
virtual enum ReadingStrategy CurrentReadingStrategy () const
virtual bool SetReadingStrategy (enum ReadingStrategy aReadingStrategy)

Protected Member Functions

virtual bool _Commit ()
virtual bool _Rollback ()
bool _FindFreeConnectionHandles (int &LocHandle, int &GlobHandle)
void _DisposeConnectionHandles (int &LocHandle, int &GlobHandle)

Protected Attributes

unsigned short _Strategies
char * _ConnectString
Connection_Connections [MAX_CONNECTION_PER_DATABASE]
int _FirstFreeConnection

Static Protected Attributes

Connection_AllConnections [MAX_CONNECTION]
int _FreeAllConnections [MAX_CONNECTION]
int _FirstFreeAllConnection
bool runAfterConnectHandler = true
int(* afterConnectHandler )(Connection *connection)

Detailed Description

Abstract class that represents a database.

The only "correct" instantiable descendant of this class is currently class Oracle8iDatabase. If you want to implement support for another database please have a look at that class.

This class was nearly undocumented in POLiTe - a few of old comments can be found in source code - not in doxygen. I (Josef Troch) have documented all "interface" (i.e. pure virtual) functions of this class and also put a few words to other important methods. Remaining members were left undocumented.

Methods of this class returns true if OK, false otherwise.

See also:
DatabaseSqlStatements, Connection, Cursor

Constructor & Destructor Documentation

Database::Database const char *  ConnectString = NULL  ) 


ConnectString Service name of database to connect to.

Database::~Database  )  [virtual]

Destructor - disconnects all connections to this database (Connection::Disconnect()).

Member Function Documentation

bool Database::_Commit  )  [protected, virtual]

Performs commit on all connections to the database immediately (modified objects are not saved into DB).

Reimplemented in OracleDatabase.

bool Database::_Rollback  )  [protected, virtual]

Performs rollback on all connections to the database (doesn't destroy copies in memory).

Reimplemented in OracleDatabase.

bool Database::Commit  )  [virtual]

Saves all modified objects to DB, then performs commit on all connections to the database.

Reimplemented in OracleDatabase.

bool Database::Rollback  )  [virtual]

Performs rollback on all connections to the database, then destroys all copies in memory.

Reimplemented in OracleDatabase.

class Connection * Database::Connect const char *  UserName,
const char *  Password
[pure virtual]

Creates new connection to the database

After successful connection this function should call afterConnectHandler if runAfterConnectHandler is set.

Implementation should return ObjLibException_ConnectionError in case of error.

UserName User name to connect as.
Password Password for user UserName.
Created Connection object.

Implemented in OracleDatabase, and Oracle8iDatabase.

virtual bool Database::WriteDDL std::ofstream &  S  )  [pure virtual]

Generates DDL statements needed for old POLiTe style persistence to work

Obsolete function. IopcPersistentObject ancestors don't need this generated DDL statements. So you can make fake implementation of this function if you don't need to support POLiTe-style persistent classes.

S Stream to output DDL statements into.

Implemented in OracleDatabase, and Oracle8iDatabase.

virtual char* Database::ColumnTypeDDL char  colType,
int  colLength
[pure virtual]

Returns correct database column type for given attribute type.

Obsolete function used by POLiTe-style persistent classes. IopcPersistentObject ancestors don't use this function. So you can make fake implementation of this function if you don't need to support POLiTe-style persistent classes.

colType Type of the attribute (TYPE_INT etc.)
colLength Length of the attribute (for int-s etc. sizeof())
See also:

Implemented in OracleDatabase, and Oracle8iDatabase.

bool Database::_FindFreeConnectionHandles int &  LocHandle,
int &  GlobHandle

void Database::_DisposeConnectionHandles int &  LocHandle,
int &  GlobHandle

bool Database::Assign const char *  ConnectString  )  [virtual]

virtual enum UpdatingStrategy Database::CurrentUpdatingStrategy  )  const [inline, virtual]

bool Database::SetUpdatingStrategy enum UpdatingStrategy  anUpdateStrategy  )  [virtual]

virtual enum WaitingStrategy Database::CurrentWaitingStrategy  )  const [inline, virtual]

bool Database::SetWaitingStrategy enum WaitingStrategy  aWaitingStrategy  )  [virtual]

virtual enum LockingStrategy Database::CurrentLockingStrategy  )  const [inline, virtual]

bool Database::SetLockingStrategy enum LockingStrategy  aLockingStrategy  )  [virtual]

virtual enum ReadingStrategy Database::CurrentReadingStrategy  )  const [inline, virtual]

bool Database::SetReadingStrategy enum ReadingStrategy  aReadingStrategy  )  [virtual]

Member Data Documentation

unsigned short Database::_Strategies [protected]

char* Database::_ConnectString [protected]

class Connection* Database::_Connections[MAX_CONNECTION_PER_DATABASE] [protected]

Array of existing connections to this database.

int Database::_FreeConnections[MAX_CONNECTION_PER_DATABASE] [protected]

int Database::_FirstFreeConnection [protected]

Connection * Database::_AllConnections [static, protected]

Array of existing connections to all databases.

int Database::_FreeAllConnections [static, protected]

int Database::_FirstFreeAllConnection [static, protected]

bool Database::runAfterConnectHandler = true [static, protected]

Should afterConnectHandler be used?

Added by Josef Troch.

int(* Database::afterConnectHandler)(Connection *connection)=NULL [static, protected]

Pointer to the function that is executed at the end of Connect() if runAfterConnectHandler is set.

If afterConnectHandler returns 0, runAfterConnectHandler should be set to false.

The documentation for this class was generated from the following files:
Generated on Wed Aug 11 22:35:24 2004 for IOPC by Doxygen 1.3.6