dtn::SQLStore Class Reference

#include <SQLStore.h>

Inheritance diagram for dtn::SQLStore:

dtn::PersistentStore oasys::Logger

List of all members.


Detailed Description

Implementation of a StorageManager with an underlying SQL database.

Definition at line 33 of file SQLStore.h.

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::SQLImplementationsql_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.

Public Member Functions

 SQLStore (const char *table_name, oasys::SQLImplementation *db)
 Create a SQLStore with specfied table_name.

Constructor & Destructor Documentation

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


Member Function Documentation

int dtn::SQLStore::close (  )  [virtual]

Close the table.

Implements dtn::PersistentStore.

int dtn::SQLStore::get ( oasys::SerializableObject obj,
const int  key 
) [virtual]

Get an obj (identified by key) from the sql store.

Returns:
0 if success, -1 on error

Implements dtn::PersistentStore.

int dtn::SQLStore::put ( oasys::SerializableObject obj,
const int  key 
)

Store the object with the given key.

int dtn::SQLStore::add ( oasys::SerializableObject obj,
const int  key 
) [virtual]

Put an obj in the sql store.

Returns:
0 if success, -1 on error

Implements dtn::PersistentStore.

int dtn::SQLStore::update ( oasys::SerializableObject obj,
const int  key 
) [virtual]

Update the object's state in the sql store.

Returns:
number updated on success, -1 on error

Implements dtn::PersistentStore.

int dtn::SQLStore::del ( const int  key  )  [virtual]

Delete an obj (identified by key).

Returns:
0 if success, -1 on error

Implements dtn::PersistentStore.

int dtn::SQLStore::num_elements (  )  [virtual]

Return number of elements in the store.

Returns:
number of elements if success, -1 on error

Implements dtn::PersistentStore.

void dtn::SQLStore::keys ( std::vector< int > *  l  )  [virtual]

Return list of keys for all elements in the store.

Returns:
0 if success, -1 on error

Implements dtn::PersistentStore.

int dtn::SQLStore::exists ( const int  id  ) 

Name of the table in the database to which this SQLStore corresponds.

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.

Returns:
count of extracted elements, or -1 on error

const char* dtn::SQLStore::table_name (  ) 

Returns the table name associated with this store.

bool dtn::SQLStore::has_table ( const char *  name  ) 

Checks if the table already exists.

Returns:
true if table exits, false otherwise

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.

Returns:
0 if success, -1 on error

int dtn::SQLStore::exec_query ( const char *  query  ) 

Executes the given query.

Essentially forwards the query to data_base_pointer_

Returns:
0 if success, -1 on error

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.


Member Data Documentation

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.

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.


The documentation for this class was generated from the following file:
Generated on Sat Sep 8 08:36:23 2007 for DTN Reference Implementation by  doxygen 1.5.3