iopc::CachedConnection Class Reference
[iopclib]

A Connection decorator which makes the Connection interface cache aware. More...

#include <cachedConnection.h>

Inheritance diagram for iopc::CachedConnection:

Inheritance graph
[legend]

List of all members.

Public Member Functions

void stopCache ()
 Empties and stops the associated cache.
void restartCache ()
 Starts the stopped cache.
virtual ~CachedConnection ()
 Deletes the inner (decorated) Connection instance and the associated Cache.
virtual Cursorsql (const std::string &name)
 Calls Cache::updateDirty() before performing Cursor::sql().
virtual CursorsqlNoCache (const std::string &name)
 Executes an SQL statement while not notifying the associated cache.
virtual void returnCursor (Cursor *cur)
 Cursors that are no longer needed should be returned to the driver Connection object using this method.
virtual void closeAllCursors ()
 Closes and returns all cursors on this connection.
virtual void sqlNonQuery (const std::string &name)
 Calls Cache::updateDirty() before performing Cursor::sqlNonQuery().
virtual void sqlNonQueryNoCache (const std::string &name)
 Executes an SQL statement while not notifying the associated cache.
virtual void commit ()
 Calls Cache::updateDirty() before performing Cursor::commit().
virtual void rollback ()
 Calls Cache::removeAll() before performing Cursor::rollback().
virtual void savepoint (const std::string &name)
 Calls Cache::updateDirty() before performing Cursor::savepoint().
virtual void rollbackToSavepoint (const std::string &name)
 Calls Cache::removeAll() before performing Cursor::rollbackToSavepoint().
virtual void open ()
 Opens the connection.
virtual void close ()
 Closes the connection.
virtual void disconnect ()
 Commits last transaction and closes the connection.
virtual void abort ()
 Rolls back current transaction and closes the connection.
virtual void setAutoCommit (bool ac)
 Turns autocommit on this connection on or off.
virtual bool isOpened ()
 Determines whether this connection is opened or not.
virtual Connectionoperator<< (const std::string &command)
 Shortcut for sqlNonQuery.
DatabasegetDatabase ()
 Returns the associated Database object.
DrivergetDriver ()
 Returns the database driver used.
virtual void updateDirty ()
 Invokes Cache::updateDirty() on the associated Cache.
virtual void removeAll ()
 Invokes Cache::removeAll() on the associated Cache.
ConnectionImplgetImplementation ()
 Returns the driver-side part of the Connection implemenation.
virtual ConnectiongetBasicConnection ()
 Returns the driver-independent part of the Connection implementation.
CacheLockmakePersistent (const PersIdentification &persId, DatabaseObject &objectPtr)
 Transfers the referenced object ownership to the associated cache.
CacheLockgetCacheLock (const PersIdentification &persId, bool rdonly=false)
 Locks the specified object in the associated cache.
void dbDelete (const PersIdentification &persId)
 Removes a persistent object identified by persId from database and from an associated cache.
void cacheDelete (const PersIdentification &persId)
 Hints cache to drop its copy of the object identified by persId.
virtual ConnectiongetInnerConnection ()
 Returns the decorated connection.
CachegetCache ()
 Returns the associated cache.


Detailed Description

A Connection decorator which makes the Connection interface cache aware.

Each instance of CachedConnection has an associated Cache. Behaviour of most of the Connection methods is modified to notify the cache on various events. For example it tells the cache that it should write all cached local copies into database before commit is performed. It also provides several proxy methods such as dbDelete(), cacheDelete(), makePersistent(), getCacheLock() that invoke corresponding actions on the associated cache.


Member Function Documentation

void iopc::CachedConnection::stopCache (  ) 

Empties and stops the associated cache.

Author:
Jan hadrava

void iopc::CachedConnection::restartCache (  ) 

Starts the stopped cache.

Author:
Jan hadrava

Cursor * iopc::CachedConnection::sql ( const std::string &  name  )  [virtual]

Calls Cache::updateDirty() before performing Cursor::sql().

See also:
Cursor::sql()

Implements iopc::Connection.

Cursor * iopc::CachedConnection::sqlNoCache ( const std::string &  name  )  [virtual]

Executes an SQL statement while not notifying the associated cache.

See also:
sql()

void iopc::CachedConnection::returnCursor ( Cursor cur  )  [virtual]

Cursors that are no longer needed should be returned to the driver Connection object using this method.

All resources allocated by the Cursor are released.

Implements iopc::Connection.

void iopc::CachedConnection::sqlNonQuery ( const std::string &  name  )  [virtual]

Calls Cache::updateDirty() before performing Cursor::sqlNonQuery().

See also:
Cursor::sql()

Implements iopc::Connection.

void iopc::CachedConnection::sqlNonQueryNoCache ( const std::string &  name  )  [virtual]

Executes an SQL statement while not notifying the associated cache.

See also:
sqlNonQuery()

void iopc::CachedConnection::commit (  )  [virtual]

Calls Cache::updateDirty() before performing Cursor::commit().

See also:
Cursor::commit()

Implements iopc::Connection.

void iopc::CachedConnection::rollback (  )  [virtual]

Calls Cache::removeAll() before performing Cursor::rollback().

See also:
Cursor::rollback()

Implements iopc::Connection.

void iopc::CachedConnection::savepoint ( const std::string &  name  )  [virtual]

Calls Cache::updateDirty() before performing Cursor::savepoint().

See also:
Cursor::savepoint()

Implements iopc::Connection.

void iopc::CachedConnection::rollbackToSavepoint ( const std::string &  name  )  [virtual]

Calls Cache::removeAll() before performing Cursor::rollbackToSavepoint().

See also:
Cursor::rollbackToSavepoint()

Implements iopc::Connection.

void iopc::CachedConnection::open (  )  [virtual]

Opens the connection.

This call opens a physical link to the DBMS

Implements iopc::Connection.

void iopc::CachedConnection::close (  )  [virtual]

Closes the connection.

This call should close the physical link to the DBMS

Implements iopc::Connection.

void iopc::CachedConnection::disconnect (  )  [virtual]

Commits last transaction and closes the connection.

The connection still needs to be returned to associated Database object

Implements iopc::Connection.

void iopc::CachedConnection::setAutoCommit ( bool  ac  )  [virtual]

Turns autocommit on this connection on or off.

Parameters:
ac - true - autocommit is enabled, false - autocommit is disabled

Implements iopc::Connection.

virtual void iopc::CachedConnection::updateDirty (  )  [inline, virtual]

Invokes Cache::updateDirty() on the associated Cache.

Synchronizes the state of cache and DB by updating the DB.

virtual void iopc::CachedConnection::removeAll (  )  [inline, virtual]

Invokes Cache::removeAll() on the associated Cache.

Synchronizes the state of cache and DB by discarding all managed object (no modifications are written to the DB).

CacheLock & iopc::CachedConnection::makePersistent ( const PersIdentification persId,
DatabaseObject objectPtr 
)

Transfers the referenced object ownership to the associated cache.

Parameters:
persId Identity of the object
objectPtr The persistent object

CacheLock & iopc::CachedConnection::getCacheLock ( const PersIdentification persId,
bool  rdonly = false 
)

Locks the specified object in the associated cache.

Parameters:
persId Identity of the object to be locked
rdonly Determines if a shared read-only lock should be placed on the object in the cache.


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

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