StDbSql.hh
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
#ifndef STDATABASE_HH
00067
#define STDATABASE_HH
00068
00069
#include "StDbTableDescriptor.h"
00070
#include "StDbManager.hh"
00071
#include "StDataBaseI.hh"
00072
#include "MysqlDb.h"
00073
#include "StDbBuffer.h"
00074
00075
#include <list>
00076
#ifdef ST_NO_TEMPLATE_DEF_ARGS
00077
typedef list<StDbTableDescriptor*,allocator<StDbTableDescriptor*> >
DescList;
00078
#else
00079
#if !defined(ST_NO_NAMESPACES)
00080
using std::list;
00081
#endif
00082
00083
#ifdef HPUX
00084
#define freeze(i) str()
00085
#endif
00086
00087 typedef list<StDbTableDescriptor*>
DescList;
00088
#endif
00089
00090 #define MAX_EID_INDECES 10
00091
00092 class StDbSql :
public StDataBaseI {
00093
00094
protected:
00095
00096 StDbManager*
mgr;
00097
00098
00099 DescList mdescriptors;
00100
00101 char*
mretString;
00102 int mtableCatalog;
00103 char*
mdefaultEndDateTime;
00104 unsigned int mdefaultEndTime;
00105
00106
00107
StDbTableDescriptor*
findDescriptor(
int structID,
int schemaID);
00108
StDbTableDescriptor*
getDescriptor(
int structID,
int schemaID);
00109
void addDescriptor(
StDbTableDescriptor* td);
00110
void deleteDescriptors();
00111
void deleteDescriptor(
int structID,
int schemaID);
00112
00113
int prepareNode(
StDbNode* node);
00114
int queryNode(
StDbNode* node);
00115
bool readNodeInfo(
StDbNode* node);
00116
bool readConfigNodeInfo(
StDbConfigNode* node);
00117
bool readTableInfo(
StDbTable* table);
00118
bool checkValue(
const char* colName,
const char* colValue);
00119
bool checkForNull(
const char* src);
00120
00121
00122
char*
insertNodeString(
StDbNode* node);
00123
char*
getFlavorQuery(
const char* flavor);
00124
char*
getProdTimeQuery(
unsigned int prodTime);
00125
char*
getElementList(
int* elements,
int num);
00126
char*
getElementListIN(
int* elements,
int num);
00127
char*
getColumnList(
StDbTable* table,
char* tableName=0,
char* funcName=0);
00128
char*
getEmptyString();
00129
00130
bool hasInstance(
StDbTable* table);
00131
void checkTableCatalog();
00132
char*
checkTablePrepForQuery(
StDbTable* table,
bool checkIndexed=
false);
00133
00134
void deleteRows(
const char* tableName,
int* rowID,
int nrows);
00135
void initEndTime();
00136
00137
char*
mRetString(
StString& rs);
00138
int sendMess(
const char* a,
const char* b, StDbMessLevel m,
00139
int lineNum=0,
const char* className=
" ",
00140
const char* methName=
" ");
00141
00142
00143
bool checkColumn(
const char* tableName,
const char* columnName);
00144
bool updateEndTime(
StDbTable* table,
const char* dataTable,
unsigned int reqTime);
00145
void init();
00146
00147
00148
virtual int WriteDbNoIndex(
StDbTable* table,
unsigned int storeTime);
00149
00150
00151
public:
00152
00153
StDbSql(
MysqlDb &db,
StDbBuffer& buffer);
00154
StDbSql(
MysqlDb &db,
StDbBuffer& buffer,
00155 StDbType type, StDbDomain domain);
00156
StDbSql(
MysqlDb &db,
StDbBuffer& buffer,
00157
const char* typeName,
const char* domainName);
00158
00159
virtual ~StDbSql();
00160
00161
virtual void use();
00162
virtual void close();
00163
virtual void clear();
00164
00165
virtual int QueryDb(
StDbConfigNode* node);
00166
virtual int QueryDb(
StDbNode* node);
00167
virtual int QueryDb(
StDbTable* table,
unsigned int reqTime);
00168
virtual int QueryDb(
StDbTable* table,
const char* whereClause);
00169
virtual unsigned int*
QueryDbTimes(
StDbTable* table,
const char* whereClause,
int opt=0);
00170
virtual int QueryDbFunction(
StDbTable* table,
const char* whereClause,
char* funcName);
00171
virtual int QueryDescriptor(
StDbTable* table);
00172
virtual int WriteDb(
StDbTable* table,
unsigned int storeTime);
00173
virtual int WriteDb(
StDbConfigNode* node,
int parentID,
int& configID);
00174
00175
virtual int storeConfigNode(
StDbConfigNode* node);
00176
virtual int storeTableNode(
StDbTable* table);
00177
virtual bool insertNodeRelation(
int configID,
int parent,
int child);
00178
virtual bool rollBack(
StDbNode* node);
00179
virtual bool rollBack(
StDbTable* table);
00180
00181
virtual unsigned int getUnixTime(
const char* time) ;
00182
virtual char*
getDateTime(
unsigned int time) ;
00183
00184
virtual int*
selectElements(
const char* elementName,
00185
StDbElementIndex* inval,
00186
int& numElements);
00187
00188
char*
getDataTable(
StDbTable* table,
unsigned int time);
00189
char**
getDataTables(
StDbTable* table,
int& numTables);
00190
void setDbUtils(
MysqlDb& db,
StDbBuffer& buffer);
00191
void setDefaultReturnValues(
StDbTable* table,
unsigned int reqTime);
00192
void setDefaultBeginTime(
StDbTable* table,
unsigned int reqTime);
00193
void setDefaultEndTime(
StDbTable* table );
00194
char**
getIndexNames(
const char* elementName,
int& numIndexes);
00195
00196 MysqlDb&
Db;
00197 StDbBuffer&
buff;
00198
00199 };
00200
00201 inline char*
StDbSql::mRetString(
StString& rs){
00202
if(
mretString)
delete []
mretString;
00203 string srs=rs.
str();
00204
mretString =
new char[srs.length()+1];
00205 strcpy(
mretString,srs.c_str());
00206
return mretString;
00207 }
00208
00209 inline int StDbSql::sendMess(
const char* a,
const char* b, StDbMessLevel m,
int lineNum,
const char* className,
const char* methName){
00210
if(m==
dbMDebug && !(
mgr->
IsVerbose()))
return 0;
00211
return mgr->
printInfo(a,b,m,lineNum,className,methName);
00212 }
00213
00214 inline void StDbSql::init() {
00215
mretString = 0;
00216
mtableCatalog=0;
00217
mdefaultEndDateTime = 0;
00218 }
00219
00220 inline void StDbSql::use() {
Db.
setDefaultDb(mdbName); };
00221 inline void StDbSql::close() {
Db.
Close(); };
00222 inline void StDbSql::clear() {
Db.
Release();
buff.
Raz(); };
00223
00224
#endif
00225
00226
00227
00228
00229
Generated on Thu Aug 24 14:45:27 2006 for Doxygen by
1.3.7