Nebula
|
#include <database.h>
Wraps an entire database into a C++ object.
Inherits Core::RefCounted.
Inherited by Db::Sqlite3Database.
Public Types | |
enum | AccessMode { ReadOnly , ReadWriteExisting , ReadWriteCreate } |
access modes More... | |
Public Member Functions | |
Database () | |
constructor | |
virtual | ~Database () |
destructor | |
void | SetURI (const IO::URI &uri) |
set the data source URI (usually filename of database file) | |
const IO::URI & | GetURI () const |
get the database URI | |
void | SetAccessMode (AccessMode m) |
set the access mode (ReadOnly or ReadWrite) | |
AccessMode | GetAccessMode () const |
get access mode | |
void | SetExclusiveMode (bool b) |
enable/disable exclusive mode | |
bool | GetExclusiveMode () const |
get exclusive mode | |
void | SetIgnoreUnknownColumns (bool b) |
ignore unknown columns (not existing as attribute), yes/no | |
bool | GetIgnoreUnknownColumns () const |
get ignore unknown columns flag | |
virtual bool | Open () |
open the database | |
virtual void | Close () |
close the database | |
bool | IsOpen () const |
return true if database is open | |
const Util::String & | GetError () const |
get last error string | |
virtual bool | AttachDatabase (const IO::URI &uri, const Util::String &dbName) |
attach another database to the current database | |
virtual void | DetachDatabase (const Util::String &dbName) |
detach an attached database | |
virtual void | BeginTransaction () |
begin a transaction on the database | |
virtual void | EndTransaction () |
end a transaction on the database | |
virtual void | AddTable (const Ptr< Table > &table) |
create a new table in the database | |
virtual void | DeleteTable (const Util::String &tableName) |
delete a table from the database | |
bool | HasTable (const Util::String &tableName) const |
return true if a table exists by name | |
SizeT | GetNumTables () const |
get number of tables in the database | |
const Ptr< Table > & | GetTableByIndex (IndexT i) const |
get table by index | |
const Ptr< Table > & | GetTableByName (const Util::String &tableName) const |
get table by name | |
void | SetInMemoryDatabase (bool b) |
set in-memory database only | |
virtual void | CopyInMemoryDatabaseToFile (const IO::URI &fileUri) |
copy in memory database to file | |
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 | SetError (const Util::String &error) |
set error string | |
IndexT | FindTableIndex (const Util::String &tableName) const |
find a table index by name | |
Protected Member Functions inherited from Core::RefCounted | |
virtual | ~RefCounted () |
destructor (called when refcount reaches zero) | |
Protected Attributes | |
bool | isOpen |
bool | ignoreUnknownColumns |
IO::URI | uri |
Util::String | error |
AccessMode | accessMode |
bool | memoryDatabase |
bool | exclusiveMode |
Util::Array< Ptr< Table > > | tables |
Private Member Functions | |
__DeclareClass (Database) | |
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::Database::Database | ( | ) |
constructor
|
virtual |
destructor
|
private |
create a new table in the database
Add a table to the database.
No table of the same name may exist yet in the database, otherwise an error will be thrown. If the table has values, the new database table will be initialized with those values. The table object will be connected to the database, which means any later changes to the table may be written to the database by calling the CommitChanges() method on the table.
|
virtual |
attach another database to the current database
Attach another database to this database.
Override this method in a subclass!
Reimplemented in Db::Sqlite3Database.
|
virtual |
begin a transaction on the database
Begin a transaction on the database.
Override this method in a subclass.
Reimplemented in Db::Sqlite3Database.
|
virtual |
close the database
Close the database.
A subclass should flush all pending changes and disconnect from the database.
Reimplemented in Db::Sqlite3Database.
|
virtual |
copy in memory database to file
Copy database to file.
Override this method in a subclass!
Reimplemented in Db::Sqlite3Database.
|
virtual |
delete a table from the database
Remove a data table from the database.
A subclass must drop the table from the database when this method is called.
|
virtual |
detach an attached database
Detach an attached database from this database.
Override this method in a subclass!
Reimplemented in Db::Sqlite3Database.
|
virtual |
end a transaction on the database
Finish a transaction on the database.
Override this method in a subclass.
Reimplemented in Db::Sqlite3Database.
|
protected |
find a table index by name
NOTE: we cannot use a more efficient container for the tables because the table name can change anytime outside our control.
|
inline |
get access mode
|
inline |
get last error string
|
inline |
get exclusive mode
|
inline |
get ignore unknown columns flag
SizeT Db::Database::GetNumTables | ( | ) | const |
get number of tables in the database
NOTE: we cannot use a more efficient container for the tables because the table name can change anytime outside our control.
get table by index
NOTE: we cannot use a more efficient container for the tables because the table name can change anytime outside our control.
const Ptr< Table > & Db::Database::GetTableByName | ( | const Util::String & | tableName | ) | const |
get table by name
NOTE: we cannot use a more efficient container for the tables because the table name can change anytime outside our control.
|
inline |
get the database URI
bool Db::Database::HasTable | ( | const Util::String & | tableName | ) | const |
return true if a table exists by name
NOTE: we cannot use a more efficient container for the tables because the table name can change anytime outside our control.
|
inline |
return true if database is open
|
virtual |
open the database
Open the database.
A subclass should connect to the database here and create a DataTable object for each table in the database.
Reimplemented in Db::Sqlite3Database.
|
inline |
set the access mode (ReadOnly or ReadWrite)
|
inlineprotected |
set error string
|
inline |
enable/disable exclusive mode
|
inline |
ignore unknown columns (not existing as attribute), yes/no
|
inline |
set in-memory database only
|
inline |
set the data source URI (usually filename of database file)
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |