gSAFE  1.3.8
Public Member Functions | Public Attributes | Protected Attributes | List of all members
HFloatTables Class Reference

#include <datalib.h>

Inheritance diagram for HFloatTables:
HSqlHandler HSqlInterface HBase

Public Member Functions

 HFloatTables (HTable *baserec)
 
 ~HFloatTables (void)
 
void allAliveToNew (void)
 
int clearMem (void)
 
int count (void)
 
int countAllStat (void)
 
HTablecreateRecord (void)
 
HTablecreateRecordAsUndef (void)
 
int deleteRecord (HTable *d)
 
int deleteRecord (int idx)
 
void first (void)
 
HTablegetTByField (QString field, QString key)
 
HTablegetTByKey (QString key)
 
HTablegetTByNum (int idx)
 
void markedRecordToNew (HTable *r)
 
QString nextKey (void)
 
HTablenextRecord (void)
 
int readDBTable (QString filter, bool tdisabled=false)
 
int recordCount (void)
 
void removeUndef (void)
 
int saveDBTable (bool tdisabled=false)
 
void setAllField (QString fname, QVariant value)
 
QString sqlTableName (void)
 
- Public Member Functions inherited from HSqlHandler
 HSqlHandler (void)
 
 ~HSqlHandler (void)
 
QSqlQuery * allocateQSqlQuery (void)
 
void cloneSqlSettingsFrom (HSqlHandler *other)
 
void commit (void)
 
bool errorStatus (void)
 
void rollback (void)
 
bool submit0ResultQuery (QString q, QString err, bool tdisabled=false)
 
QVariant submit1ResultQuery (QString q, QString err, bool tdisabled=false)
 
HPlainDataMatrixsubmitNResultQuery (int N, QString q, QString err, bool tdisabled=false)
 
void transaction (void)
 
QSqlDatabase workDB (void)
 
- Public Member Functions inherited from HSqlInterface
 HSqlInterface ()
 
 ~HSqlInterface ()
 
void cloneSqlInterfaceSettingsFrom (HSqlInterface *other)
 
HSqlSingleInterfacemyInterface (void)
 
QString sqlConcatenateToLocal (QString string)
 
QString sqlConcatenateToLocal (QStringList fields)
 
- Public Member Functions inherited from HBase
 HBase (void)
 
 ~HBase (void)
 
QString getWhoami (void)
 

Public Attributes

HTablebaserecord
 
QList< int > * sts
 
QList< HTable * > * tbls
 

Protected Attributes

bool fiter
 
QList< int >::iterator siter
 
QString sqlTable
 
QList< HTable * >::iterator titer
 
- Protected Attributes inherited from HSqlHandler
bool query_error_occured
 
- Protected Attributes inherited from HBase
QString whoami
 

Additional Inherited Members

- Signals inherited from HSqlHandler
void errorSignal (QString err)
 
- Static Public Member Functions inherited from HSqlHandler
static void setCustomSqlDatabase (QString databaseName, QString sqlinterfacename="")
 
static void setDefaultSqlDatabase (void)
 
- Static Public Member Functions inherited from HSqlInterface
static HSqlSingleInterfacecurrentDefaultSqlInterface (void)
 
static HSqlSingleInterfacegetSqlInterface (QString interfacename)
 
static void setSqlMode (QString modename)
 
static void setSqlModeBackToFirst (void)
 
- Static Public Attributes inherited from HSqlHandler
static int trans = 0
 

Detailed Description

The HFloatTables handles an array of HTable (records). The HFloatTables enables you not to syncronize the data immediately with the database.

hfloattables.png

So in nutshell, you can read some records from the database and modify, delete and add records in the memory wihout touching the sql database. After you manupulate this records (Which are HTable instances) you can store this record array with a single function. The HFloatTables will handle every change correctly in the database. It will delete the erased reccords, run update on the modified records, and do the necessary inserts to add the new ones. Ideal for that cases when you manipulate a bigger data structure, and don't want to apply the partial modifications to the database. That case you can use one or more HFloatTables to do the canges, and when every change is finished you can store all in the database in one transaction.
The members can have 5 different state:

You can use the HFloatTables as HList (Put in a HDispList) with the HFloatTablesAsHList class

Definition at line 1610 of file datalib.h.

Constructor & Destructor Documentation

HFloatTables::HFloatTables ( HTable baserec)

Constructor. Created an empty HFloatTables with a base HTable record which act as a template record. The HFloatTables will contain that kind of records which the constructor gets in parameter. The table names come from that template record too. (Each record will be cloned from that template record.)

Parameters
baserecthe template/base record. When you delete the HFloatTables the baserecord will be deleted too!

Definition at line 3947 of file datalib.cpp.

HFloatTables::~HFloatTables ( void  )

Destructor. Deletes the base record too.

Definition at line 3993 of file datalib.cpp.

Member Function Documentation

void HFloatTables::allAliveToNew ( void  )

Sets the status of every ALIVE and NEW record to NEW. Useful to duplicate/or re-store a record in the database because it tell the system to INSERT every record to the database (not update or skip)

Definition at line 4056 of file datalib.cpp.

int HFloatTables::clearMem ( void  )

Clears the HFloatTables's records. (This does not do any SQL work!)

Definition at line 3973 of file datalib.cpp.

int HFloatTables::count ( void  )

Returns the element number of the HFloatTables. (Record number) It is only count the ALIVE and NEW status elements. Nor the deleted and undefined records.

Definition at line 4073 of file datalib.cpp.

int HFloatTables::countAllStat ( void  )

Returns the element number of the HFloatTables in all state. (Record number) It is count the elements in all state, deleted and undefined too.

Definition at line 4068 of file datalib.cpp.

HTable * HFloatTables::createRecord ( void  )

Adding a new record to the HFloatTables. (This does not do any SQL work!) You can ask a new HFloatTable record with this function. After you received the pointer you can fill the values of that HTable (or pu to gui, etc...) Every HFloatTable records have to created this way!
This function creates the record with NEW state. This mean that this record will be inserted to the database.

See Also
createRecordAsUndef()
Returns
the new record's pointer (Clone of baserecord)

Definition at line 4149 of file datalib.cpp.

HTable * HFloatTables::createRecordAsUndef ( void  )

Adding a new record to the HFloatTables. (This does not do any SQL work!) You can ask a new HFloatTable record with this function. After you received the pointer you can fill the values of that HTable (or show with gui, etc...) Every HFloatTable records have to created this way!
This function creates the record with UNDEF state. This means that we don't know the future of this record. Later you can call markedRecordToNew() function to make this record to valid, or call removeUndef() to cancel this record. This method is useful when you insert a new value with gui. First you get an instance which is showed by gui. After the user fill the gui, we call markedRecordToNew() if the user accepts the gui, or removeUndef() if the user cancell the dialog.

See Also
createRecord()
markedRecordToNew()
removeUndef()
Returns
the new record's pointer (Clone of baserecord)

Definition at line 4161 of file datalib.cpp.

int HFloatTables::deleteRecord ( HTable d)

Erase a record from the HFloatTable (This does not do any SQL work!)

Parameters
thepointer of the element to delete

Definition at line 4218 of file datalib.cpp.

int HFloatTables::deleteRecord ( int  idx)

Erase a record from the HFloatTable (This does not do any SQL work!)

Parameters
theindex of the element to delete

Definition at line 4244 of file datalib.cpp.

void HFloatTables::first ( void  )

Step through the elements of HFloatTables. You can step through all elements by calling the first() and touch all all elements by calling nextRecord() or nextKey() until it is return NULL or empty string.

See Also
nextRecord()
nextKey()

Definition at line 4003 of file datalib.cpp.

HTable * HFloatTables::getTByField ( QString  field,
QString  key 
)

Returns an ALIVE or a NEW element (HTable *) from the table by value of a field

Parameters
fieldthe a sql name of the filed which the value search in
keythe value of the searched field
Returns
returns that record which contains the searched field with the specified value

Definition at line 4090 of file datalib.cpp.

HTable * HFloatTables::getTByKey ( QString  key)

Returns an ALIVE or a NEW element (HTable *) from the table by their key value

Parameters
keythe value of the key field
Returns
returns that record which contains the key with the specified value

Definition at line 4108 of file datalib.cpp.

HTable * HFloatTables::getTByNum ( int  idx)

Returns an ALIVE or a NEW element (HTable *) from the table by the index

Parameters
idxthe index of the searched record
Returns
the requested record

Definition at line 4126 of file datalib.cpp.

void HFloatTables::markedRecordToNew ( HTable r)

Marks the record as NEW. (Related adding a new record)

See Also
createRecordAsUndef()

Definition at line 4173 of file datalib.cpp.

QString HFloatTables::nextKey ( void  )

Step through the elements of HFloatTables. You can step through all elements by calling the first() and touch all all elements by calling nextRecord() or nextKey() until it is return NULL or empty string.

See Also
first()
nextRecord()
Returns
the value of the current record's key or empty string if we reach the end of the table.

Definition at line 4039 of file datalib.cpp.

HTable * HFloatTables::nextRecord ( void  )

Step through the elements of HFloatTables. You can step through all elements by calling the first() and touch all all elements by calling nextRecord() or nextKey() until it is return NULL or empty string.

See Also
first()
nextKey()
Returns
the pointer of the current record (as HTable *) or NULL if we reach the end of the table.

Definition at line 4010 of file datalib.cpp.

int HFloatTables::readDBTable ( QString  filter,
bool  tdisabled = false 
)

Reads a list of records from the SQL database to this HFloatTables. The query is builded according to the baserecord. Every row which are returned by query will be appear in HFloatTables as a record marked ALIVE.

Parameters
tdisabledif this parameter false the save runs in a separate transaction so the function starts a transaction and to a commit after its, otherwise (true) the function doesn't call any transaction related things.
filterpart of the SQL query. Where filter is "F"
SELECT a,b,c... FROM tablename WHERE TRUE F;
For example F = " AND deadline > date(now()) "
See Also
HFloatTables

Definition at line 4249 of file datalib.cpp.

int HFloatTables::recordCount ( void  )
inline

Returns the number of records in this HFloatTable. Same as count().

Definition at line 1643 of file datalib.h.

void HFloatTables::removeUndef ( void  )

Removes all record which have UNDEF status. (Related adding a new record)

See Also
createRecordAsUndef()

Definition at line 4197 of file datalib.cpp.

int HFloatTables::saveDBTable ( bool  tdisabled = false)

Store the current records of the HFloatTable to the SQL database. Every record is handled according their state.

See Also
HFloatTables

Definition at line 4313 of file datalib.cpp.

void HFloatTables::setAllField ( QString  fname,
QVariant  value 
)

Sets a specified field to a specified value in every record

Parameters
fnamethe name of the field to set
valuethe value to set

Definition at line 4048 of file datalib.cpp.

QString HFloatTables::sqlTableName ( void  )
inline

Returns the sql name of the table. (Comes from the base record)

Definition at line 1637 of file datalib.h.

Member Data Documentation

HTable* HFloatTables::baserecord

The base record

Definition at line 1620 of file datalib.h.

QList<int>* HFloatTables::sts

List, stores the status of the records

Definition at line 1622 of file datalib.h.

QList<HTable *>* HFloatTables::tbls

List, stores the records itself

Definition at line 1624 of file datalib.h.


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