00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00021
00022 #include "TObject.h"
00023
00024 #include "DatabaseInterface/test/DbiDemoData3.h"
00025 #include "MessageService/MsgService.h"
00026 #include "DatabaseInterface/DbiResultSet.h"
00027 #include "DatabaseInterface/DbiOutRowStream.h"
00028 #include "DatabaseInterface/DbiValidityRec.h"
00029 #include <cmath>
00030
00031 ClassImp(DbiDemoData3)
00032
00033
00034
00035
00036 CVSID("$Id: DbiDemoData3.cxx,v 1.24 2008/03/05 06:59:21 west Exp $\n \
00037 CVSID_DBIRESULTPTR ");
00038
00039
00040
00041
00042 string DbiDemoData3::GetTableDescr(const char* alternateName ) {
00043
00044
00045
00046
00047
00048 string sql("create table ");
00049 if ( alternateName ) sql += alternateName;
00050 else sql += "DBIDEMODATA3";
00051 sql += "( SEQNO INT NOT NULL,";
00052 sql += " ROW_COUNTER INT NOT NULL,";
00053 sql += " MYBOOL_1 CHAR,";
00054 sql += " MYBOOL_2 CHAR,";
00055 sql += " MYCHAR CHAR,";
00056 sql += " MYSTRING TEXT,";
00057 sql += " MYCHARS CHAR(20),";
00058 sql += " MYCHARS2 CHAR(2),";
00059 sql += " MY_SS_TINY_1 TINYINT,";
00060 sql += " MY_SS_TINY_2 TINYINT,";
00061 sql += " MY_SS_TINY_3 TINYINT,";
00062 sql += " MY_SS_TINY_4 TINYINT,";
00063 sql += " MY_UU_TINY_1 TINYINT UNSIGNED,";
00064 sql += " MY_UU_TINY_2 TINYINT UNSIGNED,";
00065 sql += " MY_UU_TINY_3 TINYINT UNSIGNED,";
00066 sql += " MY_UU_TINY_4 TINYINT UNSIGNED,";
00067 sql += " MY_US_TINY_1 TINYINT,";
00068 sql += " MY_US_TINY_2 TINYINT,";
00069 sql += " MY_US_TINY_3 TINYINT,";
00070 sql += " MY_US_TINY_4 TINYINT,";
00071 sql += " MY_SS_SHORT_1 SMALLINT,";
00072 sql += " MY_SS_SHORT_2 SMALLINT,";
00073 sql += " MY_SS_SHORT_3 SMALLINT,";
00074 sql += " MY_SS_SHORT_4 SMALLINT,";
00075 sql += " MY_UU_SHORT_1 SMALLINT UNSIGNED,";
00076 sql += " MY_UU_SHORT_2 SMALLINT UNSIGNED,";
00077 sql += " MY_UU_SHORT_3 SMALLINT UNSIGNED,";
00078 sql += " MY_UU_SHORT_4 SMALLINT UNSIGNED,";
00079 sql += " MY_US_SHORT_1 SMALLINT,";
00080 sql += " MY_US_SHORT_2 SMALLINT,";
00081 sql += " MY_US_SHORT_3 SMALLINT,";
00082 sql += " MY_US_SHORT_4 SMALLINT,";
00083 sql += " MY_SS_INT_1 INT,";
00084 sql += " MY_SS_INT_2 INT,";
00085 sql += " MY_SS_INT_3 INT,";
00086 sql += " MY_SS_INT_4 INT,";
00087 sql += " MY_US_INT_1 INT,";
00088 sql += " MY_US_INT_2 INT,";
00089 sql += " MY_US_INT_3 INT,";
00090 sql += " MY_US_INT_4 INT,";
00091 sql += " MYFLOAT_1 FLOAT,";
00092 sql += " MYFLOAT_2 FLOAT,";
00093 sql += " MYDOUBLE_1 DOUBLE,";
00094 sql += " MYDOUBLE_2 DOUBLE,";
00095 sql += " primary key(SEQNO,ROW_COUNTER))";
00096 return sql;
00097 }
00098
00099
00100
00101
00102 #include "DatabaseInterface/DbiResultPtr.tpl"
00103 template class DbiResultPtr<DbiDemoData3>;
00104
00105 #include "DatabaseInterface/DbiWriter.tpl"
00106 template class DbiWriter<DbiDemoData3>;
00107
00108
00109
00110
00111 namespace {
00112
00113
00114
00115 template<class T> void CompareValue(const T& thisValue,
00116 const T& thatValue,
00117 const char* name,
00118 bool printDiff,
00119 bool& matchedSofar) {
00120
00121 if ( thisValue == thatValue ) return;
00122 if ( printDiff ) {
00123 if ( matchedSofar )
00124 MSG("Dbi",Msg::kInfo) << "Mismatch between DbiDemoData3 objects:-\n";
00125 MSG("Dbi",Msg::kInfo) << " member " << name << " this: " << thisValue << endl;
00126 MSG("Dbi",Msg::kInfo) << " member " << name << " that: " << thatValue << endl;
00127
00128 }
00129 matchedSofar = false;
00130 }
00131 template<class T> void CompareValuewithTol(const T& thisValue,
00132 const T& thatValue,
00133 const char* name,
00134 bool printDiff,
00135 bool& matchedSofar,
00136 float tol) {
00137
00138 float diff = fabs(thisValue - thatValue)
00139 /(fabs(thisValue) + fabs(thatValue));
00140 if ( diff <= tol ) return;
00141 if ( printDiff ) {
00142 if ( matchedSofar )
00143 MSG("Dbi",Msg::kInfo) << "Mismatch between DbiDemoData3 objects:-\n" << setprecision(22);
00144 MSG("Dbi",Msg::kInfo) << " member " << name << " this: " << thisValue << endl;
00145 MSG("Dbi",Msg::kInfo) << " member " << name << " that: " << thatValue
00146 << " % difference: " << diff << endl;
00147 }
00148 matchedSofar = false;
00149 }
00150 }
00151
00152
00153
00154
00155
00156
00157
00158
00159 DbiDemoData3::DbiDemoData3():
00160 fBool_1(1 == 1),
00161 fBool_2(1 != 1),
00162 fChar('a'),
00163 fString("Check special chars: backslash: \\ tab: \t newline: \n single quote: \' double quote:\""),
00164 fChars("abcdefgh"),
00165 fChars2("yz"),
00166 fSS_Tiny_1(0x0000),
00167 fSS_Tiny_2(0x007f),
00168 fSS_Tiny_3(-128),
00169 fSS_Tiny_4(-1),
00170 fUU_Tiny_1(0x0000),
00171 fUU_Tiny_2(0x007f),
00172 fUU_Tiny_3(0x0080),
00173 fUU_Tiny_4(0x00ff),
00174 fUS_Tiny_1(0x0000),
00175 fUS_Tiny_2(0x007f),
00176 fUS_Tiny_3(0x0080),
00177 fUS_Tiny_4(0x00ff),
00178 fSS_Short_1(0x0000),
00179 fSS_Short_2(0x7fff),
00180 fSS_Short_3(0x8000),
00181 fSS_Short_4(0xffff),
00182 fUU_Short_1(0x0000),
00183 fUU_Short_2(0x7fff),
00184 fUU_Short_3(0x8000),
00185 fUU_Short_4(0xffff),
00186 fUS_Short_1(0x0000),
00187 fUS_Short_2(0x7fff),
00188 fUS_Short_3(0x8000),
00189 fUS_Short_4(0xffff),
00190 fSS_Int_1(0x00000000),
00191 fSS_Int_2(0x7fffffff),
00192 fSS_Int_3(0x80000001),
00193 fSS_Int_4(0xffffffff),
00194 fUS_Int_1(0x00000000),
00195 fUS_Int_2(0x7fffffff),
00196 fUS_Int_3(0x80000001),
00197 fUS_Int_4(0xffffffff),
00198 fFloat_1(14511.7998),
00199 fFloat_2(12345.550e+16),
00200 fDouble_1(-1.234567890123456789012345e+100),
00201 fDouble_2( 1.234567890123456789012345e-100)
00202 {
00203
00204
00205
00206 LEA_CTOR;
00207
00208
00209
00210
00211
00212
00213 fUU_Tiny_3 = fUU_Tiny_4 = fUU_Tiny_1;
00214 fUU_Short_3 = fUU_Short_4 = fUU_Short_1;
00215 }
00216
00217
00218
00219 Bool_t DbiDemoData3::Compare(const DbiDemoData3* that,
00220 Bool_t printDiff ) const {
00221
00222
00223
00224
00225
00226
00227 bool compare = true;
00228
00229 if ( ! that ) {
00230 if ( printDiff ) MSG("Dbi",Msg::kInfo) << "Cannot compare DbiDemoData3 object; null pointer passed\n" << endl;
00231 return false;
00232 }
00233
00234 float tol_double = 2.e-16;
00235 float tol_single = 0.;
00236
00237 CompareValue(this->fBool_1,that->fBool_1,"fBool_1",printDiff,compare);
00238 CompareValue(this->fBool_2,that->fBool_2,"fBool_2",printDiff,compare);
00239 CompareValue(this->fChar,that->fChar,"fChar",printDiff,compare);
00240 CompareValue(this->fString,that->fString,"fString",printDiff,compare);
00241 CompareValue(this->fChars,that->fChars,"fChars",printDiff,compare);
00242 CompareValue(this->fChars2,that->fChars2,"fChars2",printDiff,compare);
00243 CompareValue(this->fSS_Tiny_1,that->fSS_Tiny_1,"fSS_Tiny_1",printDiff,compare);
00244 CompareValue(this->fSS_Tiny_2,that->fSS_Tiny_2,"fSS_Tiny_2",printDiff,compare);
00245 CompareValue(this->fSS_Tiny_3,that->fSS_Tiny_3,"fSS_Tiny_3",printDiff,compare);
00246 CompareValue(this->fSS_Tiny_4,that->fSS_Tiny_4,"fSS_Tiny_4",printDiff,compare);
00247 CompareValue(this->fUU_Tiny_1,that->fUU_Tiny_1,"fUU_Tiny_1",printDiff,compare);
00248 CompareValue(this->fUU_Tiny_2,that->fUU_Tiny_2,"fUU_Tiny_2",printDiff,compare);
00249 CompareValue(this->fUU_Tiny_3,that->fUU_Tiny_3,"fUU_Tiny_3",printDiff,compare);
00250 CompareValue(this->fUU_Tiny_4,that->fUU_Tiny_4,"fUU_Tiny_4",printDiff,compare);
00251 CompareValue(this->fUS_Tiny_1,that->fUS_Tiny_1,"fUS_Tiny_1",printDiff,compare);
00252 CompareValue(this->fUS_Tiny_2,that->fUS_Tiny_2,"fUS_Tiny_2",printDiff,compare);
00253 CompareValue(this->fUS_Tiny_3,that->fUS_Tiny_3,"fUS_Tiny_3",printDiff,compare);
00254 CompareValue(this->fUS_Tiny_4,that->fUS_Tiny_4,"fUS_Tiny_4",printDiff,compare);
00255 CompareValue(this->fSS_Short_1,that->fSS_Short_1,"fSS_Short_1",printDiff,compare);
00256 CompareValue(this->fSS_Short_2,that->fSS_Short_2,"fSS_Short_2",printDiff,compare);
00257 CompareValue(this->fSS_Short_3,that->fSS_Short_3,"fSS_Short_3",printDiff,compare);
00258 CompareValue(this->fSS_Short_4,that->fSS_Short_4,"fSS_Short_4",printDiff,compare);
00259 CompareValue(this->fUU_Short_1,that->fUU_Short_1,"fUU_Short_1",printDiff,compare);
00260 CompareValue(this->fUU_Short_2,that->fUU_Short_2,"fUU_Short_2",printDiff,compare);
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270 CompareValue(this->fUS_Short_1,that->fSS_Short_1,"fUS_Short_1",printDiff,compare);
00271 CompareValue(this->fUS_Short_2,that->fUS_Short_2,"fUS_Short_2",printDiff,compare);
00272 CompareValue(this->fUS_Short_3,that->fUS_Short_3,"fUS_Short_3",printDiff,compare);
00273 CompareValue(this->fUS_Short_4,that->fUS_Short_4,"fUS_Short_4",printDiff,compare);
00274 CompareValue(this->fSS_Int_1,that->fSS_Int_1,"fSS_Int_1",printDiff,compare);
00275 CompareValue(this->fSS_Int_2,that->fSS_Int_2,"fSS_Int_2",printDiff,compare);
00276 CompareValue(this->fSS_Int_3,that->fSS_Int_3,"fSS_Int_3",printDiff,compare);
00277 CompareValue(this->fSS_Int_4,that->fSS_Int_4,"fSS_Int_4",printDiff,compare);
00278 CompareValue(this->fUS_Int_1,that->fUS_Int_1,"fUS_Int_1",printDiff,compare);
00279 CompareValue(this->fUS_Int_2,that->fUS_Int_2,"fUS_Int_2",printDiff,compare);
00280 CompareValue(this->fUS_Int_3,that->fUS_Int_3,"fUS_Int_3",printDiff,compare);
00281 CompareValue(this->fUS_Int_4,that->fUS_Int_4,"fUS_Int_4",printDiff,compare);
00282 CompareValuewithTol(this->fFloat_1,that->fFloat_1,"fFloat_1",printDiff,compare,tol_single);
00283 CompareValuewithTol(this->fFloat_2,that->fFloat_2,"fFloat_2",printDiff,compare,tol_single);
00284 CompareValuewithTol(this->fDouble_1,that->fDouble_1,"fDouble_1",printDiff,compare,tol_double);
00285 CompareValuewithTol(this->fDouble_2,that->fDouble_2,"fDouble_2",printDiff,compare,tol_double);
00286 return compare;
00287
00288 }
00289
00290
00291
00292
00293 void DbiDemoData3::Fill(DbiResultSet& rs,
00294 const DbiValidityRec* ) {
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318 this->JunkFill();
00319 rs >> fBool_1 >> fBool_2 >> fChar >> fString >> fChars >> fChars2
00320 >> fSS_Tiny_1 >> fSS_Tiny_2 >> fSS_Tiny_3 >> fSS_Tiny_4
00321 >> fUU_Tiny_1 >> fUU_Tiny_2 >> fUU_Tiny_3 >> fUU_Tiny_4
00322 >> fUS_Tiny_1 >> fUS_Tiny_2 >> fUS_Tiny_3 >> fUS_Tiny_4
00323 >> fSS_Short_1 >> fSS_Short_2 >> fSS_Short_3 >> fSS_Short_4
00324 >> fUU_Short_1 >> fUU_Short_2 >> fUU_Short_3 >> fUU_Short_4
00325 >> fUS_Short_1 >> fUS_Short_2 >> fUS_Short_3 >> fUS_Short_4
00326 >> fSS_Int_1 >> fSS_Int_2 >> fSS_Int_3 >> fSS_Int_4
00327 >> fUS_Int_1 >> fUS_Int_2 >> fUS_Int_3 >> fUS_Int_4
00328 >> fFloat_1 >> fFloat_2 >> fDouble_1 >> fDouble_2 ;
00329
00330 }
00331
00332
00333
00334 void DbiDemoData3::JunkFill() {
00335
00336
00337
00338
00339
00340 fBool_1 = 0;
00341 fBool_2 = 1;
00342 fChar = 'z';
00343 fString = "";
00344 fChars = "";
00345 fChars2 = "";
00346 fSS_Tiny_1 = fSS_Tiny_2 = fSS_Tiny_3 = fSS_Tiny_4 = 999;
00347 fUU_Tiny_1 = fUU_Tiny_2 = fUU_Tiny_3 = fUU_Tiny_4 = 999;
00348 fUS_Tiny_1 = fUS_Tiny_2 = fUS_Tiny_3 = fUS_Tiny_4 = 999;
00349 fSS_Short_1 = fSS_Short_2 = fSS_Short_3 = fSS_Short_4 = 999;
00350 fUU_Short_1 = fUU_Short_2 = fUU_Short_3 = fUU_Short_4 = 999;
00351 fUS_Short_1 = fUS_Short_2 = fUS_Short_3 = fUS_Short_4 = 999;
00352 fSS_Int_1 = fSS_Int_2 = fSS_Int_3 = fSS_Int_4 = 999;
00353 fUS_Int_1 = fUS_Int_2 = fUS_Int_3 = fUS_Int_4 = 999;
00354 fFloat_1 = fFloat_2 = fDouble_1 = fDouble_2 = 999.999;
00355
00356 }
00357
00358
00359
00360 void DbiDemoData3::Store(DbiOutRowStream& ors,
00361 const DbiValidityRec* ) const {
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385 const Char_t* pChars = fChars.c_str();
00386
00387 ors << fBool_1 << fBool_2 << fChar << fString << pChars << fChars2
00388 << fSS_Tiny_1 << fSS_Tiny_2 << fSS_Tiny_3 << fSS_Tiny_4
00389 << fUU_Tiny_1 << fUU_Tiny_2 << fUU_Tiny_3 << fUU_Tiny_4
00390 << fUS_Tiny_1 << fUS_Tiny_2 << fUS_Tiny_3 << fUS_Tiny_4
00391 << fSS_Short_1 << fSS_Short_2 << fSS_Short_3 << fSS_Short_4
00392 << fUU_Short_1 << fUU_Short_2 << fUU_Short_3 << fUU_Short_4
00393 << fUS_Short_1 << fUS_Short_2 << fUS_Short_3 << fUS_Short_4
00394 << fSS_Int_1 << fSS_Int_2 << fSS_Int_3 << fSS_Int_4
00395 << fUS_Int_1 << fUS_Int_2 << fUS_Int_3 << fUS_Int_4
00396 << fFloat_1 << fFloat_2 << fDouble_1 << fDouble_2 ;
00397
00398 }
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430