Nebula
|
#include <dataset.h>
A dataset is an efficient in-memory-cache for rlational database data.
It is optimized for read/modify/write operations. Usually you tell the dataset object what you want from the database, modify the queried data, and write the queried data back. Datasets can also be used to write new data into the database.
Configuring the dataset:
Add table objects which contain the columns you're interested in. Add an optional Filter object which basically describes a WHERE statement.
Once the dataset has been configured you can fill the dataset with data by either doing a PerformQuery() (which creates a new result ValueTable), or by filling out the ValueTable by hand.
To write modified data in the ValueTable back to the database, invoke the CommitChanges() method. This will try to figure out the most efficient way to write the modified data back into the database.
Inherits Core::RefCounted.
Inherited by Db::Sqlite3Dataset.
Public Member Functions | |
Dataset () | |
constructor | |
virtual | ~Dataset () |
destructor | |
void | AddColumn (const Attr::AttrId &attrId) |
add the columns you're interested in | |
void | AddAllTableColumns () |
add all the table columns to the dataset | |
const Ptr< Table > & | GetTable () const |
get pointer to database table this set is associated with | |
const Ptr< FilterSet > & | Filter () |
access to query filter | |
const Ptr< ValueTable > & | Values () |
access to value table | |
virtual void | PerformQuery (bool appendResult=false) |
fill value table from database | |
virtual void | CommitChanges (bool newRowsAsUpdate=false) |
commit modified values to the database | |
virtual void | CommitDeletedRows () |
commit deleted rows only to the database | |
Public Member Functions inherited from Core::RefCounted | |
RefCounted () | |
constructor | |
int | GetRefCount () const |
get the current refcount | |
void | AddRef () |
increment refcount by one | |
void | Release () |
decrement refcount and destroy object if refcount is zero | |
bool | IsInstanceOf (const Rtti &rtti) const |
return true if this object is instance of given class | |
bool | IsInstanceOf (const Util::String &className) const |
return true if this object is instance of given class by string | |
bool | IsInstanceOf (const Util::FourCC &classFourCC) const |
return true if this object is instance of given class by fourcc | |
bool | IsA (const Rtti &rtti) const |
return true if this object is instance of given class, or a derived class | |
bool | IsA (const Util::String &rttiName) const |
return true if this object is instance of given class, or a derived class, by string | |
bool | IsA (const Util::FourCC &rttiFourCC) const |
return true if this object is instance of given class, or a derived class, by fourcc | |
const Util::String & | GetClassName () const |
get the class name | |
Util::FourCC | GetClassFourCC () const |
get the class FourCC code | |
Protected Member Functions | |
void | SetTable (const Ptr< Table > &t) |
set pointer to database table | |
virtual bool | Connect () |
connect to database table | |
virtual void | Disconnect () |
disconnect from database table | |
bool | IsConnected () const |
return true if the dataset is connected | |
Protected Member Functions inherited from Core::RefCounted | |
virtual | ~RefCounted () |
destructor (called when refcount reaches zero) | |
Protected Attributes | |
bool | isConnected |
Ptr< Table > | table |
Ptr< FilterSet > | filter |
Ptr< ValueTable > | values |
Private Member Functions | |
__DeclareClass (Dataset) | |
Friends | |
class | Table |
Additional Inherited Members | |
Static Public Member Functions inherited from Core::RefCounted | |
static void | DumpRefCountingLeaks () |
dump refcounting leaks, call at end of application (NEBULA_DEBUG builds only!) | |
Db::Dataset::Dataset | ( | ) |
constructor
|
virtual |
destructor
|
private |
void Db::Dataset::AddAllTableColumns | ( | ) |
add all the table columns to the dataset
void Db::Dataset::AddColumn | ( | const Attr::AttrId & | attrId | ) |
add the columns you're interested in
|
virtual |
commit modified values to the database
This will write back any changes in the ValueTable back into the database.
This includes new columns, new rows and modified existing values.
NOTE: the actual functionality of this method should be implemented in a subclass.
Reimplemented in Db::Sqlite3Dataset.
|
virtual |
commit deleted rows only to the database
This will delete all rows marked as deleted from the database.
It is sometimes necessary to perform this operation immediately.
Reimplemented in Db::Sqlite3Dataset.
|
protectedvirtual |
connect to database table
Connect the dataset to the table it is associated with.
A dataset will only be connected to its table during database operations.
Reimplemented in Db::Sqlite3Dataset.
|
protectedvirtual |
disconnect from database table
Disconnect the dataset from the table it is associated with.
This will commit any changes to the value table into the database.
Reimplemented in Db::Sqlite3Dataset.
get pointer to database table this set is associated with
|
inlineprotected |
return true if the dataset is connected
|
virtual |
fill value table from database
This will create a new value table object by performing a query from the database.
The query will be built from the TableColumnPairs, Relations and the optional Filter set on this dataset object. If possible, the previous query will be re-used to save compile time. The query will completely overwrite the current value table.
NOTE: the actual functionality of this method should be implemented in a subclass.
Reimplemented in Db::Sqlite3Dataset.
|
inline |
access to value table
|
friend |
|
protected |
|
protected |