Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Database Class Template Reference

interface to some of the PalmOS database functions Using this class: derive a new database class as public from this one passing your packed/unpacked structures as parameters. More...

#include <Database.h>

Inheritance diagram for Database:

GenericDB Collaboration diagram for Database:

Collaboration graph
[legend]
List of all members.

Public Methods

MemHandle getUnpackedRecord (UInt16 id, recordStructure *rec) DB_SECTION1
 get the unpacked strucure of a given record. More...

MemHandle getUnpackedRecord (recordStructure *rec) DB_SECTION1
 get the unpacked strucure of the current record. More...

MemHandle getUnpackedRecord (UInt32 uid, recordStructure *rec) DB_SECTION1
 get the unpacked strucure of a given record. More...

 Database (DmOpenRef db_open_ref)
 constructor use when in need to access functions like pack/unpack from a static function. More...

 Database (UInt32 type, UInt32 creator, Char *db_name)
 initialize the databases. More...

 Database (UInt32 type, UInt32 creator, Char *db_name, UInt16 categ_string)
 initialize the databases. More...

virtual ~Database () DB_SECTION1
 closes the database. More...

virtual void unpackRecord (recordStructure *rec, packedRecordStructure *packed_rec)=0
 unpacks a record. More...

virtual void packRecord (recordStructure *rec, MemHandle db_entry)=0
 packs an account record. More...

virtual UInt16 newRecord (recordStructure *rec) DB_SECTION1
 packs and writes the data from rec at the end of the database. More...


Detailed Description

template<class recordStructure, class packedRecordStructure>
class Database< recordStructure, packedRecordStructure >

interface to some of the PalmOS database functions Using this class: derive a new database class as public from this one passing your packed/unpacked structures as parameters.

in your new class override the pure virtual function from this class and add anything you might thing useful

Definition at line 31 of file Database.h.


Constructor & Destructor Documentation

template<class recordStructure, class packedRecordStructure>
Database< recordStructure, packedRecordStructure >::Database DmOpenRef    db_open_ref [inline]
 

constructor use when in need to access functions like pack/unpack from a static function.

Parameters:
db_open_ref  reference to an *already* opened database

Definition at line 55 of file Database.h.

template<class recordStructure, class packedRecordStructure>
Database< recordStructure, packedRecordStructure >::Database UInt32    type,
UInt32    creator,
Char *    db_name
[inline]
 

initialize the databases.

Parameters:
creator  database creator
db_name  name of the database
type  type of the database (ex. 'DATA')

Definition at line 61 of file Database.h.

template<class recordStructure, class packedRecordStructure>
Database< recordStructure, packedRecordStructure >::Database UInt32    type,
UInt32    creator,
Char *    db_name,
UInt16    categ_string
[inline]
 

initialize the databases.

Parameters:
type  type of the database (ex. 'DATA')
creator  database creator
db_name  - name of the database
categ_string  - id of the category resource to be used to initialise the categories for this database

Definition at line 68 of file Database.h.

template<class recordStructure, class packedRecordStructure>
Database< recordStructure, packedRecordStructure >::~Database   [virtual]
 

closes the database.

Definition at line 152 of file Database.h.


Member Function Documentation

template<class recordStructure, class packedRecordStructure>
MemHandle Database< recordStructure, packedRecordStructure >::getUnpackedRecord UInt32    uid,
recordStructure *    rec
 

get the unpacked strucure of a given record.

Parameters:
uid  unique id of the account record
rec  pointer in which the unpacked data will be saved
Returns:
pointer to the record handler (of the packed record) or NULL if error

Definition at line 90 of file Database.h.

References GenericDB::getRecordId, and getUnpackedRecord.

template<class recordStructure, class packedRecordStructure>
MemHandle Database< recordStructure, packedRecordStructure >::getUnpackedRecord recordStructure *    rec
 

get the unpacked strucure of the current record.

Parameters:
rec  pointer in which the unpacked data will be saved
Returns:
pointer to the record handler (of the packed record) or null if error

Definition at line 120 of file Database.h.

References getUnpackedRecord, GenericDB::isRecordSelected, and GenericDB::selected_record.

template<class recordStructure, class packedRecordStructure>
MemHandle Database< recordStructure, packedRecordStructure >::getUnpackedRecord UInt16    id,
recordStructure *    rec
 

get the unpacked strucure of a given record.

Parameters:
id  id of the account record
rec  pointer in which the unpacked data will be saved
Returns:
pointer to the record handler (of the packed record) or null if error

Definition at line 96 of file Database.h.

References GenericDB::ref, and unpackRecord.

Referenced by getUnpackedRecord.

template<class recordStructure, class packedRecordStructure>
UInt16 Database< recordStructure, packedRecordStructure >::newRecord recordStructure *    rec [virtual]
 

packs and writes the data from rec at the end of the database.

Returns:
the index to the record

Reimplemented in AccountsDB.

Definition at line 127 of file Database.h.

References GenericDB::current_cat, packRecord, GenericDB::ref, and GenericDB::setRecordCategory.

template<class recordStructure, class packedRecordStructure>
virtual void Database< recordStructure, packedRecordStructure >::packRecord recordStructure *    rec,
MemHandle    db_entry
[pure virtual]
 

packs an account record.

This function should be overloaded by all database classes

Parameters:
rec  pointer to the record to be packed
db_entry  pointer to the newly allocated packed record

Implemented in AccountsDB.

Referenced by newRecord.

template<class recordStructure, class packedRecordStructure>
virtual void Database< recordStructure, packedRecordStructure >::unpackRecord recordStructure *    rec,
packedRecordStructure *    packed_rec
[pure virtual]
 

unpacks a record.

Parameters:
rec  the record pacxked_rec will be unpacked into this location
packed_rec  pointer to the record to be unpacked

Implemented in AccountsDB.

Referenced by getUnpackedRecord.


The documentation for this class was generated from the following file:
Generated on Thu Jan 16 23:11:14 2003 for FreeCoins by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002