#include <record.h>
Inheritance diagram for databases::Record:
Public Types | |
typedef uint32_t | identifier_type |
Type of the record identifier. | |
enum | { dbsUpdating = 0x0001, dbsUpdateError = 0x0002, dbsMember = 0x0004, dbsInsert = 0x0008 } |
Possible status flags. More... | |
Public Member Functions | |
Record () | |
Default constructor. | |
Record (identifier_type id) | |
Constructor that sets the record identifier. | |
Record (Record const &r) | |
Copy constructor. | |
Record & | operator= (Record const &right) |
Assignment operator. | |
virtual | ~Record () |
Destructor. | |
bool | operator== (identifier_type id) |
Checks whether the given identifier is the same as the record identifier. | |
virtual void | begin_update () |
Begins record update. | |
virtual char const * | get_s (Field const *field) const |
Gets a string field. | |
virtual char const * | set_s (Field const *field, char const *value) |
Sets a string field. | |
virtual int32_t | get_i (Field const *field) const |
Gets an integer field. | |
virtual int32_t | set_i (Field const *field, int32_t value) |
Sets an integer field. | |
virtual uint32_t | get_ui (Field const *field) const |
Gets an unsigned integer field. | |
virtual uint32_t | set_ui (Field const *field, uint32_t value) |
Sets an unsigned integer field. | |
virtual time_t | get_ut (Field const *field) const |
Gets a Unix timestamp field. | |
virtual time_t | set_ut (Field const *field, time_t value) |
Sets a Unix timestamp field. | |
virtual identifier_type | get_ri (Field const *field) const |
Gets a record identifier field. | |
virtual identifier_type | set_ri (Field const *field, identifier_type value) |
Sets a record identifier field. | |
virtual bool | end_update () |
Ends record update. | |
virtual bool | owned (Collection const *coll, Record const *record) |
Determines whether this record is owned by another record. | |
virtual size_t | memory_usage () const |
Returns the memory usage of the record. | |
identifier_type | id () const |
Returns the unique identifier of the record. | |
identifier_type | id (identifier_type id) |
Sets the unique identifier of the record. | |
uint16_t | db_status () const |
Returns the status of the record. | |
uint16_t | db_status_add (uint16_t flags) |
Adds flags to the status of the record. | |
uint16_t | db_status_remove (uint16_t flags) |
Removes flags from the status of the record. | |
Static Public Member Functions | |
static identifier_type | strtori (char const *nptr, char **endptr, int base) |
Converts string record identifier to its integer representation. | |
Protected Attributes | |
identifier_type | m_id |
The record identifier. | |
uint16_t | m_db_status |
The record status. |
Each record gets an unique numeric identifier that may be used to refer to it easily.
The begin_update(), get_s(), set_s(), get_i(), set_i(), get_ui(), set_ui(), get_ut(), set_ut(), get_ri(), set_ri(), end_update(), owned() and memory_usage() functions may be overriden in derived classes.
|
|
|
Begins record update. This function must be called by database modules before they start updating the record. Once this function has been called successfully, all fields in the record for which a value is available are expected to be updated, in ANY order (and not always in the order they were added to the database), and end_update() MUST be called even if there was an error in the update phase. The default implementation adds the flags dbsUpdating and dbsInsert (since it is _known_ that the record is indeed in the database) to the record status, and always returns true.
|
|
Adds flags to the status of the record.
|
|
Removes flags from the status of the record.
|
|
Ends record update. This function must be called by database modules after they finish updating the record (begin_update() is therefore expected to have been called successfully before). The default implementation removes the flag dbsUpdating from the record status, and returns true, unless the dbsUpdateError flag has been set, in which case the flag is cleared and the function returns false.
|
|
Gets an integer field. The default implementation just returns some undefined value.
|
|
Gets a record identifier field. The default implementation just returns some undefined value.
|
|
Gets a string field. The default implementation just returns some undefined value.
|
|
Gets an unsigned integer field. The default implementation just returns some undefined value.
|
|
Gets a Unix timestamp field. The default implementation just returns some undefined value.
|
|
Sets the unique identifier of the record.
|
|
Returns the memory usage of the record. The default implementation always returns zero.
|
|
Determines whether this record is owned by another record. The default implementation always returns false, so this has to be changed if the collection this records belongs to is owned by another collection.
|
|
Sets an integer field. This function must have been preceded by a call to begin_update(). The default implementation does nothing else than returning the given parameter.
|
|
Sets a record identifier field. This function must have been preceded by a call to begin_update(). The default implementation does nothing else than returning the given parameter.
|
|
Sets a string field. This function must have been preceded by a call to begin_update(). The default implementation does nothing else than returning the given parameter.
|
|
Sets an unsigned integer field. This function must have been preceded by a call to begin_update(). The default implementation does nothing else than returning the given parameter.
|
|
Sets a Unix timestamp field. This function must have been preceded by a call to begin_update(). The default implementation does nothing else than returning the given parameter.
|