Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

DBStore Class Reference

The DBStore class is the class responsible for storing, sorting and searching the data loaded by the application. More...

#include </home/clem/local/src/opie/noncore/apps/tableviewer/db/datacache.h>

Collaboration diagram for DBStore:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 DBStore ()
 ~DBStore ()
bool openSource (QIODevice *, const QString &source)
bool saveSource (QIODevice *, const QString &source)
void addItem (DataElem *)
void addItemInternal (DataElem *)
void removeItem (DataElem *)
void setName (const QString &name)
QString getName ()
KeyListgetKeys ()
void setKeys (KeyList *)
int getNumFields ()
int getKeyIndex (QString qs)
TVVariant::KeyType getKeyType (int i)
QString getKeyName (int i)
void first ()
void last ()
bool next ()
bool previous ()
DataElemgetCurrentData ()

Private Member Functions

void freeTable ()

Private Attributes

QString name
QVector< DataElemmaster_table
DBAccessarchive
KeyListkRep
unsigned int number_elems
unsigned int table_size
bool full
unsigned int current_elem

Detailed Description

The DBStore class is the class responsible for storing, sorting and searching the data loaded by the application.

Definition at line 68 of file datacache.h.


Constructor & Destructor Documentation

DBStore::DBStore  ) 
 

Constructs a DBStore item

Definition at line 53 of file datacache.cpp.

References archive, current_elem, full, INIT_TABLE_SIZE, kRep, master_table, name, number_elems, and table_size.

DBStore::~DBStore  ) 
 

Removes all items from the DBStore and destroys the DBStore

Definition at line 90 of file datacache.cpp.

References freeTable().


Member Function Documentation

void DBStore::addItem DataElem delem  ) 
 

This function is used to add new elements to the database. If the database has already reached the maximum allowable size this function does not alter the database.

Parameters:
delm An already allocated and initialized data element to be added

Definition at line 152 of file datacache.cpp.

References addItemInternal().

Referenced by DBXmlHandler::endElement(), TableViewerWindow::newItemSlot(), and DBCsv::openSource().

void DBStore::addItemInternal DataElem  ) 
 

Definition at line 157 of file datacache.cpp.

References current_elem, full, master_table, number_elems, oendl, owarn, and table_size.

Referenced by addItem().

void DBStore::first  ) 
 

Sets the current element to the first element of the database

Definition at line 240 of file datacache.cpp.

References current_elem.

Referenced by TableViewerWindow::applyFilter(), TableViewerWindow::editKeysSlot(), TableViewerWindow::openDocument(), DBXml::saveSource(), and DBCsv::saveSource().

void DBStore::freeTable  )  [private]
 

Reinitializes the table to empty (include a resize of the master table, which should free some memory)

Definition at line 71 of file datacache.cpp.

References archive, QIntDict< type >::clear(), current_elem, full, INIT_TABLE_SIZE, kRep, master_table, name, number_elems, and table_size.

Referenced by openSource(), and ~DBStore().

DataElem * DBStore::getCurrentData  ) 
 

Returns the current data element in the database. Which element is current is affected by newly added items, findItem, next, previous, first and last functions

Returns:
a pointer to the current data element

Definition at line 296 of file datacache.cpp.

References current_elem, master_table, NULL, and number_elems.

Referenced by TableViewerWindow::applyFilter(), TableViewerWindow::editKeysSlot(), TableViewerWindow::openDocument(), DBXml::saveSource(), and DBCsv::saveSource().

int DBStore::getKeyIndex QString  qs  )  [inline]
 

gets the index of a key given its name

Definition at line 96 of file datacache.h.

References KeyList::getKeyIndex(), and kRep.

Referenced by DataElem::getField(), DataElem::getFieldType(), DataElem::hasValidValue(), DataElem::setField(), and DataElem::unsetField().

QString DBStore::getKeyName int  i  )  [inline]
 

gets the name of a key given its index

Definition at line 106 of file datacache.h.

References KeyList::getKeyName(), and kRep.

Referenced by DataElem::toQString().

KeyList * DBStore::getKeys  ) 
 

Retrieves a pointer to the key representation of the database for other classes to use as reference.

Returns:
a pointer to the databases key representaion

Definition at line 223 of file datacache.cpp.

References kRep.

Referenced by DataElem::getKeys(), DataElem::hasValidValue(), TableViewerWindow::newDocument(), TableViewerWindow::openDocument(), DBXml::saveSource(), DBCsv::saveSource(), and TableViewerWindow::TableViewerWindow().

TVVariant::KeyType DBStore::getKeyType int  i  )  [inline]
 

gets the type of a key given its index

Definition at line 101 of file datacache.h.

References KeyList::getKeyType(), and kRep.

Referenced by DataElem::getFieldType(), DBXml::saveSource(), DataElem::setField(), and DataElem::toSortableQString().

QString DBStore::getName void   ) 
 

Gets the name of the database

Returns:
A string representing the name of the database.

Definition at line 212 of file datacache.cpp.

References name.

Referenced by TableViewerWindow::openDocument(), and DBXml::saveSource().

int DBStore::getNumFields  )  [inline]
 

gets the number of fields defined in the database

Definition at line 91 of file datacache.h.

References KeyList::getNumFields(), and kRep.

Referenced by DataElem::DataElem(), and DataElem::getNumFields().

void DBStore::last  ) 
 

Sets the current element to the last element of the database

Definition at line 248 of file datacache.cpp.

References current_elem, and number_elems.

bool DBStore::next  ) 
 

Sets the current element to the next element of the database if there exists an element after the current one.

Definition at line 257 of file datacache.cpp.

References current_elem, and number_elems.

Referenced by TableViewerWindow::applyFilter(), TableViewerWindow::editKeysSlot(), TableViewerWindow::openDocument(), DBXml::saveSource(), and DBCsv::saveSource().

bool DBStore::openSource QIODevice inDev,
const QString source
 

This function opens the given xml file, loads it and sets up the appropriate data structures.

Parameters:
file_name A string representing the name of the file to be opened
Returns:
true if successful, false otherwise.

Definition at line 102 of file datacache.cpp.

References archive, freeTable(), number_elems, and DBAccess::openSource().

Referenced by TableViewerWindow::openDocument().

bool DBStore::previous  ) 
 

Sets the current element to the previous element of the database if there exists an element before the current one.

Definition at line 275 of file datacache.cpp.

References current_elem, and number_elems.

void DBStore::removeItem DataElem  ) 
 

Definition at line 185 of file datacache.cpp.

References master_table, and number_elems.

Referenced by TableViewerWindow::deleteItemSlot().

bool DBStore::saveSource QIODevice ,
const QString source
 

Definition at line 119 of file datacache.cpp.

References archive, DBAccess::saveSource(), and DBAccess::type().

Referenced by TableViewerWindow::saveDocument().

void DBStore::setKeys KeyList k  ) 
 

sets the database's key representation the passed pointer

Parameters:
a pointer to a key representaton

Definition at line 232 of file datacache.cpp.

References kRep.

Referenced by TableViewerWindow::editKeysSlot(), DBXmlHandler::endElement(), and DBCsv::openSource().

void DBStore::setName const QString n  ) 
 

Sets the name of the database

Parameters:
n A string representing the new name of the database.

Definition at line 202 of file datacache.cpp.

References name.

Referenced by DBXmlHandler::startElement().


Member Data Documentation

DBAccess* DBStore::archive [private]
 

Definition at line 126 of file datacache.h.

Referenced by DBStore(), freeTable(), openSource(), and saveSource().

unsigned int DBStore::current_elem [private]
 

Definition at line 134 of file datacache.h.

Referenced by addItemInternal(), DBStore(), first(), freeTable(), getCurrentData(), last(), next(), and previous().

bool DBStore::full [private]
 

Definition at line 132 of file datacache.h.

Referenced by addItemInternal(), DBStore(), and freeTable().

KeyList* DBStore::kRep [private]
 

Definition at line 128 of file datacache.h.

Referenced by DBStore(), freeTable(), getKeyIndex(), getKeyName(), getKeys(), getKeyType(), getNumFields(), and setKeys().

QVector<DataElem> DBStore::master_table [private]
 

Definition at line 125 of file datacache.h.

Referenced by addItemInternal(), DBStore(), freeTable(), getCurrentData(), and removeItem().

QString DBStore::name [private]
 

Definition at line 123 of file datacache.h.

Referenced by DBStore(), freeTable(), getName(), and setName().

unsigned int DBStore::number_elems [private]
 

Definition at line 130 of file datacache.h.

Referenced by addItemInternal(), DBStore(), freeTable(), getCurrentData(), last(), next(), openSource(), previous(), and removeItem().

unsigned int DBStore::table_size [private]
 

Definition at line 131 of file datacache.h.

Referenced by addItemInternal(), DBStore(), and freeTable().


The documentation for this class was generated from the following files:
Generated on Sat Nov 5 17:30:47 2005 for OPIE by  doxygen 1.4.2