gSAFE
1.3.8
|
#include <datalib.h>
Public Member Functions | |
HFloatTables (HTable *baserec) | |
~HFloatTables (void) | |
void | allAliveToNew (void) |
int | clearMem (void) |
int | count (void) |
int | countAllStat (void) |
HTable * | createRecord (void) |
HTable * | createRecordAsUndef (void) |
int | deleteRecord (HTable *d) |
int | deleteRecord (int idx) |
void | first (void) |
HTable * | getTByField (QString field, QString key) |
HTable * | getTByKey (QString key) |
HTable * | getTByNum (int idx) |
void | markedRecordToNew (HTable *r) |
QString | nextKey (void) |
HTable * | nextRecord (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) |
HPlainDataMatrix * | submitNResultQuery (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) |
HSqlSingleInterface * | myInterface (void) |
QString | sqlConcatenateToLocal (QString string) |
QString | sqlConcatenateToLocal (QStringList fields) |
Public Member Functions inherited from HBase | |
HBase (void) | |
~HBase (void) | |
QString | getWhoami (void) |
Public Attributes | |
HTable * | baserecord |
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 HSqlSingleInterface * | currentDefaultSqlInterface (void) |
static HSqlSingleInterface * | getSqlInterface (QString interfacename) |
static void | setSqlMode (QString modename) |
static void | setSqlModeBackToFirst (void) |
Static Public Attributes inherited from HSqlHandler | |
static int | trans = 0 |
The HFloatTables handles an array of HTable (records). The HFloatTables enables you not to syncronize the data immediately with the database.
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
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.)
baserec | the 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.
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.
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.
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!)
the | pointer 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!)
the | index 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.
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
field | the a sql name of the filed which the value search in |
key | the value of the searched field |
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
key | the value of the key field |
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
idx | the index of the searched record |
Definition at line 4126 of file datalib.cpp.
void HFloatTables::markedRecordToNew | ( | HTable * | r | ) |
Marks the record as NEW. (Related adding a new record)
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.
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.
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.
tdisabled | if 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. |
filter | part of the SQL query. Where filter is "F" SELECT a,b,c... FROM tablename WHERE TRUE F; For example F = " AND deadline > date(now()) " |
Definition at line 4249 of file datalib.cpp.
|
inline |
void HFloatTables::removeUndef | ( | void | ) |
Removes all record which have UNDEF status. (Related adding a new record)
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.
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
fname | the name of the field to set |
value | the value to set |
Definition at line 4048 of file datalib.cpp.
|
inline |
QList<int>* HFloatTables::sts |
QList<HTable *>* HFloatTables::tbls |