Frontend class to make the objects persistent. More...
#include <session.hpp>
Public Member Functions | |
session (object_store &ostore, const std::string &dbstring="memory://") | |
Creates a session frontend for an object_store and a specific database. More... | |
void | open () |
Opens the database. More... | |
bool | is_open () const |
Returns true if database is open. More... | |
void | create () |
Creates the database. More... | |
void | drop () |
Drops all tables. More... | |
void | close () |
Closes the database. More... | |
bool | load () |
Load all objects from the database. More... | |
result * | execute (const std::string &sql) |
Executes a database query. More... | |
template<class T > | |
object_ptr< T > | insert (T *o) |
Inserts a new object. More... | |
void | update (const object_base_ptr &optr) |
Updates a given persistent object. More... | |
void | remove (object_base_ptr &optr) |
Deletes a given persistent object. More... | |
object_store & | ostore () |
const object_store & | ostore () const |
transaction * | current_transaction () const |
const database & | db () const |
database & | db () |
Friends | |
class | transaction |
class | statement |
class | query |
Detailed Description
Frontend class to make the objects persistent.
This class is the frontend to any database made available by a concrete database implementation. All objects in the given object_store will be made persistent.
Constructor & Destructor Documentation
oos::session::session | ( | object_store & | ostore, |
const std::string & | dbstring = "memory://" |
||
) |
Creates a session frontend for an object_store and a specific database.
This constructor creates a connection between an object_store and a specific database identified by a database connection string.
- Parameters
-
ostore The object_store to make persistent. dbstring The database connection string.
Member Function Documentation
void oos::session::close | ( | ) |
Closes the database.
Closes the database.
void oos::session::create | ( | ) |
Creates the database.
Try to create the database and all tables described in the object_store. If database already exists an exception is thrown. Once the database is created it is also opened.
transaction* oos::session::current_transaction | ( | ) | const |
Return the current transaction from the stack.
- Returns
- The current transaction.
const database& oos::session::db | ( | ) | const |
Returns a constant reference to the session underlaying database.
- Returns
- The underlaying database.
database& oos::session::db | ( | ) |
Returns a reference to the session underlaying database.
- Returns
- The underlaying database.
void oos::session::drop | ( | ) |
Drops all tables.
When called all tables of the database are dropped and all data is lost.
result* oos::session::execute | ( | const std::string & | sql | ) |
Executes a database query.
Executes the given query on the database and return the result in a query_result object.
- Parameters
-
sql The database query to execute.
- Returns
- The result of the query.
|
inline |
Inserts a new object.
- Template Parameters
-
T Type of object
Inserts a new not inserted object into object store and persists it on database
- Parameters
-
o The object to insert.
- Returns
- The inserted persistent object.
bool oos::session::is_open | ( | ) | const |
Returns true if database is open.
Returns true if database is open
- Returns
- True on open database.
bool oos::session::load | ( | ) |
Load all objects from the database.
Load all data into the object_store registered objects from the database. If the operation succeeds true is returned. If a table layoput doesn't match to the corresponding objects layout an excpetion is thrown.
- Returns
- Returns true on successful loading.
void oos::session::open | ( | ) |
Opens the database.
Opens the database. If database couldn't be opened an exception is thrown.
object_store& oos::session::ostore | ( | ) |
Returns the object_store.
const object_store& oos::session::ostore | ( | ) | const |
Returns the object_store.
void oos::session::remove | ( | object_base_ptr & | optr | ) |
Deletes a given persistent object.
Deletes a persistent object in object store and on database.
- Parameters
-
optr The object to delete
void oos::session::update | ( | const object_base_ptr & | optr | ) |
Updates a given persistent object.
- Template Parameters
-
T Type of object tp update.
Updates a persistent object in object store and on database.
- Parameters
-
optr The object to update
The documentation for this class was generated from the following file:
- database/session.hpp