Nebula
Loading...
Searching...
No Matches
Db::Dataset Class Reference

#include <dataset.h>

Detailed Description

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::StringGetClassName () 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< Tabletable
 
Ptr< FilterSetfilter
 
Ptr< ValueTablevalues
 

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!)
 

Constructor & Destructor Documentation

◆ Dataset()

Db::Dataset::Dataset ( )

constructor

◆ ~Dataset()

Db::Dataset::~Dataset ( )
virtual

destructor

Member Function Documentation

◆ __DeclareClass()

Db::Dataset::__DeclareClass ( Dataset )
private

◆ AddAllTableColumns()

void Db::Dataset::AddAllTableColumns ( )

add all the table columns to the dataset

◆ AddColumn()

void Db::Dataset::AddColumn ( const Attr::AttrId & attrId)

add the columns you're interested in

◆ CommitChanges()

void Db::Dataset::CommitChanges ( bool newRowsAsUpdate = false)
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.

◆ CommitDeletedRows()

void Db::Dataset::CommitDeletedRows ( )
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.

◆ Connect()

bool Db::Dataset::Connect ( )
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.

◆ Disconnect()

void Db::Dataset::Disconnect ( )
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.

◆ Filter()

const Ptr< FilterSet > & Db::Dataset::Filter ( )
inline

access to query filter

◆ GetTable()

const Ptr< Table > & Db::Dataset::GetTable ( ) const
inline

get pointer to database table this set is associated with

◆ IsConnected()

bool Db::Dataset::IsConnected ( ) const
inlineprotected

return true if the dataset is connected

◆ PerformQuery()

void Db::Dataset::PerformQuery ( bool appendResult = false)
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.

◆ SetTable()

void Db::Dataset::SetTable ( const Ptr< Table > & t)
inlineprotected

set pointer to database table

◆ Values()

const Ptr< ValueTable > & Db::Dataset::Values ( )
inline

access to value table

Friends And Related Symbol Documentation

◆ Table

friend class Table
friend

Member Data Documentation

◆ filter

Ptr<FilterSet> Db::Dataset::filter
protected

◆ isConnected

bool Db::Dataset::isConnected
protected

◆ table

Ptr<Table> Db::Dataset::table
protected

◆ values

Ptr<ValueTable> Db::Dataset::values
protected

The documentation for this class was generated from the following files: