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_SampleR2Database.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_SampleR2Database::DC_SampleR2Database() {
00029 setClassId(ID_SAMPLER2DATABASE);
00030 pDefaultTable = pNULL;
00031 pOperationalTable = pNULL;
00032 resetWasCalled =
false;
00033
00034 tableLength = 50;
00035
00036 maxParId = 4;
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_SampleR2Database::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] = FloatCode;
00057 pPar[2] = pOperationalTable+8;
00058 parType[2] = FloatCode;
00059 pPar[3] = pOperationalTable+16;
00060 parType[3] = FloatCode;
00061 pPar[4] = pOperationalTable+24;
00062 parType[4] = FloatCode;
00063 }
00064
00065 void DC_SampleR2Database::setDefaultTable(
char* pDefTable) {
00066 assert( pDefTable != pNULL );
00067 pDefaultTable = pDefTable;
00068 }
00069
00070 void DC_SampleR2Database::setOperationalTable(
char* pOperTable) {
00071 assert( pOperTable != pNULL );
00072 pOperationalTable = pOperTable;
00073 }
00074
00075 bool DC_SampleR2Database::isObjectConfigured() {
00076
00077
00078
if ( !
CC_RootObject::isObjectConfigured() )
00079
return NOT_CONFIGURED;
00080
00081
if ( (tableLength <= 0) ||
00082 (pDefaultTable == pNULL) ||
00083 (pOperationalTable == pNULL) ||
00084 (!resetWasCalled) )
00085
return NOT_CONFIGURED;
00086
return CONFIGURED;
00087 }
00088
00089
00090 void DC_SampleR2Database::setParameter(TD_DatabaseId parId,
int newValue) {
00091 assert( pOperationalTable != pNULL );
00092 assert( (parId <= maxParId) && (parType[parId]==IntCode) );
00093
00094
if (parId > maxParId) {
00095
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00096
return;
00097 }
00098
if (parType[parId]!=IntCode) {
00099
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00100
return;
00101 }
00102
00103 *( (
int*)(pPar[parId]) ) = newValue;
00104 }
00105
00106 void DC_SampleR2Database::setParameter(TD_DatabaseId parId,
unsigned int newValue) {
00107 assert( pOperationalTable != pNULL );
00108 assert( (parId <= maxParId) && (parType[parId]==UnsignedIntCode) );
00109
00110
if (parId > maxParId) {
00111
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00112
return;
00113 }
00114
if (parType[parId]!=UnsignedIntCode) {
00115
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00116
return;
00117 }
00118
00119 *( (
unsigned int*)(pPar[parId]) ) = newValue;
00120 }
00121
00122 void DC_SampleR2Database::setParameter(TD_DatabaseId parId,
short newValue) {
00123 assert( pOperationalTable != pNULL );
00124 assert( (parId <= maxParId) && (parType[parId]==ShortCode) );
00125
00126
if (parId > maxParId) {
00127
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00128
return;
00129 }
00130
if (parType[parId]!=ShortCode) {
00131
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00132
return;
00133 }
00134
00135 *( (
short*)(pPar[parId]) ) = newValue;
00136 }
00137
00138 void DC_SampleR2Database::setParameter(TD_DatabaseId parId,
unsigned short newValue) {
00139 assert( pOperationalTable != pNULL );
00140 assert( (parId <= maxParId) && (parType[parId]==UnsignedShortCode) );
00141
00142
if (parId > maxParId) {
00143
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00144
return;
00145 }
00146
if (parType[parId]!=UnsignedShortCode) {
00147
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00148
return;
00149 }
00150
00151 *( (
unsigned short*)(pPar[parId]) ) = newValue;
00152 }
00153
00154 void DC_SampleR2Database::setParameter(TD_DatabaseId parId,
char newValue) {
00155 assert( pOperationalTable != pNULL );
00156 assert( (parId <= maxParId) && (parType[parId]==CharCode) );
00157
00158
if (parId > maxParId) {
00159
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00160
return;
00161 }
00162
if (parType[parId]!=CharCode) {
00163
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00164
return;
00165 }
00166
00167 *( (
char*)(pPar[parId]) ) = newValue;
00168 }
00169
00170 void DC_SampleR2Database::setParameter(TD_DatabaseId parId,
unsigned char newValue) {
00171 assert( pOperationalTable != pNULL );
00172 assert( (parId <= maxParId) && (parType[parId]==UnsignedCharCode) );
00173
00174
if (parId > maxParId) {
00175
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00176
return;
00177 }
00178
if (parType[parId]!=UnsignedCharCode) {
00179
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00180
return;
00181 }
00182
00183 *( (
unsigned char*)(pPar[parId]) ) = newValue;
00184 }
00185
00186 void DC_SampleR2Database::setParameter(TD_DatabaseId parId,
bool newValue) {
00187 assert( pOperationalTable != pNULL );
00188 assert( (parId <= maxParId) && (parType[parId]==BoolCode) );
00189
00190
if (parId > maxParId) {
00191
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00192
return;
00193 }
00194
if (parType[parId]!=BoolCode) {
00195
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00196
return;
00197 }
00198
00199 *( (
bool*)(pPar[parId]) ) = newValue;
00200 }
00201
00202 void DC_SampleR2Database::setParameter(TD_DatabaseId parId,
float newValue) {
00203 assert( pOperationalTable != pNULL );
00204 assert( (parId <= maxParId) && (parType[parId]==FloatCode) );
00205
00206
if (parId > maxParId) {
00207
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00208
return;
00209 }
00210
if (parType[parId]!=FloatCode) {
00211
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00212
return;
00213 }
00214
00215 *( (
float*)(pPar[parId]) ) = newValue;
00216 }
00217
00218 void DC_SampleR2Database::setParameter(TD_DatabaseId parId,
double newValue) {
00219 assert( pOperationalTable != pNULL );
00220 assert( (parId <= maxParId) && (parType[parId]==DoubleCode) );
00221
00222
if (parId > maxParId) {
00223
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00224
return;
00225 }
00226
if (parType[parId]!=DoubleCode) {
00227
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00228
return;
00229 }
00230
00231 *( (
double*)(pPar[parId]) ) = newValue;
00232 }
00233 int DC_SampleR2Database::getParameterInt(TD_DatabaseId parId) {
00234 assert( pOperationalTable != pNULL );
00235 assert( (parId <= maxParId) && (parType[parId]==IntCode) );
00236
00237
return *(
int*)(pPar[parId]);
00238 }
00239 unsigned int DC_SampleR2Database::getParameterUnsignedInt(TD_DatabaseId parId) {
00240 assert( pOperationalTable != pNULL );
00241 assert( (parId <= maxParId) && (parType[parId]==UnsignedIntCode) );
00242
00243
return *(
unsigned int*)(pPar[parId]);
00244 }
00245 short DC_SampleR2Database::getParameterShort(TD_DatabaseId parId) {
00246 assert( pOperationalTable != pNULL );
00247 assert( (parId <= maxParId) && (parType[parId]==ShortCode) );
00248
00249
return *(
short*)(pPar[parId]);
00250 }
00251 unsigned short DC_SampleR2Database::getParameterUnsignedShort(TD_DatabaseId parId) {
00252 assert( pOperationalTable != pNULL );
00253 assert( (parId <= maxParId) && (parType[parId]==UnsignedShortCode) );
00254
00255
return *(
unsigned short*)(pPar[parId]);
00256 }
00257 char DC_SampleR2Database::getParameterChar(TD_DatabaseId parId) {
00258 assert( pOperationalTable != pNULL );
00259 assert( (parId <= maxParId) && (parType[parId]==CharCode) );
00260
00261
return *(
char*)(pPar[parId]);
00262 }
00263 unsigned char DC_SampleR2Database::getParameterUnsignedChar(TD_DatabaseId parId) {
00264 assert( pOperationalTable != pNULL );
00265 assert( (parId <= maxParId) && (parType[parId]==UnsignedCharCode) );
00266
00267
return *(
unsigned char*)(pPar[parId]);
00268 }
00269 bool DC_SampleR2Database::getParameterBool(TD_DatabaseId parId) {
00270 assert( pOperationalTable != pNULL );
00271 assert( (parId <= maxParId) && (parType[parId]==BoolCode) );
00272
00273
return *(
bool*)(pPar[parId]);
00274 }
00275 float DC_SampleR2Database::getParameterFloat(TD_DatabaseId parId) {
00276 assert( pOperationalTable != pNULL );
00277 assert( (parId <= maxParId) && (parType[parId]==FloatCode) );
00278
00279
return *(
float*)(pPar[parId]);
00280 }
00281 double DC_SampleR2Database::getParameterDouble(TD_DatabaseId parId) {
00282 assert( pOperationalTable != pNULL );
00283 assert( (parId <= maxParId) && (parType[parId]==DoubleCode) );
00284
00285
return *(
double*)(pPar[parId]);
00286 }
00287 int*
DC_SampleR2Database::getParameterPointerInt(TD_DatabaseId parId) {
00288 assert( pOperationalTable != pNULL );
00289 assert( (parId <= maxParId) && (parType[parId]==IntCode) );
00290
00291
if (parId > maxParId) {
00292
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00293
return pNULL;
00294 }
00295
if (parType[parId]!=IntCode) {
00296
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00297
return pNULL;
00298 }
00299
00300
return (
int*)(pPar[parId]);
00301 }
00302 unsigned int*
DC_SampleR2Database::getParameterPointerUnsignedInt(TD_DatabaseId parId) {
00303 assert( pOperationalTable != pNULL );
00304 assert( (parId <= maxParId) && (parType[parId]==UnsignedIntCode) );
00305
00306
if (parId > maxParId) {
00307
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00308
return pNULL;
00309 }
00310
if (parType[parId]!=UnsignedIntCode) {
00311
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00312
return pNULL;
00313 }
00314
00315
return (
unsigned int*)(pPar[parId]);
00316 }
00317 short*
DC_SampleR2Database::getParameterPointerShort(TD_DatabaseId parId) {
00318 assert( pOperationalTable != pNULL );
00319 assert( (parId <= maxParId) && (parType[parId]==ShortCode) );
00320
00321
if (parId > maxParId) {
00322
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00323
return pNULL;
00324 }
00325
if (parType[parId]!=ShortCode) {
00326
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00327
return pNULL;
00328 }
00329
00330
return (
short*)(pPar[parId]);
00331 }
00332 unsigned short*
DC_SampleR2Database::getParameterPointerUnsignedShort(TD_DatabaseId parId) {
00333 assert( pOperationalTable != pNULL );
00334 assert( (parId <= maxParId) && (parType[parId]==UnsignedShortCode) );
00335
00336
if (parId > maxParId) {
00337
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00338
return pNULL;
00339 }
00340
if (parType[parId]!=UnsignedShortCode) {
00341
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00342
return pNULL;
00343 }
00344
00345
return (
unsigned short*)(pPar[parId]);
00346 }
00347 char*
DC_SampleR2Database::getParameterPointerChar(TD_DatabaseId parId) {
00348 assert( pOperationalTable != pNULL );
00349 assert( (parId <= maxParId) && (parType[parId]==CharCode) );
00350
00351
if (parId > maxParId) {
00352
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00353
return pNULL;
00354 }
00355
if (parType[parId]!=CharCode) {
00356
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00357
return pNULL;
00358 }
00359
00360
return (
char*)(pPar[parId]);
00361 }
00362 unsigned char*
DC_SampleR2Database::getParameterPointerUnsignedChar(TD_DatabaseId parId) {
00363 assert( pOperationalTable != pNULL );
00364 assert( (parId <= maxParId) && (parType[parId]==UnsignedCharCode) );
00365
00366
if (parId > maxParId) {
00367
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00368
return pNULL;
00369 }
00370
if (parType[parId]!=UnsignedCharCode) {
00371
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00372
return pNULL;
00373 }
00374
00375
return (
unsigned char*)(pPar[parId]);
00376 }
00377 bool*
DC_SampleR2Database::getParameterPointerBool(TD_DatabaseId parId) {
00378 assert( pOperationalTable != pNULL );
00379 assert( (parId <= maxParId) && (parType[parId]==BoolCode) );
00380
00381
if (parId > maxParId) {
00382
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00383
return pNULL;
00384 }
00385
if (parType[parId]!=BoolCode) {
00386
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00387
return pNULL;
00388 }
00389
00390
return (
bool*)(pPar[parId]);
00391 }
00392 float*
DC_SampleR2Database::getParameterPointerFloat(TD_DatabaseId parId) {
00393 assert( pOperationalTable != pNULL );
00394 assert( (parId <= maxParId) && (parType[parId]==FloatCode) );
00395
00396
if (parId > maxParId) {
00397
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00398
return pNULL;
00399 }
00400
if (parType[parId]!=FloatCode) {
00401
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00402
return pNULL;
00403 }
00404
00405
return (
float*)(pPar[parId]);
00406 }
00407 double*
DC_SampleR2Database::getParameterPointerDouble(TD_DatabaseId parId) {
00408 assert( pOperationalTable != pNULL );
00409 assert( (parId <= maxParId) && (parType[parId]==DoubleCode) );
00410
00411
if (parId > maxParId) {
00412
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00413
return pNULL;
00414 }
00415
if (parType[parId]!=DoubleCode) {
00416
CC_RootObject::getEventRepository()->
create(
this,EVT_ILLEGAL_DB_ACCESS);
00417
return pNULL;
00418 }
00419
00420
return (
double*)(pPar[parId]);
00421 }