CONZEPT 16 C++ API
C16::Selection Class Reference

Selection buffer to operate on selections of a table. More...

#include "C16/Selection.hpp"

Detailed Description

Selection buffer to operate on selections of a table.

Examples

Iteration

using namespace C16;
void selections_iterate(const Table& table)
{
Selection selection(table);
for
(
Result result = selection.read(Place::FIRST);
result == Result::OK;
result = selection.read(Place::NEXT)
)
{
...
}
}

Static Public Attributes

static const int NAME_LENGTH_LIMIT = 20
 Name length limit. More...
 

Public Member Functions

 Selection (const Database &database, int table_number)
 Constructs a selection buffer by means of the database and the number of its table. More...
 
 Selection (const Database &database, const std::string &table_name)
 Constructs a selection buffer by means of the database and the name of its table. More...
 
 Selection (const Table &table)
 Constructs a selection buffer by means of its table. More...
 
 Selection (const Selection &other)
 Constructs a copy of another selection buffer. More...
 
const Databasedatabase () const
 Gets the database of the selection buffer. More...
 
const Tabletable () const
 Gets the table of the selection buffer. More...
 
bool loaded () const
 Gets if a selection is loaded into the selection buffer. More...
 
const std::string & name () const
 Gets the name of the loaded selection. More...
 
const Value::Datecreated_date () const
 Gets the date of the creation of the loaded selection. More...
 
const Value::Timecreated_time () const
 Gets the time of the creation of the loaded selection. More...
 
const Value::Datemodified_date () const
 Gets the date of the last modification of the loaded selection. More...
 
const Value::Timemodified_time () const
 Gets the time of the last modification of the loaded selection. More...
 
const std::string & modified_user () const
 Gets the user who last modified the loaded selection. More...
 
const Value::Dateexecuted_date () const
 Gets the date of the last execution of the loaded selection. More...
 
const Value::Timeexecuted_time () const
 Gets the time of the last execution of the loaded selection. More...
 
int right_modify () const
 Gets the right required by a user to modify the loaded selection. More...
 
int right_execute () const
 Gets the right required by a user to execute the loaded selection. More...
 
long int records_count () const
 Gets the count of records of the loaded selection. More...
 
Result read (const std::string &name, Place place=Place::KEY, Locking locking=Locking::NONE)
 Reads a selection by means of a reference name and a place into the selection buffer. More...
 
Result read (Place place, Locking locking=Locking::NONE)
 Reads a selection by means of a place into the selection buffer. More...
 
Result reload (Locking locking=Locking::NONE)
 Reloads the loaded selection. More...
 
void unload ()
 Unloads the loaded selection. More...
 
Result record_insert (const Record &record) const
 Inserts a record into the loaded selection. More...
 
Result record_remove (const Record &record) const
 Removes a record from the loaded selection. More...
 
Result clear () const
 Clears the loaded selection (i.e. removes all records from the selection). More...
 

Member Data Documentation

◆ NAME_LENGTH_LIMIT

const int C16::Selection::NAME_LENGTH_LIMIT = 20
static

Name length limit.

Constructor & Destructor Documentation

◆ Selection() [1/4]

C16::Selection::Selection ( const Database database,
int  table_number 
)

Constructs a selection buffer by means of the database and the number of its table.

Parameters
databaseDatabase the selection buffer operates on
table_numberNumber of the table the selection buffer operates on
Exceptions
Exception::InexistenceTable inexistent.

◆ Selection() [2/4]

C16::Selection::Selection ( const Database database,
const std::string &  table_name 
)

Constructs a selection buffer by means of the database and the name of its table.

Parameters
databaseDatabase the selection buffer operates on
table_nameName of the table the selection buffer operates on (case insensitive)
Exceptions
Exception::InexistenceTable inexistent.

◆ Selection() [3/4]

C16::Selection::Selection ( const Table table)
explicit

Constructs a selection buffer by means of its table.

Parameters
tableTable the selection buffer operates on

◆ Selection() [4/4]

C16::Selection::Selection ( const Selection other)

Constructs a copy of another selection buffer.

Parameters
otherAnother selection buffer
Note
The copy and the other selection buffer share the same selection until another selection is loaded into one of them.

Member Function Documentation

◆ database()

const Database& C16::Selection::database ( ) const

Gets the database of the selection buffer.

◆ table()

const Table& C16::Selection::table ( ) const

Gets the table of the selection buffer.

◆ loaded()

bool C16::Selection::loaded ( ) const

Gets if a selection is loaded into the selection buffer.

◆ name()

const std::string& C16::Selection::name ( ) const

Gets the name of the loaded selection.

◆ created_date()

const Value::Date& C16::Selection::created_date ( ) const

Gets the date of the creation of the loaded selection.

◆ created_time()

const Value::Time& C16::Selection::created_time ( ) const

Gets the time of the creation of the loaded selection.

◆ modified_date()

const Value::Date& C16::Selection::modified_date ( ) const

Gets the date of the last modification of the loaded selection.

◆ modified_time()

const Value::Time& C16::Selection::modified_time ( ) const

Gets the time of the last modification of the loaded selection.

◆ modified_user()

const std::string& C16::Selection::modified_user ( ) const

Gets the user who last modified the loaded selection.

◆ executed_date()

const Value::Date& C16::Selection::executed_date ( ) const

Gets the date of the last execution of the loaded selection.

◆ executed_time()

const Value::Time& C16::Selection::executed_time ( ) const

Gets the time of the last execution of the loaded selection.

◆ right_modify()

int C16::Selection::right_modify ( ) const

Gets the right required by a user to modify the loaded selection.

◆ right_execute()

int C16::Selection::right_execute ( ) const

Gets the right required by a user to execute the loaded selection.

◆ records_count()

long int C16::Selection::records_count ( ) const

Gets the count of records of the loaded selection.

◆ read() [1/2]

Result C16::Selection::read ( const std::string &  name,
Place  place = Place::KEY,
Locking  locking = Locking::NONE 
)

Reads a selection by means of a reference name and a place into the selection buffer.

Parameters
nameReference name (case insensitive, 0 to NAME_LENGTH_LIMIT characters)
placePlace of the selection
Place::KEYReads the selection with the same name as the reference name.
Place::NEXTReads the selection with the name following the reference name.
Place::PREVIOUSReads the selection with the name preceding the reference name.
lockingLocking to apply to the selection
Locking::NONEDoes not change the lock of the selection.
Locking::LOCK_EXCLUSIVEApplies an exclusive lock to the selection.
Locking::LOCK_SHAREDApplies a shared lock to the selection.
Locking::UNLOCKRemoves a lock applied by the accessing user from the selection.
Returns
Result
Return values
Result::OKSelection loaded and locking applied.
Result::LOCKEDSelection loaded but already locked.
Result::NO_KEYSelection inexistent but following selection existent and loaded.
Result::LAST_RECSelection and following selection inexistent but preceding selection existent and loaded.
Result::NO_RECNo selection existent and loaded.
Exceptions
Exception::InvalidityName invalid.
Exception::InvalidityPlace invalid.
Exception::InvalidityLocking invalid.
Note
Selections are ordered by name (lexicographicaly).

◆ read() [2/2]

Result C16::Selection::read ( Place  place,
Locking  locking = Locking::NONE 
)

Reads a selection by means of a place into the selection buffer.

Parameters
placePlace of the selection
Place::FIRSTReads the first selection.
Place::LASTReads the last selection.
Place::NEXTReads the selection with the name following the name of the loaded selection.
Place::PREVIOUSReads the selection with the name preceding the name of the loaded selection.
lockingLocking to apply to the selection
Locking::NONEDoes not change the lock of the selection.
Locking::LOCK_EXCLUSIVEApplies an exclusive lock to the selection.
Locking::LOCK_SHAREDApplies a shared lock to the selection.
Locking::UNLOCKRemoves a lock applied by the accessing user from the selection.
Returns
Result
Return values
Result::OKSelection loaded and locking applied.
Result::LOCKEDSelection loaded but already locked.
Result::NO_RECNo selection existent and loaded.
Result::NO_RIGHTSPermissions insufficient. Name of text loaded.
Exceptions
Exception::InvalidityPlace invalid.
Exception::InvalidityLocking invalid.
Note
Selections are ordered by name (lexicographicaly).
See also
Example

◆ reload()

Result C16::Selection::reload ( Locking  locking = Locking::NONE)

Reloads the loaded selection.

The selection is identified by its name.

Parameters
lockingLocking to apply to the selection
Locking::NONEDoes not change the lock of the selection.
Locking::LOCK_EXCLUSIVEApplies an exclusive lock to the selection.
Locking::LOCK_SHAREDApplies a shared lock to the selection.
Locking::UNLOCKRemoves a lock applied by the accessing user from the selection.
Returns
Result
Return values
Result::OKSelection loaded and locking applied.
Result::LOCKEDSelection loaded but already locked.
Result::NO_KEYSelection inexistent but following selection existent and loaded.
Result::LAST_RECSelection and following selection inexistent but preceding selection existent and loaded.
Result::NO_RECSelection inexistent or not loaded. No selection loaded.
Note
Selections are ordered by name (lexicographicaly).

◆ unload()

void C16::Selection::unload ( )

Unloads the loaded selection.

◆ record_insert()

Result C16::Selection::record_insert ( const Record record) const

Inserts a record into the loaded selection.

Parameters
recordRecord buffer of the record
Returns
Result
Return values
Result::OKRecord inserted to the selection.
Result::EXISTSRecord already existent in the selection.
Result::NO_LOCKSelection not exclusively locked or not loaded.
Result::DEADLOCKDeadlock occurred.
Exceptions
Exception::InexistenceResult set inexistent.
Selection does not contain a result set for the record.

◆ record_remove()

Result C16::Selection::record_remove ( const Record record) const

Removes a record from the loaded selection.

Parameters
recordRecord buffer of the record
Returns
Result
Return values
Result::OKRecord removed from the selection.
Result::NO_KEYRecord not existent in the selection.
Result::NO_RECResult set empty.
Result::NO_LOCKSelection not exclusively locked or not loaded.
Result::DEADLOCKDeadlock occurred.
Exceptions
Exception::InexistenceResult set inexistent.
Selection does not contain a result set for the record.

◆ clear()

Result C16::Selection::clear ( ) const

Clears the loaded selection (i.e. removes all records from the selection).

Returns
Result
Return values
Result::OKSelection cleared.
Result::NO_LOCKSelection not exclusively locked or not loaded.
Result::DEADLOCKDeadlock occurred.
C16::Selection::table
const Table & table() const
Gets the table of the selection buffer.
C16::Place::NEXT
@ NEXT
Operate on the next entity.
C16::Place::FIRST
@ FIRST
Operate on the first entity.
LibraryApplication.hpp
CONZEPT 16 C++ API for applications.
C16::Result
Result
Result of an operation related to a database entity.
Definition: Result.hpp:12
C16
Namespace.
Definition: Array.hpp:6
C16::Selection
Selection buffer to operate on selections of a table.
Definition: Selection.hpp:57
C16::Result::OK
@ OK
Operation succeeded.
C16::Table
Table of a database.
Definition: Table.hpp:21