Implementation of a StorageManager with an underlying SQL database. More...
#include <SQLStore.h>
Public Member Functions | |
SQLStore (const char *table_name, oasys::SQLImplementation *db) | |
Create a SQLStore with specfied table_name. | |
| |
const char * | table_name_ |
Name of the table in the database to which this SQLStore corresponds. | |
const char * | key_name_ |
Field name by which the objects are keyed. | |
oasys::SQLImplementation * | sql_impl_ |
Name of the table in the database to which this SQLStore corresponds. | |
int | close () |
Close the table. | |
int | get (oasys::SerializableObject *obj, const int key) |
Get an obj (identified by key) from the sql store. | |
int | put (oasys::SerializableObject *obj, const int key) |
Store the object with the given key. | |
int | add (oasys::SerializableObject *obj, const int key) |
Put an obj in the sql store. | |
int | update (oasys::SerializableObject *obj, const int key) |
Update the object's state in the sql store. | |
int | del (const int key) |
Delete an obj (identified by key). | |
int | num_elements () |
Return number of elements in the store. | |
void | keys (std::vector< int > *l) |
Return list of keys for all elements in the store. | |
int | exists (const int id) |
Name of the table in the database to which this SQLStore corresponds. | |
int | elements (oasys::SerializableObjectVector *elements) |
Extract all elements from the store, potentially matching the "where" clause. | |
const char * | table_name () |
Returns the table name associated with this store. | |
bool | has_table (const char *name) |
Checks if the table already exists. | |
int | create_table (oasys::SerializableObject *obj) |
Creates table a table in the store for objects which has the same type as obj. | |
int | exec_query (const char *query) |
Executes the given query. | |
void | set_key_name (const char *name) |
Set's the key name. |
Implementation of a StorageManager with an underlying SQL database.
Definition at line 33 of file SQLStore.h.
dtn::SQLStore::SQLStore | ( | const char * | table_name, | |
oasys::SQLImplementation * | db | |||
) |
Create a SQLStore with specfied table_name.
Parameter db, points to the actual implementation to which different queries are forwarded
int dtn::SQLStore::add | ( | oasys::SerializableObject * | obj, | |
const int | key | |||
) | [virtual] |
int dtn::SQLStore::close | ( | ) | [virtual] |
Close the table.
Implements dtn::PersistentStore.
int dtn::SQLStore::create_table | ( | oasys::SerializableObject * | obj | ) |
Creates table a table in the store for objects which has the same type as obj.
Checks if the table already exists.
int dtn::SQLStore::del | ( | const int | key | ) | [virtual] |
Delete an obj (identified by key).
Implements dtn::PersistentStore.
int dtn::SQLStore::elements | ( | oasys::SerializableObjectVector * | elements | ) |
Extract all elements from the store, potentially matching the "where" clause.
For each matching element, initialize the corresponding object in the vector with the values from the database.
int dtn::SQLStore::exec_query | ( | const char * | query | ) |
Executes the given query.
Essentially forwards the query to data_base_pointer_
int dtn::SQLStore::exists | ( | const int | id | ) |
Name of the table in the database to which this SQLStore corresponds.
int dtn::SQLStore::get | ( | oasys::SerializableObject * | obj, | |
const int | key | |||
) | [virtual] |
Get an obj (identified by key) from the sql store.
Implements dtn::PersistentStore.
bool dtn::SQLStore::has_table | ( | const char * | name | ) |
Checks if the table already exists.
void dtn::SQLStore::keys | ( | std::vector< int > * | l | ) | [virtual] |
Return list of keys for all elements in the store.
Implements dtn::PersistentStore.
int dtn::SQLStore::num_elements | ( | ) | [virtual] |
Return number of elements in the store.
Implements dtn::PersistentStore.
int dtn::SQLStore::put | ( | oasys::SerializableObject * | obj, | |
const int | key | |||
) |
Store the object with the given key.
void dtn::SQLStore::set_key_name | ( | const char * | name | ) |
Set's the key name.
The key name is used in all functions which need to create a query which refers to key. Must be initialized for proper operation.
const char* dtn::SQLStore::table_name | ( | ) |
Returns the table name associated with this store.
int dtn::SQLStore::update | ( | oasys::SerializableObject * | obj, | |
const int | key | |||
) | [virtual] |
Update the object's state in the sql store.
Implements dtn::PersistentStore.
const char* dtn::SQLStore::key_name_ [private] |
Field name by which the objects are keyed.
Definition at line 148 of file SQLStore.h.
oasys::SQLImplementation* dtn::SQLStore::sql_impl_ [private] |
Name of the table in the database to which this SQLStore corresponds.
Definition at line 150 of file SQLStore.h.
const char* dtn::SQLStore::table_name_ [private] |
Name of the table in the database to which this SQLStore corresponds.
Definition at line 143 of file SQLStore.h.