#include <cursor.h>
Public Member Functions | |
dbCursor (dbCursorType type=dbCursorViewOnly) | |
dbCursor (dbDatabase *aDb, dbCursorType type=dbCursorViewOnly) | |
T * | get () |
T * | next () |
T * | prev () |
T * | first () |
T * | last () |
int | seek (dbReference< T > const &ref) |
T * | operator-> () |
T * | at (dbReference< T > const &ref) |
dbReference< T > | currentId () const |
void | toArray (dbArray< dbReference< T > > &arr) const |
T * | prevAvailable () |
bool | isInSelection (dbReference< T > &ref) |
int | getNumberOfRecords () const |
void | remove () |
bool | isEmpty () const |
bool | isEmpty () |
oid_t | getOid () |
bool | isUpdateCursor () const |
bool | isLimitReached () const |
int | select (dbQuery &query, dbCursorType aType, void *paramStruct=NULL) |
int | select (dbQuery &query, void *paramStruct=NULL) |
int | select (char_t const *condition, dbCursorType aType, void *paramStruct=NULL) |
int | select (char_t const *condition, void *paramStruct=NULL) |
int | select (dbCursorType aType) |
int | select () |
oid_t * | toArrayOfOid (oid_t *arr) const |
int | selectByKey (char_t const *key, void const *value) |
int | selectByKey (dbFieldDescriptor *field, void const *value) |
int | selectByKeyRange (char_t const *key, void const *minValue, void const *maxValue, bool ascent=true) |
int | selectByKeyRange (dbFieldDescriptor *field, void const *minValue, void const *maxValue, bool ascent=true) |
bool | update () |
void | removeAll () |
void | removeAllSelected () |
void | setSelectionLimit (size_t lim) |
void | unsetSelectionLimit () |
void | setPrefetchMode (bool mode) |
bool | isIncremental () |
bool | hasIncrementalHint () |
void | enableCheckForDuplicates (bool enabled) |
void | reset () |
bool | isLast () const |
bool | isFirst () const |
void | freeze () |
void | unfreeze () |
bool | skip (int n) |
int | seek (oid_t oid) |
dbTableDescriptor * | getTable () |
bool | isInSelection (oid_t oid) |
void | fetch () |
bool | hasNext () const |
bool | hasCurrent () const |
void | link (dbL2List *elem) |
void | unlink () |
Public Attributes | |
dbL2List * | next |
dbL2List * | prev |
Protected Member Functions | |
void | checkForDuplicates () |
bool | isMarked (oid_t oid) |
void | deallocateBitmap () |
void | mark (oid_t oid) |
void | setStatementLimit (dbQuery const &q) |
void | truncateSelection () |
bool | add (oid_t oid) |
byte * | fetchNext () |
byte * | fetchPrev () |
byte * | fetchFirst () |
byte * | fetchLast () |
bool | gotoNext () |
bool | gotoPrev () |
bool | gotoFirst () |
bool | gotoLast () |
bool | moveNext () |
bool | movePrev () |
void | setCurrent (dbAnyReference const &ref) |
void | setTable (dbTableDescriptor *aTable) |
void | setRecord (void *rec) |
Protected Attributes | |
T | record |
dbDatabase * | db |
dbTableDescriptor * | table |
dbCursorType | type |
dbCursorType | defaultType |
dbSelection | selection |
bool | allRecords |
oid_t | firstId |
oid_t | lastId |
oid_t | currId |
size_t | limit |
dbGetTie | tie |
void * | paramBase |
bool | eliminateDuplicates |
bool | checkForDuplicatedIsEnabled |
bool | prefetch |
bool | removed |
bool | lastRecordWasDeleted |
size_t | stmtLimitStart |
size_t | stmtLimitLen |
size_t | nSkipped |
dbAbstractIterator * | iterator |
dbBtreeIterator | btreeIterator |
dbRtreeIterator | rtreeIterator |
dbTableIterator | tableIterator |
Cursor template parameterized by table class
Cursor constructor
type | cursor type (dbCursorViewOnly by default) |
dbCursor< T >::dbCursor | ( | dbDatabase * | aDb, | |
dbCursorType | type = dbCursorViewOnly | |||
) | [inline] |
Cursor constructor with explicit specification of database. This cursor should be used for unassigned tables.
aDb | database in which table lokkup is performed | |
type | cursor type (dbCursorViewOnly by default) |
T* dbCursor< T >::at | ( | dbReference< T > const & | ref | ) | [inline] |
Select record by reference
ref | reference to the record |
dbReference<T> dbCursor< T >::currentId | ( | ) | const [inline] |
Get current object idenitifer
void dbAnyCursor::enableCheckForDuplicates | ( | bool | enabled | ) | [inline, inherited] |
Enable or disable duplicates checking (if programmer knows that disjuncts in query do not intersect, then he can disable duplicate checking and avoid bitmap allocation
void dbAnyCursor::fetch | ( | ) | [inline, inherited] |
Fetch current record. You should use this method only if prefetch mode is disabled
T* dbCursor< T >::first | ( | ) | [inline] |
Get pointer to the first record
NULL
if no records were selected Referenced by dbTimeSeriesIterator< T >::reset().
void dbAnyCursor::freeze | ( | ) | [inherited] |
Freeze cursor. This method makes it possible to save current state of cursor, close transaction to allow other threads to proceed, and then later restore state of the cursor using unfreeze method and continue traversal through selected records.
T* dbCursor< T >::get | ( | ) | [inline] |
Get pointer to the current record
NULL
if there is no current record Referenced by dbTimeSeriesProcessor< T >::getFirstInterval(), dbTimeSeriesProcessor< T >::getInterval(), dbTimeSeriesProcessor< T >::getLastInterval(), dbTimeSeriesProcessor< T >::remove(), dbTimeSeriesProcessor< T >::select(), dbTimeSeriesReverseIterator< T >::start(), and dbTimeSeriesIterator< T >::start().
int dbAnyCursor::getNumberOfRecords | ( | ) | const [inline, inherited] |
Get number of selected records
oid_t dbAnyCursor::getOid | ( | ) | [inline, inherited] |
Get current reocrd OID
dbTableDescriptor* dbAnyCursor::getTable | ( | ) | [inline, inherited] |
Get descriptor of the table.
bool dbAnyCursor::hasCurrent | ( | ) | const [inline, inherited] |
Check if there is current record in the selection
bool dbAnyCursor::hasIncrementalHint | ( | ) | [inline, inherited] |
Check if cursor has dbIncrementalType.
bool dbAnyCursor::hasNext | ( | ) | const [inherited] |
Check if there is more records in the selection
bool dbAnyCursor::isEmpty | ( | ) | const [inline, inherited] |
Checks whether selection is empty
bool dbAnyCursor::isFirst | ( | ) | const [inherited] |
Check whether current record is the first one in the selection
NULL
bool dbAnyCursor::isIncremental | ( | ) | [inline, inherited] |
Check if cursor is incremental. Incremental cursor is used only when type is dbCursorIncremental. But even if the type of the cursor is dbCursorIncremental, the cursor may not always be incremental - it depends on a query. Queries containing order by clause except ordering by index key, can not be executed incrementally. In case of incremental cursor, select() returns 0 if no record is selected or 1 if selection is not empty, but precise number of selected records is not reported since it is not known.
bool dbAnyCursor::isInSelection | ( | oid_t | oid | ) | [inherited] |
Check if record with specified OID is in selection
true
if record with such OID was selected bool dbCursor< T >::isInSelection | ( | dbReference< T > & | ref | ) | [inline] |
Check if record with specified OID is in selection
true
if record with such OID was selected Referenced by dbCursor< dbTimeSeriesBlock< T > >::isInSelection().
bool dbAnyCursor::isLast | ( | ) | const [inherited] |
Check whether current record is the last one in the selection
NULL
bool dbAnyCursor::isLimitReached | ( | ) | const [inline, inherited] |
Checks whether limit for number of selected reacord is reached
bool dbAnyCursor::isUpdateCursor | ( | ) | const [inline, inherited] |
Check whether this cursor can be used for update
T* dbCursor< T >::last | ( | ) | [inline] |
Get pointer to the last record
NULL
if no records were selected Referenced by dbTimeSeriesProcessor< T >::getLastInterval(), dbTimeSeriesReverseIterator< T >::reset(), and dbTimeSeriesReverseIterator< T >::start().
T* dbCursor< T >::next | ( | ) | [inline] |
Get next record
NULL
if there is no next record Referenced by dbTimeSeriesProcessor< T >::getFirstInterval(), dbTimeSeriesProcessor< T >::getInterval(), dbTimeSeriesProcessor< T >::getNumberOfElements(), dbTimeSeriesIterator< T >::next(), dbTimeSeriesProcessor< T >::remove(), dbTimeSeriesProcessor< T >::select(), and dbTimeSeriesIterator< T >::start().
T* dbCursor< T >::operator-> | ( | ) | [inline] |
Overloaded operator for accessing components of the current record
T* dbCursor< T >::prev | ( | ) | [inline] |
Get previous record
NULL
if there is no previous record Referenced by dbTimeSeriesProcessor< T >::getLastInterval(), dbTimeSeriesReverseIterator< T >::next(), and dbTimeSeriesReverseIterator< T >::start().
void dbAnyCursor::remove | ( | ) | [inherited] |
Remove current record
Referenced by dbTimeSeriesProcessor< T >::remove().
void dbAnyCursor::removeAll | ( | ) | [inline, inherited] |
Remove all records in the table
void dbAnyCursor::removeAllSelected | ( | ) | [inherited] |
Remove all selected records
void dbAnyCursor::reset | ( | ) | [inherited] |
Reset cursor
int dbAnyCursor::seek | ( | oid_t | oid | ) | [inherited] |
Position cursor on the record with the specified OID
oid | object identifier of record |
int dbCursor< T >::seek | ( | dbReference< T > const & | ref | ) | [inline] |
Position cursor on the record with the specified OID
ref | reference to the object |
Referenced by dbCursor< dbTimeSeriesBlock< T > >::seek().
int dbAnyCursor::select | ( | dbCursorType | aType | ) | [inline, inherited] |
Select all records from the table
aType | cursor type: dbCursorForUpdate, dbCursorViewOnly |
int dbAnyCursor::select | ( | dbQuery & | query, | |
dbCursorType | aType, | |||
void * | paramStruct = NULL | |||
) | [inherited] |
Execute query.
query | selection criteria | |
aType | cursor type: dbCursorForUpdate, dbCursorViewOnly | |
paramStruct | pointer to structure with parameters. If you want to create reentrant precompiled query, i.e. query which can be used concurrently by different threadsm you should avoid to use static variables in such query, and instead of it place paramters into some structure, specify in query relative offsets to the parameters, fill local structure and pass pointer to it to select method. |
Referenced by dbTimeSeriesProcessor< T >::getFirstInterval(), dbTimeSeriesProcessor< T >::getFirstTime(), dbTimeSeriesProcessor< T >::getInterval(), dbTimeSeriesProcessor< T >::getLastInterval(), dbTimeSeriesProcessor< T >::getLastTime(), dbTimeSeriesProcessor< T >::getNumberOfElements(), dbTimeSeriesProcessor< T >::remove(), and dbTimeSeriesProcessor< T >::select().
int dbAnyCursor::select | ( | ) | [inline, inherited] |
Select all records from the table with default cursor type
int dbAnyCursor::select | ( | char_t const * | condition, | |
dbCursorType | aType, | |||
void * | paramStruct = NULL | |||
) | [inline, inherited] |
Execute query.
condition | selection criteria | |
aType | cursor type: dbCursorForUpdate, dbCursorViewOnly | |
paramStruct | pointer to structure with parameters. |
int dbAnyCursor::select | ( | dbQuery & | query, | |
void * | paramStruct = NULL | |||
) | [inline, inherited] |
Execute query with default cursor type.
query | selection criteria | |
paramStruct | pointer to structure with parameters. |
int dbAnyCursor::select | ( | char_t const * | condition, | |
void * | paramStruct = NULL | |||
) | [inline, inherited] |
Execute query with default cursor type.
condition | selection criteria | |
paramStruct | pointer to structure with parameters. |
int dbAnyCursor::selectByKey | ( | char_t const * | key, | |
void const * | value | |||
) | [inherited] |
Select all records from the table with specfied value of the key
key | name of the key field | |
value | searched value of the key |
int dbAnyCursor::selectByKey | ( | dbFieldDescriptor * | field, | |
void const * | value | |||
) | [inherited] |
Select all records from the table with specfied value of the key
field | key field | |
value | searched value of the key |
int dbAnyCursor::selectByKeyRange | ( | char_t const * | key, | |
void const * | minValue, | |||
void const * | maxValue, | |||
bool | ascent = true | |||
) | [inherited] |
Select all records from the table with specfied range of the key values
key | name of the key field | |
minValue | inclusive low bound for key values, if NULL then there is no low bound | |
maxValue | inclusive high bound for key values, if NULL then there is no high bound | |
ascent | key order: true - ascending order, false - descending order |
int dbAnyCursor::selectByKeyRange | ( | dbFieldDescriptor * | field, | |
void const * | minValue, | |||
void const * | maxValue, | |||
bool | ascent = true | |||
) | [inherited] |
Select all records from the table with specfied range of the key values
field | key field | |
minValue | inclusive low bound for key values, if NULL then there is no low bound | |
maxValue | inclusive high bound for key values, if NULL then there is no high bound | |
ascent | key order: true - ascending order, false - descending order |
void dbAnyCursor::setPrefetchMode | ( | bool | mode | ) | [inline, inherited] |
Set prefetch mode. By default, current record is fetch as soon as it is becomes current. But sometimesyou need only OIDs of selected records. In this case setting prefetchMode to false can help.
mode | if false then current record is not fetched. You should explicitly call fetch method if you want to fetch it. |
void dbAnyCursor::setSelectionLimit | ( | size_t | lim | ) | [inline, inherited] |
Specify maximal number of records to be selected
Referenced by dbTimeSeriesProcessor< T >::getFirstTime(), and dbTimeSeriesProcessor< T >::getLastTime().
bool dbAnyCursor::skip | ( | int | n | ) | [inherited] |
Skip specified number of records
n | if positive then skip n records forward, if negative then skip -n records backward |
true
if specified number of records was successfully skipped, false
if there is no next (n > 0
) or previous (n < 0
) record in the selction. void dbCursor< T >::toArray | ( | dbArray< dbReference< T > > & | arr | ) | const [inline] |
Convert selection to array of reference
arr | [OUT] array of refeences in which references to selected recrods will be placed |
oid_t* dbAnyCursor::toArrayOfOid | ( | oid_t * | arr | ) | const [inherited] |
Extract OIDs of selected recrods in array
arr | if arr is not null, then this array is used as destination (it should be at least selection.nRows long)If arr is null, then new array is created by new oid_t[] and returned by this method |
arr
is not null, then arr
, otherwise array created by this method Referenced by dbCursor< dbTimeSeriesBlock< T > >::toArray().
void dbAnyCursor::unfreeze | ( | ) | [inherited] |
Unfreeze cursor. This method starts new transaction and restore state of the cursor
void dbAnyCursor::unsetSelectionLimit | ( | ) | [inline, inherited] |
Remove selection limit
bool dbAnyCursor::update | ( | ) | [inline, inherited] |
Update current record. You should changed value of current record before and then call update method to save changes to the database.
Referenced by dbTimeSeriesProcessor< T >::remove().