00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
#include "../GeneralInclude/CompilerSwitches.h"
00011
#include "../GeneralInclude/DebugSupport.h"
00012
#include "../GeneralInclude/BasicTypes.h"
00013
#include "../GeneralInclude/ClassId.h"
00014
#include "../GeneralInclude/Constants.h"
00015
#include "../Base/CC_RootObject.h"
00016
#include "DC_SampleR3Database.h"
00017
00018
static unsigned int const CharCode = 1;
00019
static unsigned int const UnsignedCharCode = 2;
00020
static unsigned int const ShortCode = 3;
00021
static unsigned int const UnsignedShortCode = 4;
00022
static unsigned int const IntCode = 5;
00023
static unsigned int const UnsignedIntCode = 6;
00024
static unsigned int const BoolCode = 7;
00025
static unsigned int const FloatCode = 8;
00026
static unsigned int const DoubleCode = 9;
00027
00028 DC_SampleR3Database::DC_SampleR3Database() {
00029 setClassId(ID_SAMPLER3DATABASE);
00030 pDefaultTable = pNULL;
00031 pOperationalTable = pNULL;
00032 resetWasCalled =
false;
00033
00034 tableLength = 80;
00035
00036 maxParId = 9;
00037 pPar =
new char*[maxParId+1];
00038 parType =
new char[maxParId+1];
00039
for (
TD_DatabaseId i=0; i<maxParId; i++) {
00040 pPar[i] = pNULL;
00041 parType[i] = -1;
00042 }
00043
00044 }
00045
00046 void DC_SampleR3Database::reset() {
00047 assert( pDefaultTable != pNULL ) ;
00048 assert( pOperationalTable != pNULL );
00049 assert( tableLength > 0 );
00050
for (
TD_DatabaseId i=0; i<tableLength; i++)
00051 pOperationalTable[i] = pDefaultTable[i];
00052 resetWasCalled =
true;
00053
00054
00055 pPar[1] = pOperationalTable+0;
00056 parType[1] = ShortCode;
00057 pPar[2] = pOperationalTable+8;
00058 parType[2] = UnsignedShortCode;
00059 pPar[3] = pOperationalTable+16;
00060 parType[3] = IntCode;
00061 pPar[4] = pOperationalTable+24;
00062 parType[4] = UnsignedIntCode;
00063 pPar[5] = pOperationalTable+32;
00064 parType[5] = CharCode;
00065 pPar[6] = pOperationalTable+40;
00066 parType[6] = UnsignedCharCode;
00067 pPar[7] = pOperationalTable+48;
00068 parType[7] = FloatCode;
00069 pPar[8] = pOperationalTable+56;
00070 parType[8] = DoubleCode;
00071 pPar[9] = pOperationalTable+64;
00072 parType[9] = BoolCode;
00073 }
00074
00075 void DC_SampleR3Database::setDefaultTable(
char* pDefTable) {
00076 assert( pDefTable != pNULL );
00077 pDefaultTable = pDefTable;
00078 }
00079
00080 void DC_SampleR3Database::setOperationalTable(
char* pOperTable) {
00081 assert( pOperTable != pNULL );
00082 pOperationalTable = pOperTable;
00083 }
00084
00085 bool DC_SampleR3Database::isObjectConfigured() {
00086
00087
00088
if ( !
CC_RootObject::isObjectConfigured() )
00089
return NOT_CONFIGURED;
00090
00091
if ( (tableLength <= 0) ||
00092 (pDefaultTable == pNULL) ||
00093 (pOperationalTable == pNULL) ||
00094 (!resetWasCalled) )
00095
return NOT_CONFIGURED;
00096
return CONFIGURED;
00097 }
00098
00099
00100 void DC_SampleR3Database::setParameter(TD_DatabaseId parId,
int newValue) {
00101 assert( pOperationalTable != pNULL );
00102 assert( (parId <= maxParId) && (parType[parId]==IntCode) );
00103
00104
if (parId > maxParId) {
00105
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00106
return;
00107 }
00108
if (parType[parId]!=IntCode) {
00109
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00110
return;
00111 }
00112
00113 *( (
int*)(pPar[parId]) ) = newValue;
00114 }
00115
00116 void DC_SampleR3Database::setParameter(TD_DatabaseId parId,
unsigned int newValue) {
00117 assert( pOperationalTable != pNULL );
00118 assert( (parId <= maxParId) && (parType[parId]==UnsignedIntCode) );
00119
00120
if (parId > maxParId) {
00121
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00122
return;
00123 }
00124
if (parType[parId]!=UnsignedIntCode) {
00125
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00126
return;
00127 }
00128
00129 *( (
unsigned int*)(pPar[parId]) ) = newValue;
00130 }
00131
00132 void DC_SampleR3Database::setParameter(TD_DatabaseId parId,
short newValue) {
00133 assert( pOperationalTable != pNULL );
00134 assert( (parId <= maxParId) && (parType[parId]==ShortCode) );
00135
00136
if (parId > maxParId) {
00137
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00138
return;
00139 }
00140
if (parType[parId]!=ShortCode) {
00141
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00142
return;
00143 }
00144
00145 *( (
short*)(pPar[parId]) ) = newValue;
00146 }
00147
00148 void DC_SampleR3Database::setParameter(TD_DatabaseId parId,
unsigned short newValue) {
00149 assert( pOperationalTable != pNULL );
00150 assert( (parId <= maxParId) && (parType[parId]==UnsignedShortCode) );
00151
00152
if (parId > maxParId) {
00153
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00154
return;
00155 }
00156
if (parType[parId]!=UnsignedShortCode) {
00157
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00158
return;
00159 }
00160
00161 *( (
unsigned short*)(pPar[parId]) ) = newValue;
00162 }
00163
00164 void DC_SampleR3Database::setParameter(TD_DatabaseId parId,
char newValue) {
00165 assert( pOperationalTable != pNULL );
00166 assert( (parId <= maxParId) && (parType[parId]==CharCode) );
00167
00168
if (parId > maxParId) {
00169
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00170
return;
00171 }
00172
if (parType[parId]!=CharCode) {
00173
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00174
return;
00175 }
00176
00177 *( (
char*)(pPar[parId]) ) = newValue;
00178 }
00179
00180 void DC_SampleR3Database::setParameter(TD_DatabaseId parId,
unsigned char newValue) {
00181 assert( pOperationalTable != pNULL );
00182 assert( (parId <= maxParId) && (parType[parId]==UnsignedCharCode) );
00183
00184
if (parId > maxParId) {
00185
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00186
return;
00187 }
00188
if (parType[parId]!=UnsignedCharCode) {
00189
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00190
return;
00191 }
00192
00193 *( (
unsigned char*)(pPar[parId]) ) = newValue;
00194 }
00195
00196 void DC_SampleR3Database::setParameter(TD_DatabaseId parId,
bool newValue) {
00197 assert( pOperationalTable != pNULL );
00198 assert( (parId <= maxParId) && (parType[parId]==BoolCode) );
00199
00200
if (parId > maxParId) {
00201
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00202
return;
00203 }
00204
if (parType[parId]!=BoolCode) {
00205
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00206
return;
00207 }
00208
00209 *( (
bool*)(pPar[parId]) ) = newValue;
00210 }
00211
00212 void DC_SampleR3Database::setParameter(TD_DatabaseId parId,
float newValue) {
00213 assert( pOperationalTable != pNULL );
00214 assert( (parId <= maxParId) && (parType[parId]==FloatCode) );
00215
00216
if (parId > maxParId) {
00217
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00218
return;
00219 }
00220
if (parType[parId]!=FloatCode) {
00221
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00222
return;
00223 }
00224
00225 *( (
float*)(pPar[parId]) ) = newValue;
00226 }
00227
00228 void DC_SampleR3Database::setParameter(TD_DatabaseId parId,
double newValue) {
00229 assert( pOperationalTable != pNULL );
00230 assert( (parId <= maxParId) && (parType[parId]==DoubleCode) );
00231
00232
if (parId > maxParId) {
00233
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00234
return;
00235 }
00236
if (parType[parId]!=DoubleCode) {
00237
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00238
return;
00239 }
00240
00241 *( (
double*)(pPar[parId]) ) = newValue;
00242 }
00243 int DC_SampleR3Database::getParameterInt(TD_DatabaseId parId) {
00244 assert( pOperationalTable != pNULL );
00245 assert( (parId <= maxParId) && (parType[parId]==IntCode) );
00246
00247
if (parId > maxParId) {
00248
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00249
return (
int)0;
00250 }
00251
if (parType[parId]!=IntCode) {
00252
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00253
return (
int)0;
00254 }
00255
00256
return *(
int*)(pPar[parId]);
00257 }
00258 unsigned int DC_SampleR3Database::getParameterUnsignedInt(TD_DatabaseId parId) {
00259 assert( pOperationalTable != pNULL );
00260 assert( (parId <= maxParId) && (parType[parId]==UnsignedIntCode) );
00261
00262
if (parId > maxParId) {
00263
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00264
return (
unsigned int)0;
00265 }
00266
if (parType[parId]!=UnsignedIntCode) {
00267
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00268
return (
unsigned int)0;
00269 }
00270
00271
return *(
unsigned int*)(pPar[parId]);
00272 }
00273 short DC_SampleR3Database::getParameterShort(TD_DatabaseId parId) {
00274 assert( pOperationalTable != pNULL );
00275 assert( (parId <= maxParId) && (parType[parId]==ShortCode) );
00276
00277
if (parId > maxParId) {
00278
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00279
return (
short)0;
00280 }
00281
if (parType[parId]!=ShortCode) {
00282
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00283
return (
short)0;
00284 }
00285
00286
return *(
short*)(pPar[parId]);
00287 }
00288 unsigned short DC_SampleR3Database::getParameterUnsignedShort(TD_DatabaseId parId) {
00289 assert( pOperationalTable != pNULL );
00290 assert( (parId <= maxParId) && (parType[parId]==UnsignedShortCode) );
00291
00292
if (parId > maxParId) {
00293
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00294
return (
unsigned short)0;
00295 }
00296
if (parType[parId]!=UnsignedShortCode) {
00297
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00298
return (
unsigned short)0;
00299 }
00300
00301
return *(
unsigned short*)(pPar[parId]);
00302 }
00303 char DC_SampleR3Database::getParameterChar(TD_DatabaseId parId) {
00304 assert( pOperationalTable != pNULL );
00305 assert( (parId <= maxParId) && (parType[parId]==CharCode) );
00306
00307
if (parId > maxParId) {
00308
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00309
return (
char)0;
00310 }
00311
if (parType[parId]!=CharCode) {
00312
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00313
return (
char)0;
00314 }
00315
00316
return *(
char*)(pPar[parId]);
00317 }
00318 unsigned char DC_SampleR3Database::getParameterUnsignedChar(TD_DatabaseId parId) {
00319 assert( pOperationalTable != pNULL );
00320 assert( (parId <= maxParId) && (parType[parId]==UnsignedCharCode) );
00321
00322
if (parId > maxParId) {
00323
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00324
return (
unsigned char)0;
00325 }
00326
if (parType[parId]!=UnsignedCharCode) {
00327
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00328
return (
unsigned char)0;
00329 }
00330
00331
return *(
unsigned char*)(pPar[parId]);
00332 }
00333 bool DC_SampleR3Database::getParameterBool(TD_DatabaseId parId) {
00334 assert( pOperationalTable != pNULL );
00335 assert( (parId <= maxParId) && (parType[parId]==BoolCode) );
00336
00337
if (parId > maxParId) {
00338
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00339
return (
bool)0;
00340 }
00341
if (parType[parId]!=BoolCode) {
00342
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00343
return (
bool)0;
00344 }
00345
00346
return *(
bool*)(pPar[parId]);
00347 }
00348 float DC_SampleR3Database::getParameterFloat(TD_DatabaseId parId) {
00349 assert( pOperationalTable != pNULL );
00350 assert( (parId <= maxParId) && (parType[parId]==FloatCode) );
00351
00352
if (parId > maxParId) {
00353
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00354
return (
float)0;
00355 }
00356
if (parType[parId]!=FloatCode) {
00357
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00358
return (
float)0;
00359 }
00360
00361
return *(
float*)(pPar[parId]);
00362 }
00363 double DC_SampleR3Database::getParameterDouble(TD_DatabaseId parId) {
00364 assert( pOperationalTable != pNULL );
00365 assert( (parId <= maxParId) && (parType[parId]==DoubleCode) );
00366
00367
if (parId > maxParId) {
00368
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00369
return (
double)0;
00370 }
00371
if (parType[parId]!=DoubleCode) {
00372
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00373
return (
double)0;
00374 }
00375
00376
return *(
double*)(pPar[parId]);
00377 }
00378 int*
DC_SampleR3Database::getParameterPointerInt(TD_DatabaseId parId) {
00379 assert( pOperationalTable != pNULL );
00380 assert( (parId <= maxParId) && (parType[parId]==IntCode) );
00381
00382
if (parId > maxParId) {
00383
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00384
return pNULL;
00385 }
00386
if (parType[parId]!=IntCode) {
00387
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00388
return pNULL;
00389 }
00390
00391
return (
int*)(pPar[parId]);
00392 }
00393 unsigned int*
DC_SampleR3Database::getParameterPointerUnsignedInt(TD_DatabaseId parId) {
00394 assert( pOperationalTable != pNULL );
00395 assert( (parId <= maxParId) && (parType[parId]==UnsignedIntCode) );
00396
00397
if (parId > maxParId) {
00398
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00399
return pNULL;
00400 }
00401
if (parType[parId]!=UnsignedIntCode) {
00402
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00403
return pNULL;
00404 }
00405
00406
return (
unsigned int*)(pPar[parId]);
00407 }
00408 short*
DC_SampleR3Database::getParameterPointerShort(TD_DatabaseId parId) {
00409 assert( pOperationalTable != pNULL );
00410 assert( (parId <= maxParId) && (parType[parId]==ShortCode) );
00411
00412
if (parId > maxParId) {
00413
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00414
return pNULL;
00415 }
00416
if (parType[parId]!=ShortCode) {
00417
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00418
return pNULL;
00419 }
00420
00421
return (
short*)(pPar[parId]);
00422 }
00423 unsigned short*
DC_SampleR3Database::getParameterPointerUnsignedShort(TD_DatabaseId parId) {
00424 assert( pOperationalTable != pNULL );
00425 assert( (parId <= maxParId) && (parType[parId]==UnsignedShortCode) );
00426
00427
if (parId > maxParId) {
00428
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00429
return pNULL;
00430 }
00431
if (parType[parId]!=UnsignedShortCode) {
00432
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00433
return pNULL;
00434 }
00435
00436
return (
unsigned short*)(pPar[parId]);
00437 }
00438 char*
DC_SampleR3Database::getParameterPointerChar(TD_DatabaseId parId) {
00439 assert( pOperationalTable != pNULL );
00440 assert( (parId <= maxParId) && (parType[parId]==CharCode) );
00441
00442
if (parId > maxParId) {
00443
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00444
return pNULL;
00445 }
00446
if (parType[parId]!=CharCode) {
00447
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00448
return pNULL;
00449 }
00450
00451
return (
char*)(pPar[parId]);
00452 }
00453 unsigned char*
DC_SampleR3Database::getParameterPointerUnsignedChar(TD_DatabaseId parId) {
00454 assert( pOperationalTable != pNULL );
00455 assert( (parId <= maxParId) && (parType[parId]==UnsignedCharCode) );
00456
00457
if (parId > maxParId) {
00458
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00459
return pNULL;
00460 }
00461
if (parType[parId]!=UnsignedCharCode) {
00462
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00463
return pNULL;
00464 }
00465
00466
return (
unsigned char*)(pPar[parId]);
00467 }
00468 bool*
DC_SampleR3Database::getParameterPointerBool(TD_DatabaseId parId) {
00469 assert( pOperationalTable != pNULL );
00470 assert( (parId <= maxParId) && (parType[parId]==BoolCode) );
00471
00472
if (parId > maxParId) {
00473
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00474
return pNULL;
00475 }
00476
if (parType[parId]!=BoolCode) {
00477
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00478
return pNULL;
00479 }
00480
00481
return (
bool*)(pPar[parId]);
00482 }
00483 float*
DC_SampleR3Database::getParameterPointerFloat(TD_DatabaseId parId) {
00484 assert( pOperationalTable != pNULL );
00485 assert( (parId <= maxParId) && (parType[parId]==FloatCode) );
00486
00487
if (parId > maxParId) {
00488
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00489
return pNULL;
00490 }
00491
if (parType[parId]!=FloatCode) {
00492
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00493
return pNULL;
00494 }
00495
00496
return (
float*)(pPar[parId]);
00497 }
00498 double*
DC_SampleR3Database::getParameterPointerDouble(TD_DatabaseId parId) {
00499 assert( pOperationalTable != pNULL );
00500 assert( (parId <= maxParId) && (parType[parId]==DoubleCode) );
00501
00502
if (parId > maxParId) {
00503
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00504
return pNULL;
00505 }
00506
if (parType[parId]!=DoubleCode) {
00507
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00508
return pNULL;
00509 }
00510
00511
return (
double*)(pPar[parId]);
00512 }