Logo Search packages:      
Sourcecode: poco version File versions  Download package

Poco::Data::SessionFactory Class Reference

#include <SessionFactory.h>

List of all members.

Detailed Description

A SessionFactory is a singleton class that stores Connectors and allows to create Sessions of the required type:

Session ses(SessionFactory::instance().create(connector, connectionString));

where the first param presents the type of session one wants to create (e.g. for SQLite one would choose "SQLite") and the second param is the connection string that the connector requires to connect to the database.

A concrete example to open an SQLite database stored in the file "dummy.db" would be

Session ses(SessionFactory::instance().create(SQLite::Connector::KEY, "dummy.db"));

An even simpler way to create a session is to use the two argument constructor of Session, which automatically invokes the SessionFactory:

Session ses("SQLite", "dummy.db");

Definition at line 55 of file SessionFactory.h.

Public Member Functions

void add (const std::string &key, Connector *pIn)
 returns the static instance of the singleton.
Session create (const std::string &key, const std::string &connectionString)
void remove (const std::string &key)

Static Public Member Functions

static SessionFactoryinstance ()

Private Types

typedef std::map< std::string,
SessionInfo > 

Private Member Functions

SessionFactoryoperator= (const SessionFactory &)
 SessionFactory (const SessionFactory &)
 SessionFactory ()

Private Attributes

Connectors _connectors
Poco::FastMutex _mutex


struct  SessionInfo

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

Generated by  Doxygen 1.6.0   Back to index