kpilot

DatabaseInterpreter< kdetype, pilottype, mapper > Class Template Reference

A template class for reading and interpreting a database. More...

#include <pilotDatabase.h>

List of all members.


Public Member Functions

 DatabaseInterpreter (PilotDatabase *d)
PilotDatabasedb () const
kdetype * readNextModifiedRec (int *ind=NULL)
kdetype * readNextRecInCategory (int category)
kdetype * readRecordById (recordid_t id)
kdetype * readRecordByIndex (int index)

Protected Attributes

PilotDatabasefDB

Detailed Description

template<class kdetype, class pilottype, class mapper>
class DatabaseInterpreter< kdetype, pilottype, mapper >

A template class for reading and interpreting a database.

This removes the need for a lot of boilerplate code that does the conversions. Parameters are two interpretation classes: one for the KDE side of things (e.g. Event) and one that interprets the Pilot's records into a more sensible structure (e.g. PilotDatebookEntry). The mapping from the KDE type to the Pilot type and vice-versa is done by the mapper class's convert() functions.

To interpret a database as pilot-link interpretations (e.g. as PilotDatebookEntry records, not as Events) use the NullMapper class below in combination with a template instantiation with kdetype==pilottype.

The database interpreter intentionally has an interface similar to that of a PilotDatabase, but it isn't one.

Definition at line 192 of file pilotDatabase.h.


Constructor & Destructor Documentation

template<class kdetype , class pilottype , class mapper >
DatabaseInterpreter< kdetype, pilottype, mapper >::DatabaseInterpreter ( PilotDatabase d  )  [inline]

Constructor.

Interpret the database d.

Definition at line 218 of file pilotDatabase.h.


Member Function Documentation

template<class kdetype , class pilottype , class mapper >
PilotDatabase* DatabaseInterpreter< kdetype, pilottype, mapper >::db (  )  const [inline]

Retrieve the database pointer; this is useful to just pass around DatabaseInterpreter objects as if they are databases, and then perform DB operations on the database it wraps.

Definition at line 254 of file pilotDatabase.h.

template<class kdetype , class pilottype , class mapper >
kdetype* DatabaseInterpreter< kdetype, pilottype, mapper >::readNextModifiedRec ( int *  ind = NULL  )  [inline]

Reads the next record from database that has the dirty flag set.

If ind is non-NULL, *ind is set to the index of the current record (i.e. before the record pointer moves to the next modified record).

Definition at line 244 of file pilotDatabase.h.

template<class kdetype , class pilottype , class mapper >
kdetype* DatabaseInterpreter< kdetype, pilottype, mapper >::readNextRecInCategory ( int  category  )  [inline]

Reads the next record from database in category category.

Definition at line 233 of file pilotDatabase.h.

template<class kdetype , class pilottype , class mapper >
kdetype* DatabaseInterpreter< kdetype, pilottype, mapper >::readRecordById ( recordid_t  id  )  [inline]

Reads a record from database by id.

Definition at line 221 of file pilotDatabase.h.

template<class kdetype , class pilottype , class mapper >
kdetype* DatabaseInterpreter< kdetype, pilottype, mapper >::readRecordByIndex ( int  index  )  [inline]

Reads a record from database with index index.

Definition at line 227 of file pilotDatabase.h.


Member Data Documentation

template<class kdetype , class pilottype , class mapper >
PilotDatabase* DatabaseInterpreter< kdetype, pilottype, mapper >::fDB [protected]

Definition at line 257 of file pilotDatabase.h.


The documentation for this class was generated from the following file: