Nebula
|
#include <table.h>
Describes a table in a database, or more abstract, a set of typed columns grouped under a common name.
Note that a table object is only a descriptor of the table layout, it never contains any actual data. If the table is attached to a database, any changes to the Table object will also lead to changes in the database (changes are batched until a CommitChanges() is invoked).
Inherits Core::RefCounted.
Inherited by Db::Sqlite3Table.
Public Types | |
enum | ConnectMode { ForceCreate , AssumeExists , Default } |
connection modes More... | |
Public Member Functions | |
Table () | |
constructor | |
virtual | ~Table () |
destructor | |
virtual void | SetName (const Util::String &n) |
set name of table | |
const Util::String & | GetName () const |
get name of table | |
bool | IsConnected () const |
return true if the table is connected to a database | |
const Ptr< Database > & | GetDatabase () const |
get pointer to database this table is connected to | |
virtual void | CreateMultiColumnIndex (const Util::Array< Attr::AttrId > &columnIds) |
create a complex multicolumn index on a connected table | |
virtual Ptr< Dataset > | CreateDataset () |
create a dataset associated with this table | |
virtual void | CommitChanges (bool resetModifiedState=true, bool useTransaction=true) |
commit any changes (add columns, insert new rows, update modified rows) | |
bool | HasUncommittedColumns () const |
check if there are any uncommitted columns in the table | |
virtual void | CommitUncommittedColumns () |
commit uncommitted columns only | |
virtual void | CommitDeletedRows () |
commit deleted rows only | |
void | AddColumn (const Column &c) |
add a column to the table | |
SizeT | GetNumColumns () const |
get number of columns in table | |
const Column & | GetColumn (IndexT i) const |
get column at index | |
bool | HasColumn (const Attr::AttrId &id) const |
return true if a column exists by attribute id | |
bool | HasColumn (const Util::String &name) const |
return true if a column exists by name | |
bool | HasColumn (const Util::FourCC &fcc) const |
return true if a column exists by fourCC | |
const Column & | GetColumn (const Attr::AttrId &id) const |
get a column by attribute id | |
const Column & | GetColumn (const Util::String &name) const |
get a column by name | |
const Column & | GetColumn (const Util::FourCC &fcc) const |
get a column by fourCC | |
const Util::Array< Column > & | GetColumns () const |
get all columns in the table | |
bool | HasPrimaryColumn () const |
return true if a primary key column exists | |
const Column & | GetPrimaryColumn () const |
get the primary key column, fails hard if none exists | |
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 | |
virtual void | Connect (const Ptr< Database > &db, ConnectMode connectMode=Default, bool ignoreUnknownColumns=false) |
connect the table object with a database | |
virtual void | Disconnect (bool dropTable=false) |
disconnect the table from a database, optionally remove table from database as well | |
virtual void | BindValueTable (const Ptr< ValueTable > &valueTable) |
bind a value table to the table object, unbinds previous table | |
virtual void | UnbindValueTable () |
unbind current value table from the table object, commits any changes to the database | |
Protected Member Functions inherited from Core::RefCounted | |
virtual | ~RefCounted () |
destructor (called when refcount reaches zero) | |
Protected Attributes | |
bool | isConnected |
Ptr< Database > | database |
Ptr< ValueTable > | valueTable |
Util::String | name |
Util::Array< Column > | columns |
Util::HashTable< Util::String, IndexT > | nameIndexMap |
Util::Dictionary< Util::FourCC, IndexT > | fourccIndexMap |
Util::Dictionary< Attr::AttrId, IndexT > | attrIdIndexMap |
IndexT | primaryColumnIndex |
Private Member Functions | |
__DeclareClass (Table) | |
Friends | |
class | Database |
class | Dataset |
class | Writer |
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::Table::Table | ( | ) |
constructor
|
virtual |
destructor
|
private |
void Db::Table::AddColumn | ( | const Column & | col | ) |
add a column to the table
Add a new column to the table.
The change will not be synchronised with the database until a CommitChanges() is called on the Table object.
|
protectedvirtual |
bind a value table to the table object, unbinds previous table
Bind a value table to the table object.
A value table represents actual values in the table, adding, removing or modifying rows on a value table will be reflected automatically in the database. Only one value table may be bound at any time!
Reimplemented in Db::Sqlite3Table.
|
virtual |
commit any changes (add columns, insert new rows, update modified rows)
Commit any changes to the database:
Reimplemented in Db::Sqlite3Table.
|
virtual |
commit deleted rows only
Immediately delete rows of the connected dataset from the database.
Reimplemented in Db::Sqlite3Table.
|
virtual |
commit uncommitted columns only
Commit uncommitted columns to the database, this does not write any data to the database, just change the table layout.
Reimplemented in Db::Sqlite3Table.
|
protectedvirtual |
connect the table object with a database
Connect the table with a database:
Reimplemented in Db::Sqlite3Table.
create a dataset associated with this table
Create a dataset associated with this table.
|
virtual |
create a complex multicolumn index on a connected table
This method should be used to create multicolumn indices on the table.
The table must be connected for this method to work!
Reimplemented in Db::Sqlite3Table.
|
protectedvirtual |
disconnect the table from a database, optionally remove table from database as well
Disconnect the table with a database.
If the dropTable argument is true (default is false), the actual database table will be deleted from the database as well. If dropTable is false, a CommitChanges() should be called before the table object is disconnected (this is left to the subclass).
Reimplemented in Db::Sqlite3Table.
|
inline |
get a column by attribute id
|
inline |
get a column by fourCC
|
inline |
get a column by name
|
inline |
get all columns in the table
get pointer to database this table is connected to
|
inline |
get name of table
|
inline |
get number of columns in table
|
inline |
get the primary key column, fails hard if none exists
|
inline |
return true if a column exists by attribute id
|
inline |
return true if a column exists by fourCC
|
inline |
return true if a column exists by name
|
inline |
return true if a primary key column exists
bool Db::Table::HasUncommittedColumns | ( | ) | const |
check if there are any uncommitted columns in the table
This method returns true if any uncommited columns exist.
These are columns that have been added with AddColumn() but have not yet been committed to the database.
|
inline |
return true if the table is connected to a database
|
virtual |
set name of table
Sets a new name for the table.
If the Table is attached to a database the change will happen immediately (this must be implemented in a subclass).
Reimplemented in Db::Sqlite3Table.
|
protectedvirtual |
unbind current value table from the table object, commits any changes to the database
Unbind the currently bound value table.
This will commit any changes to the value table into the database.
Reimplemented in Db::Sqlite3Table.
|
friend |
|
friend |
|
friend |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |