SavableManager Class Reference

This class represents one row in the database. More...

#include <SavableManager.h>

List of all members.

Public Member Functions

void erase ()
 Remove the row this manager represents from the databse.
void save ()
 Save the row this manager represents to the database.
void discard ()
 Discards any changes made to this manager.
bool exists () const
 Wether the manager has been saved to the database or not.
bool lock ()
 Whether a write lock could be aquired for this manager.
void unlock ()
 Releases the lock, it is asserted at run-time that a lock was previously aquired.
void bindKeys (sqlite3 *db, sqlite3_stmt *stmt, const int startpos=1) const
 Binds the keys of this manager to the specified statement.
void bindFields (sqlite3 *db, sqlite3_stmt *stmt, const int startpos=1) const
 Binds the fields of this manager to the specified statement.
void bindUpdate (sqlite3 *db, sqlite3_stmt *stmt) const
 First binds the keys and then the fields of this manager to the specified statement.
void bindLookup (sqlite3 *db, sqlite3_stmt *stmt) const
 Binds the lookup field of this manager to the specified statement.
void parseInsert (sqlite3 *db)
 Parse an insertion from the database.
void parseSelect (sqlite3_stmt *stmt, const int startpos=0)
 Read in this managers fields from a selection from the database.
void parseLookup (sqlite3_stmt *stmt)
 Read in the keys and the fields for this manager from a lookup from the database.
TableImplPtr getTable () const
 Returns the table this manager belongs to.
ValuePtr getValue (FieldImplPtr field) const
 Returns the value of the specified field of the row this manager represents .
KeysPtr getKeys () const
 Returns the keys in this manager.
size_t primaryKeySize () const
 Returns the size of the primary keys for this manager.
std::string toString ()
 Returns a string representation of this manager.
Strings fieldList () const
 Returns an array of strings, one for each field in this row.
std::string getDiff () const
 Returns a string representation of the valueus of this manager compared to the database.
bool isDirty () const
 Wether any changes been made to this manager that have not been saved to the databse yet.
void setKeys (KeysPtr keys)
 Sets this managers keys to the specified values, it is asserted at runtime that a lock has been aquired.
void setValue (ValuePtr value)
 Sets the specified field of this manager to the specified value, it is asserted at runtime that a lock has been aquired.
void setValue (FieldImplPtr field, cstring value)
 Sets the specified field of this manager to the specified value, it is asserted at runtime that a lock has been aquired.
void setValue (FieldImplPtr field, value_type value)
 Sets the specified field of this manager to the specified value, it is asserted at runtime that a lock has been aquired.
void setValue (KeyImplPtr field, value_type value)
 Sets the specified field of this manager to the specified value, it is asserted at runtime that a lock has been aquired.

Static Public Member Functions

static SavableManagersPtr getmulti (ValuesPtr values)
 Select multiple entries from the database restricting on the specified values.
static SavableManagersPtr getmulti (ValuesPtr values, const Joins &joins)
 Select multiple entries from the database restricting on the specified values.
static SavableManagerPtr getnew (TableImplPtr table)
 Returns a new manager for the specified table, it is not yet stored in the database.
static SavableManagerPtr bykey (KeyValuePtr key)
 Returns a manager for the specified table using the specified key.
static SavableManagerPtr bykeys (KeysPtr keys)
 Returns a manager using the specified keys, these are asserted to be all the keys for this table.
static SavableManagerPtr byvalue (ValuePtr value)
 Returns a manager using the specified value, this value should uniquely identify an entry.
static KeysPtr lookupvalue (ValuePtr value)
 Wrapper that looks up a manager by the specified value and returns the keys.
static size_t count (SelectionMaskPtr mask)
 Count how many entries there are that satisfy this mask.
static size_t count (KeysPtr keys)
 Count how many entries there are for the given keys set.

Friends

class SelectionMask


Detailed Description

This class represents one row in the database.

It may be used to perform CRUD operations on the database. (Create, Retreive, Update, Delete)

Trivial locking is implemented through lock and unlock. That is, it is asserted that a lock was aquired when performing a write operation. However, it is not checked that it was the called that aquired the lock. It is therefore the responsibility of the caller not to use write operation unless it previously aquired a lock.

See also:
lock

unlock

Definition at line 57 of file SavableManager.h.


Member Function Documentation

static SavableManagersPtr SavableManager::getmulti ( ValuesPtr  values  )  [static]

Select multiple entries from the database restricting on the specified values.

This method wraps the creation of the SelectionMask and the call to the database. This is the preferred method of selection multiple rows from the database is through 'getmulti'.

Parameters:
values The values to filter on.
Returns:
A SavableManagers bucket containing the retreived data.
See also:
SelectionMask

static SavableManagersPtr SavableManager::getmulti ( ValuesPtr  values,
const Joins joins 
) [static]

Select multiple entries from the database restricting on the specified values.

This method wraps the creation of the SelectionMask and the call to the database. This is the preferred method of selection multiple rows from the database is through 'getmulti'.

Parameters:
values The values to filter on.
joins The joins to extend the selection with.
Returns:
A SavableManagers bucket containing the retreived data.
See also:
SelectionMask

static SavableManagerPtr SavableManager::getnew ( TableImplPtr  table  )  [static]

Returns a new manager for the specified table, it is not yet stored in the database.

static SavableManagerPtr SavableManager::bykey ( KeyValuePtr  key  )  [static]

Returns a manager for the specified table using the specified key.

static SavableManagerPtr SavableManager::bykeys ( KeysPtr  keys  )  [static]

Returns a manager using the specified keys, these are asserted to be all the keys for this table.

static SavableManagerPtr SavableManager::byvalue ( ValuePtr  value  )  [static]

Returns a manager using the specified value, this value should uniquely identify an entry.

static KeysPtr SavableManager::lookupvalue ( ValuePtr  value  )  [static]

Wrapper that looks up a manager by the specified value and returns the keys.

static size_t SavableManager::count ( SelectionMaskPtr  mask  )  [static]

Count how many entries there are that satisfy this mask.

static size_t SavableManager::count ( KeysPtr  keys  )  [static]

Count how many entries there are for the given keys set.

void SavableManager::erase (  ) 

Remove the row this manager represents from the databse.

void SavableManager::save (  ) 

Save the row this manager represents to the database.

void SavableManager::discard (  ) 

Discards any changes made to this manager.

bool SavableManager::exists (  )  const

Wether the manager has been saved to the database or not.

bool SavableManager::lock (  ) 

Whether a write lock could be aquired for this manager.

void SavableManager::unlock (  ) 

Releases the lock, it is asserted at run-time that a lock was previously aquired.

void SavableManager::bindKeys ( sqlite3 *  db,
sqlite3_stmt *  stmt,
const int  startpos = 1 
) const

Binds the keys of this manager to the specified statement.

void SavableManager::bindFields ( sqlite3 *  db,
sqlite3_stmt *  stmt,
const int  startpos = 1 
) const

Binds the fields of this manager to the specified statement.

void SavableManager::bindUpdate ( sqlite3 *  db,
sqlite3_stmt *  stmt 
) const

First binds the keys and then the fields of this manager to the specified statement.

void SavableManager::bindLookup ( sqlite3 *  db,
sqlite3_stmt *  stmt 
) const

Binds the lookup field of this manager to the specified statement.

void SavableManager::parseInsert ( sqlite3 *  db  ) 

Parse an insertion from the database.

Only valid on a table with a singular primary key. That is, sqlite3_last_insert_rowid must return the id of the inserted row.

void SavableManager::parseSelect ( sqlite3_stmt *  stmt,
const int  startpos = 0 
)

Read in this managers fields from a selection from the database.

void SavableManager::parseLookup ( sqlite3_stmt *  stmt  ) 

Read in the keys and the fields for this manager from a lookup from the database.

TableImplPtr SavableManager::getTable (  )  const

Returns the table this manager belongs to.

ValuePtr SavableManager::getValue ( FieldImplPtr  field  )  const

Returns the value of the specified field of the row this manager represents .

KeysPtr SavableManager::getKeys (  )  const

Returns the keys in this manager.

size_t SavableManager::primaryKeySize (  )  const

Returns the size of the primary keys for this manager.

std::string SavableManager::toString (  ) 

Returns a string representation of this manager.

Strings SavableManager::fieldList (  )  const

Returns an array of strings, one for each field in this row.

std::string SavableManager::getDiff (  )  const

Returns a string representation of the valueus of this manager compared to the database.

bool SavableManager::isDirty (  )  const

Wether any changes been made to this manager that have not been saved to the databse yet.

void SavableManager::setKeys ( KeysPtr  keys  ) 

Sets this managers keys to the specified values, it is asserted at runtime that a lock has been aquired.

void SavableManager::setValue ( ValuePtr  value  ) 

Sets the specified field of this manager to the specified value, it is asserted at runtime that a lock has been aquired.

void SavableManager::setValue ( FieldImplPtr  field,
cstring  value 
)

Sets the specified field of this manager to the specified value, it is asserted at runtime that a lock has been aquired.

void SavableManager::setValue ( FieldImplPtr  field,
value_type  value 
)

Sets the specified field of this manager to the specified value, it is asserted at runtime that a lock has been aquired.

void SavableManager::setValue ( KeyImplPtr  field,
value_type  value 
)

Sets the specified field of this manager to the specified value, it is asserted at runtime that a lock has been aquired.


Generated for UnsignedByte by  doxygen 1.5.3
SourceForge.net Logo