Main Page   Class Hierarchy   Compound List   File List   Compound Members  

dbCursor< T > Class Template Reference

#include <cursor.h>

Inheritance diagram for dbCursor< T >:

dbAnyCursor dbL2List List of all members.

Public Methods

 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)
void toArray (dbArray< dbReference< T > > &arr) const
dbReference< T > currentId () const
T * nextAvailable ()
T * prevAvailable ()
bool isInSelection (dbReference< T > &ref)
int getNumberOfRecords () const
void remove ()
bool isEmpty () const
bool isUpdateCursor () const
bool isLimitReached () const
oid_t * toArrayOfOid (oid_t *arr) const
int select (dbQuery &query, dbCursorType aType, void *paramStruct=NULL)
int select (dbQuery &query, void *paramStruct=NULL)
int select (char const *condition, dbCursorType aType, void *paramStruct=NULL)
int select (char const *condition, void *paramStruct=NULL)
int select (dbCursorType aType)
int select ()
int selectByKey (char const *key, void const *value)
int selectByKeyRange (char const *key, void const *minValue, void const *maxValue)
void update ()
void removeAll ()
void removeAllSelected ()
void setSelectionLimit (size_t lim)
void unsetSelectionLimit ()
void setPrefetchMode (bool mode)
void reset ()
bool isLast () const
bool isFirst () const
void freeze ()
void unfreeze ()
bool skip (int n)
int seek (oid_t oid)
dbTableDescriptorgetTable ()
void setTable (dbTableDescriptor *aTable)
void setRecord (void *rec)
void * getRecord ()
bool isInSelection (oid_t oid)
void fetch ()
bool hasNext () const

Protected Attributes

record

Detailed Description

template<class T>
class dbCursor< T >

Cursor template parameterized by table class


Constructor & Destructor Documentation

template<class T>
dbCursor< T >::dbCursor dbCursorType    type = dbCursorViewOnly [inline]
 

Cursor constructor

Parameters:
type  cursor type (dbCursorViewOnly by default)

template<class T>
dbCursor< T >::dbCursor dbDatabase   aDb,
dbCursorType    type = dbCursorViewOnly
[inline]
 

Cursor constructor with explicit specification of database. This cursor should be used for unassigned tables.

Parameters:
aDb  database in which table lookup is performed
type  cursor type (dbCursorViewOnly by default)


Member Function Documentation

template<class T>
T* dbCursor< T >::at dbReference< T > const &    ref [inline]
 

Select record by reference

Parameters:
ref  reference to the record
Returns:
pointer to the referenced record

template<class T>
dbReference<T> dbCursor< T >::currentId   const [inline]
 

Get current object idenitifer

Returns:
reference to the current record

void dbAnyCursor::fetch   [inline, inherited]
 

Fetch current record. You should use this method only if prefetch mode is disabled

template<class T>
T* dbCursor< T >::first   [inline]
 

Get pointer to the first record

Returns:
pointer to the first record or NULL if no records were selected

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.

template<class T>
T* dbCursor< T >::get   [inline]
 

Get pointer to the current record

Returns:
pointer to the current record or NULL if there is no current record

int dbAnyCursor::getNumberOfRecords   const [inline, inherited]
 

Get number of selected records

Returns:
number of selected records

void* dbAnyCursor::getRecord   [inline, inherited]
 

Get pointer to the location where fields of the current record are fetched

Returns:
pointer to the memory location set by cursor constructor or setRecord method

dbTableDescriptor* dbAnyCursor::getTable   [inline, inherited]
 

Get table for which cursor is opened

bool dbAnyCursor::hasNext   [inherited]
 

Check if there is more records in the selection

bool dbAnyCursor::isEmpty   const [inline, inherited]
 

Checks whether selection is empty

Returns:
true if there is no current record

bool dbAnyCursor::isFirst   [inherited]
 

Check whether current record is the first one in the selection

Returns:
true if prev() method will return NULL

bool dbAnyCursor::isInSelection oid_t    oid [inherited]
 

Check if record with specified OID is in selection

Returns:
true if record with such OID was selected

template<class T>
bool dbCursor< T >::isInSelection dbReference< T > &    ref [inline]
 

Check if record with specified OID is in selection

Returns:
true if record with such OID was selected

bool dbAnyCursor::isLast   [inherited]
 

Check whether current record is the last one in the selection

Returns:
true if next() method will return NULL

bool dbAnyCursor::isLimitReached   const [inline, inherited]
 

Checks whether limit for number of selected reacord is reached

Returns:
true if limit is reached

bool dbAnyCursor::isUpdateCursor   const [inline, inherited]
 

Check whether this cursor can be used for update

Returns:
true if it is update cursor

template<class T>
T* dbCursor< T >::last   [inline]
 

Get pointer to the last record

Returns:
pointer to the last record or NULL if no records were selected

template<class T>
T* dbCursor< T >::next   [inline]
 

Get next record

Returns:
pointer to the next record or NULL if there is no next record

template<class T>
T* dbCursor< T >::nextAvailable   [inline]
 

Method nextAvailable allows to iterate through the records in uniform way even when some records are removed. For example:

 if (cursor.select(q) > 0) { 
     do { 
         if (x) { 
             cursor.remove();
         } else { 
             cursor.update();
         }
     } while (cursor.nextAvaiable());
  }
     *
Returns:
pointer to the current record

template<class T>
T* dbCursor< T >::operator->   [inline]
 

Overloaded operator for accessing components of the current record

Returns:
pointer to the current record

template<class T>
T* dbCursor< T >::prev   [inline]
 

Get previous record

Returns:
pointer to the previous record or NULL if there is no previous record

template<class T>
T* dbCursor< T >::prevAvailable   [inline]
 

Method prevAvailable allows to iterate through the records in uniform way even when some records are removed. For example:

 if (cursor.select(q) > 0) { 
     cursor.last();
     do { 
         if (x) { 
             cursor.remove();
         } else { 
             cursor.update();
         }
     } while (cursor.prevAvaiable());
  }
     *
Returns:
pointer to the current record

void dbAnyCursor::remove   [inherited]
 

Remove current record

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

Reimplemented from dbL2List.

int dbAnyCursor::seek oid_t    oid [inherited]
 

Position cursor on the record with the specified OID

Parameters:
oid  object identifier of record
Returns:
poistion of the record in the selection or -1 if record with such OID is not in selection

template<class T>
int dbCursor< T >::seek dbReference< T > const &    ref [inline]
 

Position cursor on the record with the specified OID

Parameters:
ref  reference to the object
Returns:
poistion of the record in the selection or -1 if record with such OID is not in selection

int dbAnyCursor::select   [inline, inherited]
 

Select all records from the table with default cursor type

Returns:
number of selected records

int dbAnyCursor::select dbCursorType    aType [inline, inherited]
 

Select all records from the table

Parameters:
aType  cursor type: dbCursorForUpdate, dbCursorViewOnly
Returns:
number of selected records

int dbAnyCursor::select char const *    condition,
void *    paramStruct = NULL
[inline, inherited]
 

Execute query with default cursor type.

Parameters:
condition  selection criteria
paramStruct  pointer to structure with parameters.
Returns:
number of selected records

int dbAnyCursor::select char const *    condition,
dbCursorType    aType,
void *    paramStruct = NULL
[inline, inherited]
 

Execute query.

Parameters:
condition  selection criteria
aType  cursor type: dbCursorForUpdate, dbCursorViewOnly
paramStruct  pointer to structure with parameters.
Returns:
number of selected records

int dbAnyCursor::select dbQuery   query,
void *    paramStruct = NULL
[inline, inherited]
 

Execute query with default cursor type.

Parameters:
query  selection criteria
paramStruct  pointer to structure with parameters.
Returns:
number of selected records

int dbAnyCursor::select dbQuery   query,
dbCursorType    aType,
void *    paramStruct = NULL
[inline, inherited]
 

Execute query.

Parameters:
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.
Returns:
number of selected records

int dbAnyCursor::selectByKey char const *    key,
void const *    value
[inherited]
 

Select all records from the table with specfied value of the key

Parameters:
key  name of the key field
value  searched value of the key
Returns:
number of selected records

int dbAnyCursor::selectByKeyRange char const *    key,
void const *    minValue,
void const *    maxValue
[inherited]
 

Select all records from the table with specfied range of the key values

Parameters:
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
Returns:
number of selected records

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.

Parameters:
mode  if false then current record is not fetched. You should explicitly call fetch method if you want to fetch it.

void dbAnyCursor::setRecord void *    rec [inline, inherited]
 

Set destination for selected record rec - buffer to which fields of current record will be fetched

void dbAnyCursor::setSelectionLimit size_t    lim [inline, inherited]
 

Specify maximal number of records to be selected

void dbAnyCursor::setTable dbTableDescriptor   aTable [inline, inherited]
 

Set table for the cursor

Parameters:
aTable  table which records will be iterated

bool dbAnyCursor::skip int    n [inherited]
 

Skip specified number of records

Parameters:
n  if positive then skip n records forward, if negative then skip -n records backward
Returns:
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.

template<class T>
void dbCursor< T >::toArray dbArray< dbReference< T > > &    arr const [inline]
 

Convert selection to array of reference

Parameters:
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

Parameters:
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
Returns:
if arr is not null, then arr, otherwise array created by this method

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

void 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


The documentation for this class was generated from the following file:
Generated on Mon Oct 23 13:23:59 2006 for FastDB by doxygen1.2.18