LiteSQL
Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
litesql::Persistent Class Reference

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

#include <persistent.hpp>

Collaboration diagram for litesql::Persistent:
Collaboration graph
[legend]

Public Member Functions

const DatabasegetDatabase () const
 returns reference to Database the object is in
 
bool isInDatabase () const
 returns true if object is in database
 
const Persistentoperator= (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 std::vector< std::string > getTablesFromFieldTypes (const std::vector< FieldType > &fdatas)
 selectObjectQuery uses this to list tables used by Persistent More...
 

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 Databasedb
 pointer to current Database Persistent is assigned to. More...
 
bool inDatabase
 flag that indicates that object is stored in some database. More...
 
int oldKey
 used to keep track of ID changes. More...
 

Detailed Description

An abstract base class of persistents objects.

Member Function Documentation

◆ getTablesFromFieldTypes()

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

selectObjectQuery uses this to list tables used by Persistent

Parameters
fdatasfield information

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(), and operator=().

◆ 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(), and operator=().

◆ 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(), and operator=().


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

SourceForge.net Logo