SQLArchive Class ReferenceArchive of objects stored in SQL database.
More...
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Public Member Functions | |
| int | getAvailableConnections () const |
| Get number of connections that are available for streams and getConnection() function. | |
| DbConnection * | getConnection () |
| Get connection from archive. | |
| virtual const ConvSpec & | getConversionSpecs () const |
| Get current conversion specification from internal database object. | |
| Database * | getDatabase () |
| Get pointer to database that archive is using. | |
| SQLIdFetcher * | getIdFetcher () const |
| Get associated id fetcher or NULL if none was set. | |
| virtual IStream * | getInputStream () |
| Create input stream. | |
| SQLIStream | getIStream () |
| Create SQLIStream using one connection from pool. | |
| SQLOStream | getOStream () |
| Create output stream using one connection from pool. | |
| virtual OStream * | getOutputStream () |
| 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 | mapType (const std::type_info &pType, StoreableFilterBase *pFilter) |
| Change default filter for given C++ type. | |
| 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) | |
| DbConnection * | getFreeConnection (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. | |
| Database * | mDb |
| Pointer to internal database object. | |
| SQLIdFetcher * | mFetcher |
| SQLFetcher. | |
| FilterMapper | mFilterMapper |
| Mappings for creating SQL queries from SQL object in streams. | |
| DbPlugin * | mPlugin |
| Plugin loaded for database object creation - NULL if database is set using constructor or setDatabase function. | |
Detailed Description
Archive of objects stored in SQL database.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] |
| 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 | ( | ) |
| virtual OStream* getOutputStream | ( | ) | [virtual] |
| 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] |
| void mapType | ( | const std::type_info & | pType, | |
| StoreableFilterBase * | pFilter | |||
| ) |
Change default filter for given C++ type.
Used when sending SQL queries using streams. New mapping for the same C++ type will replace existing one.
- Parameters:
-
pType C++ type returned by typeid() pFilter New default filter to use
| 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.
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 |
| API Documentation |
|---|
| Class hierarchy |
| Member index |
| API Reference |
| Store filters |
| Store table macros |
Generated by doxygen at Fri Oct 22 23:15:46 2010


