SQLArchive Class Reference
[Public API]

SQL-database archive of objects. More...

#include <sqlarchive.h>

Inheritance diagram for SQLArchive:

Inheritance graph
[legend]
Collaboration diagram for SQLArchive:

Collaboration graph
[legend]
List of all members.

Public Member Functions

int getAvailableConnections () const
 Get number of connections that are available for streams and getConnection() function.
DbConnectiongetConnection ()
 Get connection from archive.
virtual const ConvSpecgetConversionSpecs () const
 Get current conversion specification from internal database object.
DatabasegetDatabase ()
 Get pointer to database that archive is using.
SQLIdFetchergetIdFetcher () const
 Get associated id fetcher or NULL if none was set.
virtual IStreamgetInputStream ()
 Create input stream.
SQLIStream getIStream ()
 Create SQLIStream using one connection from pool.
SQLOStream getOStream ()
 Create output stream using one connection from pool.
virtual OStreamgetOutputStream ()
 Create output stream.
std::list< std::string > getTableNames ()
 Get list of available tables.
int getUsedConnections () const
 Get number of currently used connections.
void initPlugin (const char *pPluginName)
 Initialize internal plugin and create database instance owned by SQLArchive.
bool isDatabaseOwner () const
 Check if this instance owns mDb.
virtual bool isOpen () const
 Check if archive is open.
void open (const char *pPluginName, const char *pConnectString)
 Load database plugin, check its version, initialize it and connect to database using pConnectString argument.
virtual void open (const char *pConnectString)
 Connect to already initialized database.
virtual void setConversionSpecs (const ConvSpec &pSpecs)
 Set new conversion specification for archive.
void setDatabase (Database *pDb)
 Set database plugin for archive.
void setIdFetcher (SQLIdFetcher *pFetcher)
 Set fetcher on archive.
 SQLArchive (Database *pDb=NULL)
 Constructor.
virtual ~SQLArchive ()
 Destructor.

Static Public Member Functions

static bool handleError (void *pOwner, int pType, const char *pMsg)
 default error handler for archive.

Protected Member Functions

void closeAllConnections ()
 close all connections to database
void destroyPlugin ()
 close all connnections and delete mPlugin and mDb (if owned, see mPlugin description)
DbConnectiongetFreeConnection (bool pRelease=false)
 Get or allocate new connection.

Protected Attributes

std::list< DbConnection * > mConnections
 List of open connections.
std::string mConnectStr
 Connect string used to create new connection.
DatabasemDb
 Pointer to internal database object.
SQLIdFetchermFetcher
 SQLFetcher.
DbPluginmPlugin
 Plugin loaded for database object creation - NULL if database is set using constructor or setDatabase function.

Detailed Description

SQL-database archive of objects.

This should store binded var in the youngest child table


Constructor & Destructor Documentation

SQLArchive Database pDb = NULL  ) 
 

Constructor.

Archive does not take ownership on passed Database pointer, you have to delete it using DbPlugin instance that was used to load it.

See also:
open(const char* pPluginName, const char* pConnectString) for better alternative
Parameters:
pDb sql database driver for archive

Member Function Documentation

DbConnection* getConnection  ) 
 

Get connection from archive.

If all connections are used then new connection will be created using ConnectString passed to open().

Warning:
returned connection is removed from connection pool managed by SQLArchive - you need to close and delete it yourself.
Returns:
DbConnection instance

DbConnection* getFreeConnection bool  pRelease = false  )  [protected]
 

Get or allocate new connection.

Parameters:
pRelease if true then remove connection from connection pool

virtual IStream* getInputStream  )  [virtual]
 

Create input stream.

Returned value must be deleted

Returns:
IStream

Implements Archive.

SQLIStream getIStream  ) 
 

Create SQLIStream using one connection from pool.

If you want to load and store objects using single connection then consider using Transaction and create streams from there.

Returns:
Object Input Stream

SQLOStream getOStream  ) 
 

Create output stream using one connection from pool.

Returns:
Object Output Stream

virtual OStream* getOutputStream  )  [virtual]
 

Create output stream.

Returned value must be deleted

Returns:
IStream

Implements Archive.

std::list<std::string> getTableNames  ) 
 

Get list of available tables.

Must be called after open()

Returns:
list of names of available SQL tables

static bool handleError void *  pOwner,
int  pType,
const char *  pMsg
[static]
 

default error handler for archive.

It throws SQLException or DatabaseException depends on error type.

Parameters:
pOwner not used
pType type of error
pMsg error description from Database plugin
See also:
errorHandlerFunc

void initPlugin const char *  pPluginName  ) 
 

Initialize internal plugin and create database instance owned by SQLArchive.

Used by open(const char* pPluginName, const char* pConnectString)

Parameters:
pPluginName name of plugin library to load

virtual bool isOpen  )  const [virtual]
 

Check if archive is open.

Returns:
true if archive is open or false otherwise.

Implements Archive.

void open const char *  pPluginName,
const char *  pConnectString
 

Load database plugin, check its version, initialize it and connect to database using pConnectString argument.

Parameters:
pPluginName name of plugin without extension
pConnectString plugin-specific database connection description
See also:
Driver notes for connect string description

virtual void open const char *  pConnectString  )  [virtual]
 

Connect to already initialized database.

You have to set database first to use this function, or (better) use open(pPluginName, pConnectString), which will load plugin and create database automatically.

Parameters:
pConnectString ConnectString as string
See also:
open(pPluginName, pConnectString) for better alternative

Implements Archive.

virtual void setConversionSpecs const ConvSpec pSpecs  )  [virtual]
 

Set new conversion specification for archive.

Call to this method will update conversion specification on internal database object and all connections to database that are managed by this archive

Parameters:
pSpecs new conversion specification

void setDatabase Database pDb  ) 
 

Set database plugin for archive.

Must be called on closed archive. Archive does not take ownership on this pointer, you have to delete it using DbPlugin instance that was used to load it.

See also:
open(const char* pPluginName, const char* pConnectString) for better alternative
Parameters:
pDb database loaded using DbPlugin

void setIdFetcher SQLIdFetcher pFetcher  ) 
 

Set fetcher on archive.

Parameters:
pFetcher new id fetcher

Member Data Documentation

SQLIdFetcher* mFetcher [protected]
 

SQLFetcher.

Must not be NULL when streams are created.

DbPlugin* mPlugin [protected]
 

Plugin loaded for database object creation - NULL if database is set using constructor or setDatabase function.

NULL value also means that we are not owner of mDb pointer


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

Documentation
Quick start
Examples
Search

API Documentation
Class hierarchy
Member index
API Reference
Store filters
Store table macros
Back

Generated by doxygen at Sun Nov 9 02:08:24 2008