LiteSQL 0.3.10
litesql::Persistent Class Reference

An abstract base class of persistents objects. More...

#include <persistent.hpp>

Collaboration diagram for litesql::Persistent:

Public Member Functions

const Database & getDatabase () const
 returns reference to Database the object is in
bool isInDatabase () const
 returns true if object is in database
const Persistent & operator= (const Persistent &p)
 copies values and keeps fields unchanged
 Persistent (const Persistent &p)
 copies values and registers Field-objects to fields
 Persistent (const Database &_db, const Record &row)
 Persistent (const Database &_db)
 creates empty Persistent
virtual void onDelete ()
virtual ~Persistent ()
 empty

Static Public Member Functions

static Split getTablesFromFieldTypes (const std::vector< FieldType > &fdatas)
 selectObjectQuery uses this to list tables used by Persistent

Protected Types

typedef std::map< std::string, std::vector< pair< FieldType, std::string > > > Updates

Protected Member Functions

std::string insert (Record &tables, Records &fieldRecs, Records &values, const std::string &sequence)
 executed when object is created into database
void update (const Updates &updates)
template<class T>
void updateField (litesql::Persistent::Updates &updates, const std::string &table, litesql::Field< T > fld)
void prepareUpdate (Updates &updates, const std::string &table)
void deleteFromTable (const std::string &table, const std::string &id)

Protected Attributes

const Database * db
 pointer to current Database Persistent is assigned to.
bool inDatabase
 flag that indicates that object is stored in some database.
int oldKey
 used to keep track of ID changes.

Detailed Description

An abstract base class of persistents objects.

Constructor & Destructor Documentation

◆ Persistent() [1/2]

litesql::Persistent::Persistent ( const Persistent & p)
inline

copies values and registers Field-objects to fields

References db, inDatabase, oldKey, and Persistent().

Referenced by operator=(), and Persistent().

◆ Persistent() [2/2]

litesql::Persistent::Persistent ( const Database & _db)
inline

creates empty Persistent

References db, inDatabase, and oldKey.

Member Function Documentation

◆ getDatabase()

const Database & litesql::Persistent::getDatabase ( ) const
inline

returns reference to Database the object is in

References db.

◆ getTablesFromFieldTypes()

Split litesql::Persistent::getTablesFromFieldTypes ( const std::vector< FieldType > & fdatas)
static

selectObjectQuery uses this to list tables used by Persistent

Parameters
fdatasfield information

◆ insert()

string litesql::Persistent::insert ( Record & tables,
Records & fieldRecs,
Records & values,
const std::string & sequence )
protected

executed when object is created into database

References db, litesql::Database::groupInsert(), inDatabase, and oldKey.

◆ isInDatabase()

bool litesql::Persistent::isInDatabase ( ) const
inline

returns true if object is in database

References inDatabase.

◆ operator=()

const Persistent & litesql::Persistent::operator= ( const Persistent & p)

copies values and keeps fields unchanged

References db, inDatabase, oldKey, and Persistent().

Member Data Documentation

◆ db

const Database* litesql::Persistent::db
protected

pointer to current Database Persistent is assigned to.

It is not a reference because Persistents must be assignable using operator=

Referenced by getDatabase(), insert(), operator=(), Persistent(), and Persistent().

◆ inDatabase

bool litesql::Persistent::inDatabase
protected

flag that indicates that object is stored in some database.

It might be more accurate to use pointer in stead of boolean.

Referenced by insert(), isInDatabase(), operator=(), Persistent(), and Persistent().

◆ oldKey

int litesql::Persistent::oldKey
protected

used to keep track of ID changes.

When user changes Persistent object's identifier (ID, field 0), record has to be upcasted to change row id of all tables of object

Referenced by insert(), operator=(), Persistent(), and Persistent().


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

SourceForge.net Logo