Represents the persistence layer for a database and an object_store.
More...
#include <persistence.hpp>
|
| persistence (const std::string &dns) |
| Creates a new persistence object.
|
|
template<class T > |
void | attach (const char *type, const char *parent=nullptr) |
|
template<class T > |
void | attach_abstract (const char *type, const char *parent=nullptr) |
|
template<class T , class S > |
void | attach (const char *type) |
|
template<class T , class S > |
void | attach_abstract (const char *type) |
|
void | detach (const char *type) |
|
template<class T > |
bool | exists () |
|
void | create () |
| Creates all tables.
|
|
void | drop () |
| Drops all tables.
|
|
void | clear () |
|
t_table_map::iterator | find_table (const std::string &type) |
| Finds a table by its name.
|
|
t_table_map::iterator | begin () |
| Returns the begin of the table map.
|
|
t_table_map::iterator | end () |
| Returns the end of the table map.
|
|
object_store & | store () |
| Return a reference to the underlying object_store.
|
|
const object_store & | store () const |
| Return a const reference to the underlying object_store.
|
|
connection & | conn () |
| Return a reference to the underlying database connection.
|
|
const connection & | conn () const |
| Return a const reference to the underlying database connection.
|
|
void | enable_log () |
|
void | disable_log () |
|
bool | is_log_enabled () const |
|
|
template<class T , class Enabled > |
class | table |
|
template<class T > |
class | persistence_observer |
|
class | session |
|
Represents the persistence layer for a database and an object_store.
This class acts as mediator between the database connection and the object_store. It attaches the object prototypes to the object_store and drops or creates the corresponding tables on the database.
It also holds a map of all created tables, checks if a table exists and is able to clear the object store.
◆ t_table_map
Shortcut to map of table shared pointer
◆ table_ptr
Shortcut to the table shared pointer
◆ persistence()
matador::persistence::persistence |
( |
const std::string & |
dns | ) |
|
|
explicit |
Creates a new persistence object.
Creates a new persistence object for the given database connection string.
- Parameters
-
dns | The database connection string |
◆ attach() [1/2]
template<class T , class S >
void matador::persistence::attach |
( |
const char * |
type | ) |
|
Inserts a new object prototype into the prototype tree. The prototype consists of a unique type name. To know where the new prototype is inserted into the hierarchy the type name of the parent node is also given. parameter.
- Template Parameters
-
T | The type of the prototype node |
S | The type of the parent prototype node |
- Parameters
-
type | The unique name of the type. |
- Returns
- Returns new inserted prototype iterator.
◆ attach() [2/2]
template<class T >
void matador::persistence::attach |
( |
const char * |
type, |
|
|
const char * |
parent = nullptr |
|
) |
| |
Inserts a new object prototype into the prototype tree. The prototype consists of a unique type name. To know where the new prototype is inserted into the hierarchy the type name of the parent node is also given.
- Template Parameters
-
T | The type of the prototype node |
- Parameters
-
type | The unique name of the type. |
parent | The name of the parent type. |
- Returns
- Returns new inserted prototype iterator.
◆ attach_abstract() [1/2]
template<class T , class S >
void matador::persistence::attach_abstract |
( |
const char * |
type | ) |
|
Inserts a new object prototype into the prototype tree. The prototype consists of a unique type name. To know where the new prototype is inserted into the hierarchy the type name of the parent node is also given. parameter.
- Template Parameters
-
T | The type of the prototype node |
S | The type of the parent prototype node |
- Parameters
-
type | The unique name of the type. |
- Returns
- Returns new inserted prototype iterator.
◆ attach_abstract() [2/2]
template<class T >
void matador::persistence::attach_abstract |
( |
const char * |
type, |
|
|
const char * |
parent = nullptr |
|
) |
| |
Inserts a new object prototype into the prototype tree. The prototype consists of a unique type name. To know where the new prototype is inserted into the hierarchy the type name of the parent node is also given.
- Template Parameters
-
T | The type of the prototype node |
- Parameters
-
type | The unique name of the type. |
parent | The name of the parent type. |
- Returns
- Returns new inserted prototype iterator.
◆ begin()
t_table_map::iterator matador::persistence::begin |
( |
| ) |
|
Returns the begin of the table map.
- Returns
- The begin of the table map
◆ clear()
void matador::persistence::clear |
( |
| ) |
|
clears all objects from object store
◆ conn() [1/2]
Return a reference to the underlying database connection.
- Returns
- A reference to the database connection.
◆ conn() [2/2]
const connection & matador::persistence::conn |
( |
| ) |
const |
Return a const reference to the underlying database connection.
- Returns
- A const reference to the database connection.
◆ create()
void matador::persistence::create |
( |
| ) |
|
Creates all tables.
Creates all tables currently attached to the persistence object.
◆ detach()
void matador::persistence::detach |
( |
const char * |
type | ) |
|
Removes an object prototype from the prototype tree. All children nodes and all objects are also removed.
- Parameters
-
type | The name of the type to remove. |
◆ disable_log()
void matador::persistence::disable_log |
( |
| ) |
|
Disable console log of sql statements
◆ drop()
void matador::persistence::drop |
( |
| ) |
|
Drops all tables.
Drops all tables currently attached to the persistence object.
◆ enable_log()
void matador::persistence::enable_log |
( |
| ) |
|
Enable console log of sql statements
◆ end()
t_table_map::iterator matador::persistence::end |
( |
| ) |
|
Returns the end of the table map.
- Returns
- The end of the table map
◆ exists()
template<class T >
bool matador::persistence::exists |
( |
| ) |
|
|
inline |
Checks if the given entity as table exists
- Template Parameters
-
- Returns
- True if table exists
◆ find_table()
t_table_map::iterator matador::persistence::find_table |
( |
const std::string & |
type | ) |
|
Finds a table by its name.
Finds a table by its name. If the name is unknown map::end is returned.
- Parameters
-
type | The name of the table |
- Returns
- The iterator of the table or end
◆ is_log_enabled()
bool matador::persistence::is_log_enabled |
( |
| ) |
const |
Returns true if logging is enabled.
- Returns
- True if logging is enabled
◆ store() [1/2]
◆ store() [2/2]
The documentation for this class was generated from the following file:
- matador/orm/persistence.hpp