00001
00002
00003 #ifndef GENERIC_FIELD_H_
00004 #define GENERIC_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 #include <fesa-core/Synchronization/MultiplexingContext.h>
00012
00013 namespace fesa
00014 {
00015
00022 template<typename T>
00023 class GenericFieldScalar: public Field<T> {
00024 public:
00025
00032 GenericFieldScalar(const std::string& fieldName, bool multiplexed,
00033 DataStore* pDataStore, bool persistent = false,
00034 DataIntegrity bufferType = SingleBuffered);
00038 ~GenericFieldScalar();
00039
00045 T get(MultiplexingContext*);
00046
00052 void set(T val, MultiplexingContext*);
00053 };
00054
00055 template<typename T>
00056 GenericFieldScalar<T>::GenericFieldScalar(const std::string& fieldName,
00057 bool multiplexed, DataStore* pDataStore, bool persistent,
00058 DataIntegrity bufferType) :
00059 Field<T> (fieldName, Generic, multiplexed, false, persistent,
00060 bufferType, pDataStore) {
00061 }
00062
00063 template<typename T>
00064 GenericFieldScalar<T>::~GenericFieldScalar() {
00065
00066 }
00067
00068 template<typename T>
00069 T GenericFieldScalar<T>::get(MultiplexingContext* context) {
00070
00071 if (context == NULL)
00072 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00073
00074 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00075 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00076 this->name_.c_str());
00077
00078 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00079 : this->multiplexingManager_->getSlot(*context);
00080 FieldValue<T>* pFV = this->getFieldValue(slot);
00081
00082 return (pFV->activeBuffer((char*) pFV));
00083 }
00084
00085 template<typename T>
00086 void GenericFieldScalar<T>::set(T val, MultiplexingContext* context) {
00087
00088 if (context == NULL)
00089 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00090
00091 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00092 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00093 this->name_.c_str());
00094
00095 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00096 : this->multiplexingManager_->requireSlot(*context);
00097 FieldValue<T>* pFV = this->getFieldValue(slot);
00098
00099 pFV->pendingBuffer((char*) pFV) = val;
00100 }
00101
00102
00103
00110 template<typename T>
00111 class GenericFieldStruct: public Field<T> {
00112 public:
00113
00120 GenericFieldStruct(const std::string& fieldName, bool multiplexed,
00121 DataStore* pDataStore, bool persistent,
00122 DataIntegrity bufferType = SingleBuffered);
00126 ~GenericFieldStruct();
00127
00133 const T* get(MultiplexingContext*);
00134
00140 void set(T* val, MultiplexingContext*);
00141 };
00142
00143 template<typename T>
00144 GenericFieldStruct<T>::GenericFieldStruct(const std::string& fieldName,
00145 bool multiplexed, DataStore* pDataStore, bool persistent,
00146 DataIntegrity bufferType) :
00147 Field<T> (fieldName, Generic, multiplexed, false, persistent,
00148 bufferType, pDataStore) {
00149 }
00150
00151 template<typename T>
00152 GenericFieldStruct<T>::~GenericFieldStruct() {
00153
00154 }
00155
00156 template<typename T>
00157 const T* GenericFieldStruct<T>::get(MultiplexingContext* context) {
00158
00159 if (context == NULL)
00160 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00161
00162 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00163 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00164 this->name_.c_str());
00165
00166 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00167 : this->multiplexingManager_->getSlot(*context);
00168 FieldValue<T>* pFV = this->getFieldValue(slot);
00169
00170 return &(pFV->activeBuffer((char*) pFV));
00171 }
00172
00173 template<typename T>
00174 void GenericFieldStruct<T>::set(T* val, MultiplexingContext* context) {
00175
00176 if (context == NULL)
00177 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00178
00179 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00180 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00181 this->name_.c_str());
00182
00183 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00184 : this->multiplexingManager_->requireSlot(*context);
00185 FieldValue<T>* pFV = this->getFieldValue(slot);
00186
00187 std::memcpy(&(pFV->pendingBuffer((char*) pFV)), val, sizeof(T));
00188 }
00189
00190
00191
00192 template<typename T>
00193 class GenericFieldArray: public FieldArray<T> {
00194 public:
00195
00202 GenericFieldArray(const std::string& fieldName, bool multiplexed,
00203 DataStore* pDataStore, bool persistent, int32_t size,
00204 DataIntegrity bufferType);
00205
00209 ~GenericFieldArray();
00210
00216 const T* get(uint32_t& size, MultiplexingContext* context);
00217
00224 void set(const T* val, uint32_t size, MultiplexingContext* context);
00225
00231 uint32_t getSize(MultiplexingContext* context);
00232 };
00233
00234 template<typename T>
00235 GenericFieldArray<T>::GenericFieldArray(const std::string& fieldName, bool multiplexed,
00236 DataStore* pDataStore, bool persistent, int32_t size,
00237 DataIntegrity bufferType) :
00238 FieldArray<T> (fieldName, Generic, multiplexed, false, persistent,
00239 bufferType, pDataStore, size) {
00240 }
00241
00242 template<typename T>
00243 GenericFieldArray<T>::~GenericFieldArray() {
00244
00245 }
00246
00247 template<typename T>
00248 const T* GenericFieldArray<T>::get(uint32_t& size,
00249 MultiplexingContext* context) {
00250
00251 if (context == NULL)
00252 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00253
00254 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00255 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00256 this->name_.c_str());
00257
00258 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00259 : this->multiplexingManager_->getSlot(*context);
00260 FieldValue<T[]>* pFV = this->getFieldValue(slot);
00261
00262 size = pFV->getActiveCurrentSize();
00263
00264 return (pFV->activeBuffer((char*) pFV));
00265 }
00266
00267 template<typename T>
00268 void GenericFieldArray<T>::set(const T* val, uint32_t size,
00269 MultiplexingContext* context) {
00270
00271 if (context == NULL)
00272 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00273
00274 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00275 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00276 this->name_.c_str());
00277
00278 this->checkMaxDimension(size);
00279
00280 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00281 : this->multiplexingManager_->requireSlot(*context);
00282 FieldValue<T[]>* pFV = this->getFieldValue(slot);
00283
00284 pFV->setPendingCurrentSize(size);
00285
00286 std::memcpy(pFV->pendingBuffer((char*) pFV), val, size * sizeof(T));
00287 }
00288
00289 template<typename T>
00290 uint32_t GenericFieldArray<T>::getSize(MultiplexingContext* context) {
00291 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00292 : this->multiplexingManager_->requireSlot(*context);
00293 FieldValue<T[]>* pFV = this->getFieldValue(slot);
00294 return pFV->getActiveCurrentSize();
00295 }
00296
00297
00298
00299 template<typename T>
00300 class GenericFieldScalarArray: public GenericFieldArray<T> {
00301 public:
00302
00309 GenericFieldScalarArray(const std::string& fieldName, bool multiplexed,
00310 DataStore* pDataStore, bool persistent, int32_t size,
00311 DataIntegrity bufferType = SingleBuffered);
00312
00316 ~GenericFieldScalarArray();
00317
00324 T getCell(uint32_t index, MultiplexingContext* context);
00325
00332 void setCell(T val, uint32_t index, MultiplexingContext* context);
00333 };
00334
00335 template<typename T>
00336 GenericFieldScalarArray<T>::GenericFieldScalarArray(const std::string& fieldName,
00337 bool multiplexed, DataStore* pDataStore, bool persistent, int32_t size,
00338 DataIntegrity bufferType) :
00339 GenericFieldArray<T> (fieldName, multiplexed, pDataStore, persistent, size,
00340 bufferType) {
00341
00342 }
00343
00344 template<typename T>
00345 GenericFieldScalarArray<T>::~GenericFieldScalarArray() {
00346
00347 }
00348
00349 template<typename T>
00350 T GenericFieldScalarArray<T>::getCell(uint32_t index,
00351 MultiplexingContext* context) {
00352
00353 if (context == NULL)
00354 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00355
00356 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00357 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00358 this->name_.c_str());
00359
00360 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00361 : this->multiplexingManager_->getSlot(*context);
00362 FieldValue<T[]>* pFV = this->getFieldValue(slot);
00363
00364 uint32_t size = pFV->getActiveCurrentSize();
00365 if ((index+1) > size) {
00366 throw FesaException(__FILE__, __LINE__,
00367 FesaErrorFieldCurrentDimensionOutOfBound.c_str(),
00368 StringUtilities::toString(index).c_str(), this->name_.c_str(),
00369 StringUtilities::toString(size).c_str());
00370 }
00371
00372 return (pFV->activeBuffer((char*) pFV)[index]);
00373 }
00374
00375 template<typename T>
00376 void GenericFieldScalarArray<T>::setCell(T val, uint32_t index,
00377 MultiplexingContext* context) {
00378
00379 if (context == NULL)
00380 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00381
00382 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00383 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00384 this->name_.c_str());
00385
00386 this->checkMaxDimension(index+1);
00387
00388 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00389 : this->multiplexingManager_->requireSlot(*context);
00390 FieldValue<T[]>* pFV = this->getFieldValue(slot);
00391
00392 uint32_t size = pFV->getPendingCurrentSize();
00393 if ((index + 1) > size)
00394 pFV->setPendingCurrentSize(index+1);
00395
00396 pFV->pendingBuffer((char*) pFV)[index] = val;
00397 }
00398
00399
00400
00401 template<typename T>
00402 class GenericFieldStructArray: public GenericFieldArray<T> {
00403 public:
00404
00411 GenericFieldStructArray(const std::string& fieldName, bool multiplexed,
00412 DataStore* pDataStore, bool persistent, int32_t size,
00413 DataIntegrity bufferType = SingleBuffered);
00414
00418 ~GenericFieldStructArray();
00419
00426 const T* getCell(uint32_t index, MultiplexingContext* context);
00427
00434 void setCell(T* val, uint32_t index, MultiplexingContext* context);
00435 };
00436
00437 template<typename T>
00438 GenericFieldStructArray<T>::GenericFieldStructArray(const std::string& fieldName,
00439 bool multiplexed, DataStore* pDataStore, bool persistent, int32_t size,
00440 DataIntegrity bufferType) :
00441 GenericFieldArray<T> (fieldName, multiplexed, pDataStore, persistent, size,
00442 bufferType) {
00443
00444 }
00445
00446 template<typename T>
00447 GenericFieldStructArray<T>::~GenericFieldStructArray() {
00448
00449 }
00450
00451 template<typename T>
00452 const T* GenericFieldStructArray<T>::getCell(uint32_t index,
00453 MultiplexingContext* context) {
00454
00455 if (context == NULL)
00456 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00457
00458 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00459 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00460 this->name_.c_str());
00461
00462 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00463 : this->multiplexingManager_->getSlot(*context);
00464 FieldValue<T[]>* pFV = this->getFieldValue(slot);
00465
00466 uint32_t size = pFV->getActiveCurrentSize();
00467 if ((index+1) > size) {
00468 throw FesaException(__FILE__, __LINE__,
00469 FesaErrorFieldCurrentDimensionOutOfBound.c_str(),
00470 StringUtilities::toString(index).c_str(), this->name_.c_str(),
00471 StringUtilities::toString(size).c_str());
00472 }
00473
00474 return &(pFV->activeBuffer((char*) pFV)[index]);
00475 }
00476
00477 template<typename T>
00478 void GenericFieldStructArray<T>::setCell(T* val, uint32_t index,
00479 MultiplexingContext* context) {
00480
00481 if (context == NULL)
00482 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00483
00484 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00485 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00486 this->name_.c_str());
00487
00488 this->checkMaxDimension(index + 1);
00489
00490 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00491 : this->multiplexingManager_->requireSlot(*context);
00492 FieldValue<T[]>* pFV = this->getFieldValue(slot);
00493
00494 uint32_t size = pFV->getPendingCurrentSize();
00495 if ((index + 1) > size)
00496 pFV->setPendingCurrentSize(index+1);
00497
00498 std::memcpy(&(pFV->activeBuffer((char*) pFV)[index]), val, sizeof(T));
00499 }
00500
00501
00502
00503 template<typename T>
00504 class GenericFieldArray2D: public FieldArray2D<T> {
00505 public:
00512 GenericFieldArray2D(const std::string& fieldName, bool multiplexed,
00513 DataStore* pDataStore, bool persistent, int32_t size1, int32_t size2,
00514 DataIntegrity bufferType);
00515
00519 ~GenericFieldArray2D();
00520
00528 const T** get(uint32_t& size1, uint32_t& size2,
00529 MultiplexingContext* context);
00530
00538 void getColumn(uint32_t index, uint32_t size, T* column, uint32_t& currentSize,
00539 MultiplexingContext* context);
00540
00548 const T* getRow(uint32_t index, uint32_t& size,
00549 MultiplexingContext* context);
00550
00559 void set(const T* const * val, uint32_t size1, uint32_t size2,
00560 MultiplexingContext* context);
00561
00569 void setColumn(const T* val, uint32_t index, uint32_t size,
00570 MultiplexingContext* context);
00571
00579 void setRow(const T* val, uint32_t index, uint32_t size,
00580 MultiplexingContext* context);
00581
00588 void getSize(uint32_t& size1, uint32_t& size2, MultiplexingContext* context);
00589 };
00590
00591 template<typename T>
00592 GenericFieldArray2D<T>::GenericFieldArray2D(const std::string& fieldName,
00593 bool multiplexed, DataStore* pDataStore, bool persistent, int32_t size1, int32_t size2,
00594 DataIntegrity bufferType) :
00595 FieldArray2D<T> (fieldName, Generic, multiplexed, false, persistent,
00596 bufferType, pDataStore, size1, size2) {
00597 }
00598
00599 template<typename T>
00600 GenericFieldArray2D<T>::~GenericFieldArray2D() {
00601
00602 }
00603
00604 template<typename T>
00605 const T** GenericFieldArray2D<T>::get(uint32_t& size1, uint32_t& size2,
00606 MultiplexingContext* context) {
00607
00608 if (context == NULL)
00609 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00610
00611 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00612 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00613 this->name_.c_str());
00614
00615 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00616 : this->multiplexingManager_->getSlot(*context);
00617 FieldValue<T[][1]>* pFV = this->getFieldValue(slot);
00618
00619 pFV->getActiveCurrentSize(size1, size2);
00620
00621 return (const T**) (pFV->activeBuffer((char*) pFV));
00622 }
00623
00624 template<typename T>
00625 void GenericFieldArray2D<T>::getColumn(uint32_t index, uint32_t size,
00626 T* column, uint32_t& currentSize, MultiplexingContext* context) {
00627
00628 if (context == NULL)
00629 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00630
00631 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00632 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00633 this->name_.c_str());
00634
00635 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00636 : this->multiplexingManager_->getSlot(*context);
00637 FieldValue<T[][1]>* pFV = this->getFieldValue(slot);
00638
00639 uint32_t size1, size2;
00640 pFV->getActiveCurrentSize(size1, size2);
00641 if ((index+1) > size2 || size < size1) {
00642 throw FesaException(__FILE__, __LINE__,
00643 FesaErrorFieldCurrentDimensionsOutOfBound.c_str(),
00644 StringUtilities::toString(index).c_str(),
00645 StringUtilities::toString(size).c_str(),
00646 this->name_.c_str(),
00647 StringUtilities::toString(size1).c_str(),
00648 StringUtilities::toString(size2).c_str());
00649 }
00650
00651 currentSize = size1;
00652 T(*activeVal)[size2];
00653 activeVal = (T(*)[size2]) pFV->activeBuffer((char*) pFV);
00654 for (uint32_t i = 0; i < size1; i++) {
00655 column[i] = activeVal[i][index];
00656 }
00657 }
00658
00659 template<typename T>
00660 const T* GenericFieldArray2D<T>::getRow(uint32_t index, uint32_t& size,
00661 MultiplexingContext* context) {
00662
00663 if (context == NULL)
00664 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00665
00666 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00667 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00668 this->name_.c_str());
00669
00670 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00671 : this->multiplexingManager_->getSlot(*context);
00672 FieldValue<T[][1]>* pFV = this->getFieldValue(slot);
00673
00674 uint32_t size1, size2;
00675 pFV->getActiveCurrentSize(size1, size2);
00676 if ((index+1) > size1) {
00677 throw FesaException(__FILE__, __LINE__,
00678 FesaErrorFieldCurrentDimensionOutOfBound.c_str(),
00679 StringUtilities::toString(index).c_str(), this->name_.c_str(),
00680 StringUtilities::toString(size1).c_str());
00681 }
00682
00683 size = size2;
00684 T(*activeVal)[size2];
00685 activeVal = (T(*)[size2]) pFV->activeBuffer((char*) pFV);
00686 return activeVal[index];
00687 }
00688
00689 template<typename T>
00690 void GenericFieldArray2D<T>::set(const T* const * val, uint32_t size1,
00691 uint32_t size2, MultiplexingContext* context) {
00692
00693 if (context == NULL)
00694 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00695
00696 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00697 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00698 this->name_.c_str());
00699
00700 this->checkMaxDimensions(size1, size2);
00701
00702 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00703 : this->multiplexingManager_->requireSlot(*context);
00704 FieldValue<T[][1]>* pFV = this->getFieldValue(slot);
00705
00706 pFV->setPendingCurrentSize(size1, size2);
00707
00708 std::memcpy(pFV->pendingBuffer((char*) pFV), val, size1 * size2 * sizeof(T));
00709 }
00710
00711 template<typename T>
00712 void GenericFieldArray2D<T>::setColumn(const T* val, uint32_t index,
00713 uint32_t size, MultiplexingContext* context) {
00714
00715 if (context == NULL)
00716 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00717
00718 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00719 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00720 this->name_.c_str());
00721
00722 this->checkMaxDimensions(size, index+1);
00723
00724 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00725 : this->multiplexingManager_->requireSlot(*context);
00726 FieldValue<T[][1]>* pFV = this->getFieldValue(slot);
00727
00728 uint32_t size1, size2;
00729 pFV->getPendingCurrentSize(size1, size2);
00730 uint32_t newSize1 = (size > size1) ? size : size1;
00731 uint32_t newSize2 = ((index+1) > size2) ? (index+1) : size2;
00732 pFV->setPendingCurrentSize(newSize1, newSize2);
00733
00734 T(*activeVal)[newSize2];
00735 activeVal = (T(*)[newSize2]) pFV->pendingBuffer((char*) pFV);
00736 for (uint32_t i = 0; i < size; i++) {
00737 activeVal[i][index] = val[i];
00738 }
00739 }
00740
00741 template<typename T>
00742 void GenericFieldArray2D<T>::setRow(const T* val, uint32_t index,
00743 uint32_t size, MultiplexingContext* context) {
00744
00745 if (context == NULL)
00746 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00747
00748 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00749 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00750 this->name_.c_str());
00751
00752 this->checkMaxDimensions(index+1, size);
00753
00754 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00755 : this->multiplexingManager_->requireSlot(*context);
00756 FieldValue<T[][1]>* pFV = this->getFieldValue(slot);
00757
00758 uint32_t size1, size2;
00759 pFV->getPendingCurrentSize(size1, size2);
00760 uint32_t newSize1 = ((index+1) > size1) ? (index+1) : size1;
00761 uint32_t newSize2 = (size > size2) ? size : size2;
00762 pFV->setPendingCurrentSize(newSize1, newSize2);
00763
00764
00765 T(*pendingVal)[newSize2];
00766 pendingVal = (T(*)[newSize2]) pFV->pendingBuffer((char*) pFV);
00767 std::memcpy(pendingVal[index], val, size * sizeof(T));
00768 }
00769
00770 template<typename T>
00771 void GenericFieldArray2D<T>::getSize(uint32_t& size1, uint32_t& size2, MultiplexingContext* context) {
00772
00773 if (context == NULL)
00774 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00775
00776 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00777 : this->multiplexingManager_->requireSlot(*context);
00778 FieldValue<T[][1]>* pFV = this->getFieldValue(slot);
00779 pFV->getActiveCurrentSize(size1, size2);
00780 }
00781
00782
00783
00784 template<typename T>
00785 class GenericFieldScalarArray2D: public GenericFieldArray2D<T> {
00786 public:
00793 GenericFieldScalarArray2D(const std::string& fieldName, bool multiplexed,
00794 DataStore* pDataStore, bool persistent, int32_t size1, int32_t size2,
00795 DataIntegrity bufferType = SingleBuffered);
00796
00800 ~GenericFieldScalarArray2D();
00801
00809 T getCell(uint32_t index1, uint32_t index2,
00810 MultiplexingContext* context);
00811
00819 void setCell(T val, uint32_t index1, uint32_t index2,
00820 MultiplexingContext* context);
00821
00822 };
00823
00824 template<typename T>
00825 GenericFieldScalarArray2D<T>::GenericFieldScalarArray2D(const std::string& fieldName,
00826 bool multiplexed, DataStore* pDataStore, bool persistent, int32_t size1, int32_t size2,
00827 DataIntegrity bufferType) :
00828 GenericFieldArray2D<T> (fieldName, multiplexed, pDataStore, persistent, size1, size2,
00829 bufferType) {
00830
00831 }
00832
00833 template<typename T>
00834 T GenericFieldScalarArray2D<T>::getCell(uint32_t index1, uint32_t index2,
00835 MultiplexingContext* context) {
00836
00837 if (context == NULL)
00838 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00839
00840 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00841 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00842 this->name_.c_str());
00843
00844 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00845 : this->multiplexingManager_->getSlot(*context);
00846 FieldValue<T[][1]>* pFV = this->getFieldValue(slot);
00847
00848 uint32_t size1, size2;
00849 pFV->getActiveCurrentSize(size1, size2);
00850 if ( ((index1+1) > size1) || ((index2+1) > size2) ) {
00851 throw FesaException(__FILE__, __LINE__,
00852 FesaErrorFieldCurrentDimensionsOutOfBound.c_str(),
00853 StringUtilities::toString(index1).c_str(),
00854 StringUtilities::toString(index2).c_str(),
00855 this->name_.c_str(),
00856 StringUtilities::toString(size1).c_str(),
00857 StringUtilities::toString(size2).c_str());
00858 }
00859
00860 T(*activeVal)[size2];
00861 activeVal = (T(*)[size2]) pFV->activeBuffer((char*) pFV);
00862 return activeVal[index1][index2];
00863 }
00864
00865 template<typename T>
00866 void GenericFieldScalarArray2D<T>::setCell(T val, uint32_t index1,
00867 uint32_t index2, MultiplexingContext* context) {
00868
00869 if (context == NULL)
00870 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00871
00872 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00873 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00874 this->name_.c_str());
00875
00876 this->checkMaxDimensions((index1+1), (index2+1));
00877
00878 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00879 : this->multiplexingManager_->requireSlot(*context);
00880 FieldValue<T[][1]>* pFV = this->getFieldValue(slot);
00881
00882 uint32_t size1, size2;
00883 pFV->getPendingCurrentSize(size1, size2);
00884 uint32_t newSize1 = ((index1+1) > size1) ? (index1+1) : size1;
00885 uint32_t newSize2 = ((index2+1) > size2) ? (index2+1) : size2;
00886 pFV->setPendingCurrentSize(newSize1, newSize2);
00887
00888 T(*activeVal)[newSize2];
00889 activeVal = (T(*)[newSize2]) pFV->pendingBuffer((char*) pFV);
00890 activeVal[index1][index2] = val;
00891 }
00892
00893 template<typename T>
00894 GenericFieldScalarArray2D<T>::~GenericFieldScalarArray2D() {
00895
00896 }
00897
00898
00899
00900 template<typename T>
00901 class GenericFieldStructArray2D: public GenericFieldArray2D<T> {
00902 public:
00909 GenericFieldStructArray2D(const std::string& fieldName, bool multiplexed,
00910 DataStore* pDataStore, bool persistent, int32_t size1, int32_t size2,
00911 DataIntegrity bufferType = SingleBuffered);
00912
00916 ~GenericFieldStructArray2D();
00917
00925 const T* getCell(uint32_t index1, uint32_t index2,
00926 MultiplexingContext* context = 0);
00927
00935 void setCell(T* val, uint32_t index1, uint32_t index2,
00936 MultiplexingContext* context);
00937
00938 };
00939
00940 template<typename T>
00941 GenericFieldStructArray2D<T>::GenericFieldStructArray2D(const std::string& fieldName,
00942 bool multiplexed, DataStore* pDataStore, bool persistent, int32_t size1, int32_t size2,
00943 DataIntegrity bufferType) :
00944 GenericFieldArray2D<T> (fieldName, multiplexed, pDataStore, persistent, size1, size2,
00945 bufferType) {
00946
00947 }
00948
00949 template<typename T>
00950 const T* GenericFieldStructArray2D<T>::getCell(uint32_t index1,
00951 uint32_t index2, MultiplexingContext* context) {
00952
00953 if (context == NULL)
00954 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00955
00956 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00957 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00958 this->name_.c_str());
00959
00960 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00961 : this->multiplexingManager_->getSlot(*context);
00962 FieldValue<T[][1]>* pFV = this->getFieldValue(slot);
00963
00964 uint32_t size1, size2;
00965 pFV->getActiveCurrentSize(size1, size2);
00966 if ( ((index1+1) > size1) || ((index2+1) > size2) ) {
00967 throw FesaException(__FILE__, __LINE__,
00968 FesaErrorFieldCurrentDimensionsOutOfBound.c_str(),
00969 StringUtilities::toString(index1).c_str(),
00970 StringUtilities::toString(index2).c_str(),
00971 this->name_.c_str(),
00972 StringUtilities::toString(size1).c_str(),
00973 StringUtilities::toString(size2).c_str());
00974 }
00975
00976 T(*activeVal)[size2];
00977 activeVal = (T(*)[size2]) pFV->activeBuffer((char*) pFV);
00978 return &(activeVal[index1][index2]);
00979 }
00980
00981 template<typename T>
00982 void GenericFieldStructArray2D<T>::setCell(T* val, uint32_t index1,
00983 uint32_t index2, MultiplexingContext* context) {
00984
00985 if (context == NULL)
00986 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00987
00988 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00989 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00990 this->name_.c_str());
00991
00992 this->checkMaxDimensions((index1+1), (index2+1));
00993
00994 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00995 : this->multiplexingManager_->requireSlot(*context);
00996 FieldValue<T[][1]>* pFV = this->getFieldValue(slot);
00997
00998 uint32_t size1, size2;
00999 pFV->getPendingCurrentSize(size1, size2);
01000 uint32_t newSize1 = ((index1+1) > size1) ? (index1+1) : size1;
01001 uint32_t newSize2 = ((index2+1) > size2) ? (index2+1) : size2;
01002 pFV->setPendingCurrentSize(newSize1, newSize2);
01003
01004 T(*pendingVal)[newSize2];
01005 pendingVal = (T(*)[newSize2]) pFV->pendingBuffer((char*) pFV);
01006 std::memcpy(&(pendingVal[index1][index2]), val, sizeof(T));
01007 }
01008
01009 template<typename T>
01010 GenericFieldStructArray2D<T>::~GenericFieldStructArray2D() {
01011
01012 }
01013
01014
01015
01016 class GenericFieldString: public FieldString {
01017 public:
01024 GenericFieldString(const std::string& fieldName, bool multiplexed,
01025 DataStore* pDataStore, bool persistent, int32_t size,
01026 DataIntegrity bufferType = SingleBuffered);
01027
01028 ~GenericFieldString();
01029
01035 const char* get(MultiplexingContext* context);
01036
01042 void set(const char* val, MultiplexingContext* context);
01043
01044 };
01045
01046
01047
01048 class GenericFieldStringArray: public FieldStringArray {
01049 public:
01056 GenericFieldStringArray(const std::string& fieldName, bool multiplexed,
01057 DataStore* pDataStore, bool persistent, int32_t size1, int32_t size2,
01058 DataIntegrity bufferType = SingleBuffered);
01062 ~GenericFieldStringArray();
01063
01069 const char** get(uint32_t& size1, MultiplexingContext* context);
01070
01077 const char* getString(uint32_t index, MultiplexingContext* context);
01078
01084 void set(const char** val, uint32_t size1,
01085 MultiplexingContext* context);
01086
01093 void setString(const char* val, uint32_t index,
01094 MultiplexingContext* context);
01095
01096 };
01097
01098
01099
01100 }
01101
01102 #endif // GENERIC_FIELD_H_