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

#include <writer.h>

Detailed Description

A wrapper class to bulk-write data to the database in a simple way.

Inherits Core::RefCounted.

Public Member Functions

 Writer ()
 constructor
 
virtual ~Writer ()
 destructor
 
void SetDatabase (const Ptr< Database > &db)
 set database object
 
void SetTableName (const Util::String &n)
 set the database table name
 
void AddColumn (const Db::Column &col)
 add a column definition
 
void SetFlushTable (bool flushTable)
 set true if the table should be deleted before writing new data
 
bool Open ()
 open the writer
 
bool OpenFromValueTable (const Ptr< ValueTable > &values)
 special case: open from existing value table
 
bool IsOpen () const
 return true if open
 
void Close ()
 close the writer - write to DB
 
void BeginRow ()
 begin writing a new row
 
void SetBool (Attr::BoolAttrId id, bool b)
 set bool attribute in current row
 
void SetInt (Attr::IntAttrId id, int i)
 set int attribute in current row
 
void SetFloat (Attr::FloatAttrId id, float f)
 set float attribute in current row
 
void SetString (Attr::StringAttrId id, const Util::String &s)
 set string attribute in current row
 
void SetVec4 (Attr::Vec4AttrId id, const Math::vec4 &v)
 set vec4 attribute in current row
 
void SetMat4 (Attr::Mat4AttrId id, const Math::mat4 &m)
 set mat4 attribute in current row
 
void SetGuid (Attr::GuidAttrId id, const Util::Guid &guid)
 set guid attribute in current row
 
void SetBlob (Attr::BlobAttrId id, const Util::Blob &blob)
 set blob attribute in current row
 
void EndRow ()
 end current row
 
- 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
 

Private Member Functions

 __DeclareClass (Writer)
 
IndexT FindAttrIndex (Attr::AttrId id) const
 check if attribute exists in current row
 

Private Attributes

Ptr< Databasedatabase
 
bool isOpen
 
bool inBeginRow
 
Util::String tableName
 
Util::Array< Columncolumns
 
Util::Dictionary< Attr::AttrId, IndexTcolumnMap
 
Ptr< ValueTablevalueTable
 
bool flushTable
 
IndexT rowIndex
 

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!)
 
- Protected Member Functions inherited from Core::RefCounted
virtual ~RefCounted ()
 destructor (called when refcount reaches zero)
 

Constructor & Destructor Documentation

◆ Writer()

Db::Writer::Writer ( )

constructor

◆ ~Writer()

Db::Writer::~Writer ( )
virtual

destructor

Member Function Documentation

◆ __DeclareClass()

Db::Writer::__DeclareClass ( Writer )
private

◆ AddColumn()

void Db::Writer::AddColumn ( const Db::Column & col)
inline

add a column definition

Add a column to the db writer.

◆ BeginRow()

void Db::Writer::BeginRow ( )

begin writing a new row

Begin writing a new row to the database.

◆ Close()

void Db::Writer::Close ( )

close the writer - write to DB

Close the writer.

The database update stuff will happen here.

◆ EndRow()

void Db::Writer::EndRow ( )

end current row

Finish writing the current row.

This will update the columns array with any new attribute ids in the current row.

◆ FindAttrIndex()

IndexT Db::Writer::FindAttrIndex ( Attr::AttrId id) const
private

check if attribute exists in current row

◆ IsOpen()

bool Db::Writer::IsOpen ( ) const
inline

return true if open

◆ Open()

bool Db::Writer::Open ( )

open the writer

This opens the writer.

◆ OpenFromValueTable()

bool Db::Writer::OpenFromValueTable ( const Ptr< ValueTable > & srcValues)

special case: open from existing value table

This opens the writer from an existing value table.

Note: you still need to add primary and/or indexed columns, all others will be taken from the value table.

◆ SetBlob()

void Db::Writer::SetBlob ( Attr::BlobAttrId id,
const Util::Blob & blob )
inline

set blob attribute in current row

◆ SetBool()

void Db::Writer::SetBool ( Attr::BoolAttrId id,
bool b )
inline

set bool attribute in current row

◆ SetDatabase()

void Db::Writer::SetDatabase ( const Ptr< Database > & db)
inline

set database object

Set pointer to database.

◆ SetFloat()

void Db::Writer::SetFloat ( Attr::FloatAttrId id,
float f )
inline

set float attribute in current row

◆ SetFlushTable()

void Db::Writer::SetFlushTable ( bool flushTable)
inline

set true if the table should be deleted before writing new data

◆ SetGuid()

void Db::Writer::SetGuid ( Attr::GuidAttrId id,
const Util::Guid & guid )
inline

set guid attribute in current row

◆ SetInt()

void Db::Writer::SetInt ( Attr::IntAttrId id,
int i )
inline

set int attribute in current row

◆ SetMat4()

void Db::Writer::SetMat4 ( Attr::Mat4AttrId id,
const Math::mat4 & m )
inline

set mat4 attribute in current row

◆ SetString()

void Db::Writer::SetString ( Attr::StringAttrId id,
const Util::String & s )
inline

set string attribute in current row

◆ SetTableName()

void Db::Writer::SetTableName ( const Util::String & n)
inline

set the database table name

Set the name of database table the writer will work on.

◆ SetVec4()

void Db::Writer::SetVec4 ( Attr::Vec4AttrId id,
const Math::vec4 & v )
inline

set vec4 attribute in current row

Member Data Documentation

◆ columnMap

Util::Dictionary<Attr::AttrId,IndexT> Db::Writer::columnMap
private

◆ columns

Util::Array<Column> Db::Writer::columns
private

◆ database

Ptr<Database> Db::Writer::database
private

◆ flushTable

bool Db::Writer::flushTable
private

◆ inBeginRow

bool Db::Writer::inBeginRow
private

◆ isOpen

bool Db::Writer::isOpen
private

◆ rowIndex

IndexT Db::Writer::rowIndex
private

◆ tableName

Util::String Db::Writer::tableName
private

◆ valueTable

Ptr<ValueTable> Db::Writer::valueTable
private

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