00001
00002
00003 #ifndef CONFIGURATION_FIELD_H_
00004 #define CONFIGURATION_FIELD_H_
00005
00006 #include <fesa-core/DataStore/Field.h>
00007 #include <fesa-core/DataStore/FieldArray.h>
00008 #include <fesa-core/DataStore/FieldArray2D.h>
00009 #include <fesa-core/DataStore/FieldString.h>
00010 #include <fesa-core/DataStore/FieldStringArray.h>
00011
00012 namespace fesa
00013 {
00014
00015
00021 template<typename T>
00022 class ConfigFieldScalar : public Field<T> {
00023 public:
00024
00031 ConfigFieldScalar(const std::string& fieldName, DataStore* pDataStore,
00032 const DataIntegrity bufferType = SingleBuffered);
00036 ~ConfigFieldScalar();
00037
00042 T get();
00043
00044
00045
00046
00047
00048
00049
00050 };
00051
00052 template<typename T>
00053 ConfigFieldScalar<T>::~ConfigFieldScalar() {
00054
00055 }
00056
00057 template<typename T>
00058 ConfigFieldScalar<T>::ConfigFieldScalar(const std::string& fieldName, DataStore* pDataStore,
00059 const DataIntegrity bufferType) :
00060 Field<T> (fieldName, Configuration, false, false, false, bufferType,
00061 pDataStore) {
00062 }
00063
00064 template<typename T>
00065 T ConfigFieldScalar<T>::get() {
00066 return (this->fieldValue_->activeBuffer((char*) this->fieldValue_));
00067 }
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00086 template<typename T>
00087 class ConfigFieldStruct: public Field<T> {
00088 public:
00089
00096 ConfigFieldStruct(const std::string& fieldName, DataStore* pDataStore,
00097 const DataIntegrity bufferType = SingleBuffered);
00101 ~ConfigFieldStruct();
00102
00108 const T* get();
00109
00110
00111
00112
00113
00114
00115
00116 };
00117
00118 template<typename T>
00119 ConfigFieldStruct<T>::~ConfigFieldStruct() {
00120
00121 }
00122
00123 template<typename T>
00124 ConfigFieldStruct<T>::ConfigFieldStruct(const std::string& fieldName, DataStore* pDataStore,
00125 const DataIntegrity bufferType) :
00126 Field<T> (fieldName, Configuration, false, false, false, bufferType,
00127 pDataStore) {
00128 }
00129
00130 template<typename T>
00131 const T* ConfigFieldStruct<T>::get() {
00132 return (&(this->fieldValue_->activeBuffer((char*) this->fieldValue_)));
00133 }
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146 template<typename T>
00147 class ConfigFieldArray: public FieldArray<T> {
00148 public:
00156 ConfigFieldArray(const std::string& fieldName, DataStore* pDataStore, int32_t size,
00157 const DataIntegrity bufferType = SingleBuffered);
00158
00162 ~ConfigFieldArray();
00163
00169 const T* get(uint32_t& size);
00170
00175 uint32_t getSize();
00176 };
00177
00178 template<typename T>
00179 ConfigFieldArray<T>::ConfigFieldArray(const std::string& fieldName,
00180 DataStore* pDataStore, int32_t size,
00181 const DataIntegrity bufferType) :
00182 FieldArray<T> (fieldName, Configuration, false, false, false, bufferType,
00183 pDataStore, size) {
00184
00185 }
00186
00187 template<typename T>
00188 ConfigFieldArray<T>::~ConfigFieldArray() {
00189
00190 }
00191
00192 template<typename T>
00193 const T* ConfigFieldArray<T>::get(uint32_t& size) {
00194 size = this->fieldValue_->getActiveCurrentSize();
00195 return (const T*) (this->fieldValue_->activeBuffer(
00196 (char*) this->fieldValue_));
00197 }
00198
00199 template<typename T>
00200 uint32_t ConfigFieldArray<T>::getSize() {
00201 return this->fieldValue_->getActiveCurrentSize();
00202 }
00203
00204
00205
00206
00207 template<typename T>
00208 class ConfigFieldScalarArray: public ConfigFieldArray<T> {
00209 public:
00217 ConfigFieldScalarArray(const std::string& fieldName, DataStore* pDataStore, int32_t size,
00218 const DataIntegrity bufferType = SingleBuffered);
00219
00223 ~ConfigFieldScalarArray();
00224
00231 T getCell(uint32_t index);
00232
00233 };
00234
00235 template<typename T>
00236 ConfigFieldScalarArray<T>::ConfigFieldScalarArray(const std::string& fieldName,
00237 DataStore* pDataStore, int32_t size, const DataIntegrity bufferType) :
00238 ConfigFieldArray<T> (fieldName, pDataStore, size,
00239 bufferType) {
00240
00241 }
00242
00243 template<typename T>
00244 T ConfigFieldScalarArray<T>::getCell(uint32_t index) {
00245
00246 uint32_t size = this->fieldValue_->getActiveCurrentSize();
00247 if ((index+1) > size) {
00248 throw FesaException(__FILE__, __LINE__,
00249 FesaErrorFieldCurrentDimensionOutOfBound.c_str(),
00250 StringUtilities::toString(index).c_str(), this->name_.c_str(),
00251 StringUtilities::toString(size).c_str());
00252 }
00253 return this->fieldValue_->activeBuffer((char*) this->fieldValue_)[index];
00254 }
00255
00256 template<typename T>
00257 ConfigFieldScalarArray<T>::~ConfigFieldScalarArray() {
00258
00259 }
00260
00261
00262
00263
00264 template<typename T>
00265 class ConfigFieldStructArray: public ConfigFieldArray<T> {
00266 public:
00274 ConfigFieldStructArray(const std::string& fieldName, DataStore* pDataStore, int32_t size,
00275 const DataIntegrity bufferType = SingleBuffered);
00276
00280 ~ConfigFieldStructArray();
00281
00288 const T* getCell(uint32_t index);
00289
00290 };
00291
00292 template<typename T>
00293 ConfigFieldStructArray<T>::ConfigFieldStructArray(const std::string& fieldName,
00294 DataStore* pDataStore, int32_t size, const DataIntegrity bufferType) :
00295 ConfigFieldArray<T> (fieldName, pDataStore, size,
00296 bufferType) {
00297
00298 }
00299
00300 template<typename T>
00301 const T* ConfigFieldStructArray<T>::getCell(uint32_t index) {
00302
00303 uint32_t size = this->fieldValue_->getActiveCurrentSize();
00304 if ((index+1) > size) {
00305 throw FesaException(__FILE__, __LINE__,
00306 FesaErrorFieldCurrentDimensionOutOfBound.c_str(),
00307 StringUtilities::toString(index).c_str(), this->name_.c_str(),
00308 StringUtilities::toString(size).c_str());
00309 }
00310 return &(this->fieldValue_->activeBuffer((char*) this->fieldValue_)[index]);
00311 }
00312
00313 template<typename T>
00314 ConfigFieldStructArray<T>::~ConfigFieldStructArray() {
00315
00316 }
00317
00318
00319
00320
00321 template<typename T>
00322 class ConfigFieldArray2D : public FieldArray2D<T> {
00323 public:
00324
00331 ConfigFieldArray2D(const std::string& fieldName, DataStore* pDataStore, int32_t size1, int32_t size2,
00332 const DataIntegrity bufferType = SingleBuffered);
00333
00337 ~ConfigFieldArray2D();
00338
00346 const T** get(uint32_t& size1, uint32_t& size2);
00347
00355 void getColumn(uint32_t index, uint32_t size, T* column, uint32_t& currentSize);
00356
00364 const T* getRow(uint32_t index, uint32_t& size);
00365
00371 void getSize(uint32_t& size1, uint32_t& size2);
00372
00373 };
00374
00375 template<typename T>
00376 ConfigFieldArray2D<T>::ConfigFieldArray2D(const std::string& fieldName,
00377 DataStore* pDataStore, int32_t size1, int32_t size2,
00378 const DataIntegrity bufferType) :
00379 FieldArray2D<T> (fieldName, Configuration, false, false, false, bufferType,
00380 pDataStore, size1, size2) {
00381 }
00382
00383 template<typename T>
00384 ConfigFieldArray2D<T>::~ConfigFieldArray2D() {
00385
00386 }
00387
00388 template<typename T>
00389 const T** ConfigFieldArray2D<T>::get(uint32_t& size1, uint32_t& size2) {
00390 this->fieldValue_->getActiveCurrentSize(size1, size2);
00391 return (const T**) this->fieldValue_->activeBuffer(
00392 (char*) this->fieldValue_);
00393 }
00394
00395 template<typename T>
00396 void ConfigFieldArray2D<T>::getColumn(uint32_t index, uint32_t size,
00397 T* column, uint32_t& currentSize) {
00398
00399
00400 uint32_t size1, size2;
00401 this->fieldValue_->getActiveCurrentSize(size1, size2);
00402 if ((index+1) > size2 || size < size1) {
00403 throw FesaException(__FILE__, __LINE__,
00404 FesaErrorFieldCurrentDimensionsOutOfBound.c_str(),
00405 StringUtilities::toString(index).c_str(),
00406 StringUtilities::toString(size).c_str(),
00407 this->name_.c_str(),
00408 StringUtilities::toString(size1).c_str(),
00409 StringUtilities::toString(size2).c_str());
00410 }
00411 currentSize = size1;
00412 T(*activeVal)[size2];
00413 activeVal = (T(*)[size2]) this->fieldValue_->activeBuffer((char*) this->fieldValue_);
00414 for (uint32_t i = 0; i < size1; i++) {
00415 column[i] = activeVal[i][index];
00416 }
00417 }
00418
00419 template<typename T>
00420 const T* ConfigFieldArray2D<T>::getRow(uint32_t index, uint32_t& size) {
00421
00422
00423 uint32_t size1, size2;
00424 this->fieldValue_->getActiveCurrentSize(size1, size2);
00425 if ((index+1) > size1) {
00426 throw FesaException(__FILE__, __LINE__,
00427 FesaErrorFieldCurrentDimensionOutOfBound.c_str(),
00428 StringUtilities::toString(index).c_str(), this->name_.c_str(),
00429 StringUtilities::toString(size1).c_str());
00430 }
00431
00432 size = size2;
00433 T(*activeVal)[size2];
00434 activeVal = (T(*)[size2]) this->fieldValue_->activeBuffer((char*) this->fieldValue_);
00435 return activeVal[index];
00436 }
00437
00438 template<typename T>
00439 void ConfigFieldArray2D<T>::getSize(uint32_t& size1, uint32_t& size2) {
00440 this->fieldValue_->getActiveCurrentSize(size1, size2);
00441 }
00442
00443
00444 template<typename T>
00445 class ConfigFieldScalarArray2D: public ConfigFieldArray2D<T> {
00446 public:
00447
00454 ConfigFieldScalarArray2D(const std::string& fieldName, DataStore* pDataStore, int32_t size1, int32_t size2,
00455 const DataIntegrity bufferType = SingleBuffered);
00456
00460 ~ConfigFieldScalarArray2D();
00461
00469 T getCell(uint32_t index1, uint32_t index2);
00470
00471 };
00472
00473 template<typename T>
00474 ConfigFieldScalarArray2D<T>::ConfigFieldScalarArray2D(
00475 const std::string& fieldName, DataStore* pDataStore, int32_t size1, int32_t size2,
00476 const DataIntegrity bufferType) :
00477 ConfigFieldArray2D<T> (fieldName, pDataStore, size1, size2,
00478 bufferType) {
00479 }
00480
00481 template<typename T>
00482 ConfigFieldScalarArray2D<T>::~ConfigFieldScalarArray2D() {
00483
00484 }
00485
00486 template<typename T>
00487 T ConfigFieldScalarArray2D<T>::getCell(uint32_t index1,
00488 uint32_t index2) {
00489
00490 uint32_t size1, size2;
00491 this->fieldValue_->getActiveCurrentSize(size1, size2);
00492 if ( ((index1+1) > size1) || ((index2+1) > size2) ) {
00493 throw FesaException(__FILE__, __LINE__,
00494 FesaErrorFieldCurrentDimensionsOutOfBound.c_str(),
00495 StringUtilities::toString(index1).c_str(),
00496 StringUtilities::toString(index2).c_str(),
00497 this->name_.c_str(),
00498 StringUtilities::toString(size1).c_str(),
00499 StringUtilities::toString(size2).c_str());
00500 }
00501
00502 T(*activeVal)[size2];
00503 activeVal = (T(*)[size2]) this->fieldValue_->activeBuffer(
00504 (char*) this->fieldValue_);
00505 return activeVal[index1][index2];
00506 }
00507
00508
00509
00510 template<typename T>
00511 class ConfigFieldStructArray2D: public ConfigFieldArray2D<T> {
00512 public:
00513
00520 ConfigFieldStructArray2D(const std::string& fieldName,
00521 DataStore* pDataStore, int32_t size1, int32_t size2,
00522 const DataIntegrity bufferType = SingleBuffered);
00523
00527 ~ConfigFieldStructArray2D();
00528
00536 const T* getCell(uint32_t index1, uint32_t index2);
00537
00538 };
00539
00540 template<typename T>
00541 ConfigFieldStructArray2D<T>::ConfigFieldStructArray2D(
00542 const std::string& fieldName, DataStore* pDataStore, int32_t size1, int32_t size2,
00543 const DataIntegrity bufferType) :
00544 ConfigFieldArray2D<T> (fieldName, pDataStore, size1, size2,
00545 bufferType) {
00546 }
00547
00548 template<typename T>
00549 ConfigFieldStructArray2D<T>::~ConfigFieldStructArray2D() {
00550
00551 }
00552
00553 template<typename T>
00554 const T* ConfigFieldStructArray2D<T>::getCell(uint32_t index1,
00555 uint32_t index2) {
00556
00557 uint32_t size1, size2;
00558 this->fieldValue_->getActiveCurrentSize(size1, size2);
00559 if ( ((index1+1) > size1) || ((index2+1) > size2) ) {
00560 throw FesaException(__FILE__, __LINE__,
00561 FesaErrorFieldCurrentDimensionsOutOfBound.c_str(),
00562 StringUtilities::toString(index1).c_str(),
00563 StringUtilities::toString(index2).c_str(),
00564 this->name_.c_str(),
00565 StringUtilities::toString(size1).c_str(),
00566 StringUtilities::toString(size2).c_str());
00567 }
00568
00569 T(*activeVal)[size2];
00570 activeVal = (T(*)[size2]) this->fieldValue_->activeBuffer(
00571 (char*) this->fieldValue_);
00572
00573 return &(activeVal[index1][index2]);
00574 }
00575
00576
00577
00578 class ConfigFieldString: public FieldString {
00579 public:
00586 ConfigFieldString(const std::string& fieldName, DataStore* pDataStore, int32_t size,
00587 const DataIntegrity bufferType = SingleBuffered);
00588
00592 ~ConfigFieldString();
00593
00600 const char* get();
00601
00606 const std::string getAsString();
00607
00608 };
00609
00610
00611
00612 class ConfigFieldStringArray: public FieldStringArray {
00613 public:
00614
00619 ConfigFieldStringArray(const std::string& fieldName, DataStore* pDataStore, int32_t size1, int32_t size2,
00620 const DataIntegrity bufferType = SingleBuffered);
00624 ~ConfigFieldStringArray();
00625
00631 const char** get(uint32_t& size1);
00632
00640 const char* getString(uint32_t index);
00641
00642 };
00643
00644
00645
00646 }
00647
00648 #endif // CONFIGURATION_FIELD_H_