00001
00002
00003 #ifndef ACQUISITION_FIELD_H_
00004 #define ACQUISITION_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 AcqFieldScalar : public Field<T>
00024 {
00025 public:
00026
00033 AcqFieldScalar(const std::string& fieldName, bool multiplexed,
00034 DataStore* pDataStore, bool persistent = false,
00035 DataIntegrity bufferType = SingleBuffered);
00039 ~AcqFieldScalar();
00040
00046 T get(MultiplexingContext*);
00047
00053 void set(T val, MultiplexingContext*);
00054 };
00055
00056 template<typename T>
00057 AcqFieldScalar<T>::AcqFieldScalar(const std::string& fieldName,
00058 bool multiplexed, DataStore* pDataStore, bool persistent,
00059 DataIntegrity bufferType) :
00060 Field<T> (fieldName, Acquisition, multiplexed, false, persistent,
00061 bufferType, pDataStore) {
00062 }
00063
00064 template<typename T>
00065 AcqFieldScalar<T>::~AcqFieldScalar() {
00066
00067 }
00068
00069 template<typename T>
00070 T AcqFieldScalar<T>::get(MultiplexingContext* context) {
00071
00072 if (context == NULL)
00073 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00074
00075 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00076 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00077 this->name_.c_str());
00078
00079 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00080 : this->multiplexingManager_->getSlot(*context);
00081 FieldValue<T>* pFV = this->getFieldValue(slot);
00082
00083 return (pFV->activeBuffer((char*) pFV));
00084 }
00085
00086 template<typename T>
00087 void AcqFieldScalar<T>::set(T val, MultiplexingContext* context) {
00088
00089 if (context == NULL)
00090 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00091
00092 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00093 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00094 this->name_.c_str());
00095
00096 if (!(context->getAcquisitionAccessMask() & MultiplexingContext::SET_ALLOWED))
00097 throw FesaException(__FILE__, __LINE__, FesaErrorWrongSourceContextAcquisitionField.c_str(),
00098 this->name_.c_str());
00099
00100 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00101 : this->multiplexingManager_->requireSlot(*context);
00102 FieldValue<T>* pFV = this->getFieldValue(slot);
00103
00104 pFV->pendingBuffer((char*) pFV) = val;
00105 }
00106
00107
00108
00115 template<typename T>
00116 class AcqFieldStruct: public Field<T> {
00117 public:
00118
00125 AcqFieldStruct(const std::string& fieldName, bool multiplexed,
00126 DataStore* pDataStore, bool persistent,
00127 DataIntegrity bufferType = SingleBuffered);
00131 ~AcqFieldStruct();
00132
00138 const T* get(MultiplexingContext*);
00139
00145 void set(T* val, MultiplexingContext*);
00146 };
00147
00148 template<typename T>
00149 AcqFieldStruct<T>::AcqFieldStruct(const std::string& fieldName,
00150 bool multiplexed, DataStore* pDataStore, bool persistent,
00151 DataIntegrity bufferType) :
00152 Field<T> (fieldName, Acquisition, multiplexed, false, persistent,
00153 bufferType, pDataStore) {
00154 }
00155
00156 template<typename T>
00157 AcqFieldStruct<T>::~AcqFieldStruct() {
00158
00159 }
00160
00161 template<typename T>
00162 const T* AcqFieldStruct<T>::get(MultiplexingContext* context) {
00163
00164 if (context == NULL)
00165 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00166
00167 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00168 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00169 this->name_.c_str());
00170
00171 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00172 : this->multiplexingManager_->getSlot(*context);
00173 FieldValue<T>* pFV = this->getFieldValue(slot);
00174
00175 return &(pFV->activeBuffer((char*) pFV));
00176 }
00177
00178 template<typename T>
00179 void AcqFieldStruct<T>::set(T* val, MultiplexingContext* context) {
00180
00181 if (context == NULL)
00182 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00183
00184 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00185 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00186 this->name_.c_str());
00187
00188 if (!(context->getAcquisitionAccessMask() & MultiplexingContext::SET_ALLOWED))
00189 throw FesaException(__FILE__, __LINE__, FesaErrorWrongSourceContextAcquisitionField.c_str(),
00190 this->name_.c_str());
00191
00192 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00193 : this->multiplexingManager_->requireSlot(*context);
00194 FieldValue<T>* pFV = this->getFieldValue(slot);
00195
00196 std::memcpy(&(pFV->pendingBuffer((char*) pFV)), val, sizeof(T));
00197 }
00198
00199
00200
00201 template<typename T>
00202 class AcqFieldArray: public FieldArray<T> {
00203 public:
00204
00211 AcqFieldArray(const std::string& fieldName, bool multiplexed,
00212 DataStore* pDataStore, bool persistent, int32_t size,
00213 DataIntegrity bufferType);
00214
00218 ~AcqFieldArray();
00219
00225 const T* get(uint32_t& size, MultiplexingContext* context);
00226
00233 void set(const T* val, uint32_t size, MultiplexingContext* context);
00234
00240 uint32_t getSize(MultiplexingContext* context);
00241 };
00242
00243 template<typename T>
00244 AcqFieldArray<T>::AcqFieldArray(const std::string& fieldName, bool multiplexed,
00245 DataStore* pDataStore, bool persistent, int32_t size,
00246 DataIntegrity bufferType) :
00247 FieldArray<T> (fieldName, Acquisition, multiplexed, false, persistent,
00248 bufferType, pDataStore, size) {
00249 }
00250
00251 template<typename T>
00252 AcqFieldArray<T>::~AcqFieldArray() {
00253
00254 }
00255
00256 template<typename T>
00257 const T* AcqFieldArray<T>::get(uint32_t& size,
00258 MultiplexingContext* context) {
00259
00260 if (context == NULL)
00261 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00262
00263 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00264 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00265 this->name_.c_str());
00266
00267 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00268 : this->multiplexingManager_->getSlot(*context);
00269 FieldValue<T[]>* pFV = this->getFieldValue(slot);
00270
00271 size = pFV->getActiveCurrentSize();
00272
00273 return (pFV->activeBuffer((char*) pFV));
00274 }
00275
00276 template<typename T>
00277 void AcqFieldArray<T>::set(const T* val, uint32_t size,
00278 MultiplexingContext* context) {
00279
00280 if (context == NULL)
00281 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00282
00283 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00284 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00285 this->name_.c_str());
00286
00287 if (!(context->getAcquisitionAccessMask() & MultiplexingContext::SET_ALLOWED))
00288 throw FesaException(__FILE__, __LINE__, FesaErrorWrongSourceContextAcquisitionField.c_str(),
00289 this->name_.c_str());
00290
00291 this->checkMaxDimension(size);
00292
00293 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00294 : this->multiplexingManager_->requireSlot(*context);
00295 FieldValue<T[]>* pFV = this->getFieldValue(slot);
00296
00297 pFV->setPendingCurrentSize(size);
00298
00299 std::memcpy(pFV->pendingBuffer((char*) pFV), val, size * sizeof(T));
00300 }
00301
00302 template<typename T>
00303 uint32_t AcqFieldArray<T>::getSize(MultiplexingContext* context) {
00304 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00305 : this->multiplexingManager_->requireSlot(*context);
00306 FieldValue<T[]>* pFV = this->getFieldValue(slot);
00307 return pFV->getActiveCurrentSize();
00308 }
00309
00310
00311
00312 template<typename T>
00313 class AcqFieldScalarArray: public AcqFieldArray<T> {
00314 public:
00315
00322 AcqFieldScalarArray(const std::string& fieldName, bool multiplexed,
00323 DataStore* pDataStore, bool persistent, int32_t size,
00324 DataIntegrity bufferType = SingleBuffered);
00325
00329 ~AcqFieldScalarArray();
00330
00337 T getCell(uint32_t index, MultiplexingContext* context);
00338
00345 void setCell(T val, uint32_t index, MultiplexingContext* context);
00346 };
00347
00348 template<typename T>
00349 AcqFieldScalarArray<T>::AcqFieldScalarArray(const std::string& fieldName,
00350 bool multiplexed, DataStore* pDataStore, bool persistent, int32_t size,
00351 DataIntegrity bufferType) :
00352 AcqFieldArray<T> (fieldName, multiplexed, pDataStore, persistent, size,
00353 bufferType) {
00354
00355 }
00356
00357 template<typename T>
00358 AcqFieldScalarArray<T>::~AcqFieldScalarArray() {
00359
00360 }
00361
00362 template<typename T>
00363 T AcqFieldScalarArray<T>::getCell(uint32_t index,
00364 MultiplexingContext* context) {
00365
00366 if (context == NULL)
00367 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00368
00369 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00370 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00371 this->name_.c_str());
00372
00373 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00374 : this->multiplexingManager_->getSlot(*context);
00375 FieldValue<T[]>* pFV = this->getFieldValue(slot);
00376
00377 uint32_t size = pFV->getActiveCurrentSize();
00378 if ((index+1) > size) {
00379 throw FesaException(__FILE__, __LINE__,
00380 FesaErrorFieldCurrentDimensionOutOfBound.c_str(),
00381 StringUtilities::toString(index).c_str(), this->name_.c_str(),
00382 StringUtilities::toString(size).c_str());
00383 }
00384
00385 return (pFV->activeBuffer((char*) pFV)[index]);
00386 }
00387
00388 template<typename T>
00389 void AcqFieldScalarArray<T>::setCell(T val, uint32_t index,
00390 MultiplexingContext* context) {
00391
00392 if (context == NULL)
00393 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00394
00395 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00396 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00397 this->name_.c_str());
00398
00399 if (!(context->getAcquisitionAccessMask() & MultiplexingContext::SET_ALLOWED))
00400 throw FesaException(__FILE__, __LINE__, FesaErrorWrongSourceContextAcquisitionField.c_str(),
00401 this->name_.c_str());
00402
00403 this->checkMaxDimension(index+1);
00404
00405 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00406 : this->multiplexingManager_->requireSlot(*context);
00407 FieldValue<T[]>* pFV = this->getFieldValue(slot);
00408
00409 uint32_t size = pFV->getPendingCurrentSize();
00410 if ((index + 1) > size)
00411 pFV->setPendingCurrentSize(index+1);
00412
00413 pFV->pendingBuffer((char*) pFV)[index] = val;
00414 }
00415
00416
00417
00418 template<typename T>
00419 class AcqFieldStructArray: public AcqFieldArray<T> {
00420 public:
00421
00428 AcqFieldStructArray(const std::string& fieldName, bool multiplexed,
00429 DataStore* pDataStore, bool persistent, int32_t size,
00430 DataIntegrity bufferType = SingleBuffered);
00431
00435 ~AcqFieldStructArray();
00436
00443 const T* getCell(uint32_t index, MultiplexingContext* context);
00444
00451 void setCell(T* val, uint32_t index, MultiplexingContext* context);
00452 };
00453
00454 template<typename T>
00455 AcqFieldStructArray<T>::AcqFieldStructArray(const std::string& fieldName,
00456 bool multiplexed, DataStore* pDataStore, bool persistent, int32_t size,
00457 DataIntegrity bufferType) :
00458 AcqFieldArray<T> (fieldName, multiplexed, pDataStore, persistent, size,
00459 bufferType) {
00460
00461 }
00462
00463 template<typename T>
00464 AcqFieldStructArray<T>::~AcqFieldStructArray() {
00465
00466 }
00467
00468 template<typename T>
00469 const T* AcqFieldStructArray<T>::getCell(uint32_t index,
00470 MultiplexingContext* context) {
00471
00472 if (context == NULL)
00473 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00474
00475 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00476 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00477 this->name_.c_str());
00478
00479 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00480 : this->multiplexingManager_->getSlot(*context);
00481 FieldValue<T[]>* pFV = this->getFieldValue(slot);
00482
00483 uint32_t size = pFV->getActiveCurrentSize();
00484 if ((index+1) > size) {
00485 throw FesaException(__FILE__, __LINE__,
00486 FesaErrorFieldCurrentDimensionOutOfBound.c_str(),
00487 StringUtilities::toString(index).c_str(), this->name_.c_str(),
00488 StringUtilities::toString(size).c_str());
00489 }
00490
00491 return &(pFV->activeBuffer((char*) pFV)[index]);
00492 }
00493
00494 template<typename T>
00495 void AcqFieldStructArray<T>::setCell(T* val, uint32_t index,
00496 MultiplexingContext* context) {
00497
00498 if (context == NULL)
00499 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00500
00501 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00502 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00503 this->name_.c_str());
00504
00505 if (!(context->getAcquisitionAccessMask() & MultiplexingContext::SET_ALLOWED))
00506 throw FesaException(__FILE__, __LINE__, FesaErrorWrongSourceContextAcquisitionField.c_str(),
00507 this->name_.c_str());
00508
00509 this->checkMaxDimension(index + 1);
00510
00511 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00512 : this->multiplexingManager_->requireSlot(*context);
00513 FieldValue<T[]>* pFV = this->getFieldValue(slot);
00514
00515 uint32_t size = pFV->getPendingCurrentSize();
00516 if ((index + 1) > size)
00517 pFV->setPendingCurrentSize(index+1);
00518
00519 std::memcpy(&(pFV->activeBuffer((char*) pFV)[index]), val, sizeof(T));
00520 }
00521
00522
00523
00524 template<typename T>
00525 class AcqFieldArray2D: public FieldArray2D<T> {
00526 public:
00533 AcqFieldArray2D(const std::string& fieldName, bool multiplexed,
00534 DataStore* pDataStore, bool persistent, int32_t size1, int32_t size2,
00535 DataIntegrity bufferType);
00536
00540 ~AcqFieldArray2D();
00541
00549 const T** get(uint32_t& size1, uint32_t& size2,
00550 MultiplexingContext* context);
00551
00559 void getColumn(uint32_t index, uint32_t size, T* column, uint32_t& currentSize,
00560 MultiplexingContext* context);
00561
00569 const T* getRow(uint32_t index, uint32_t& size,
00570 MultiplexingContext* context);
00571
00580 void set(const T* const * val, uint32_t size1, uint32_t size2,
00581 MultiplexingContext* context);
00582
00590 void setColumn(const T* val, uint32_t index, uint32_t size,
00591 MultiplexingContext* context);
00592
00600 void setRow(const T* val, uint32_t index, uint32_t size,
00601 MultiplexingContext* context);
00602
00609 void getSize(uint32_t& size1, uint32_t& size2, MultiplexingContext* context);
00610 };
00611
00612 template<typename T>
00613 AcqFieldArray2D<T>::AcqFieldArray2D(const std::string& fieldName,
00614 bool multiplexed, DataStore* pDataStore, bool persistent, int32_t size1, int32_t size2,
00615 DataIntegrity bufferType) :
00616 FieldArray2D<T> (fieldName, Acquisition, multiplexed, false, persistent,
00617 bufferType, pDataStore, size1, size2) {
00618 }
00619
00620 template<typename T>
00621 AcqFieldArray2D<T>::~AcqFieldArray2D() {
00622
00623 }
00624
00625 template<typename T>
00626 const T** AcqFieldArray2D<T>::get(uint32_t& size1, uint32_t& size2,
00627 MultiplexingContext* context) {
00628
00629 if (context == NULL)
00630 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00631
00632 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00633 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00634 this->name_.c_str());
00635
00636 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00637 : this->multiplexingManager_->getSlot(*context);
00638 FieldValue<T[][1]>* pFV = this->getFieldValue(slot);
00639
00640 pFV->getActiveCurrentSize(size1, size2);
00641
00642 return (const T**) (pFV->activeBuffer((char*) pFV));
00643 }
00644
00645 template<typename T>
00646 void AcqFieldArray2D<T>::getColumn(uint32_t index, uint32_t size,
00647 T* column, uint32_t& currentSize, MultiplexingContext* context) {
00648
00649 if (context == NULL)
00650 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00651
00652 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00653 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00654 this->name_.c_str());
00655
00656 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00657 : this->multiplexingManager_->getSlot(*context);
00658 FieldValue<T[][1]>* pFV = this->getFieldValue(slot);
00659
00660 uint32_t size1, size2;
00661 pFV->getActiveCurrentSize(size1, size2);
00662 if ((index+1) > size2 || size < size1) {
00663 throw FesaException(__FILE__, __LINE__,
00664 FesaErrorFieldCurrentDimensionsOutOfBound.c_str(),
00665 StringUtilities::toString(index).c_str(),
00666 StringUtilities::toString(size).c_str(),
00667 this->name_.c_str(),
00668 StringUtilities::toString(size1).c_str(),
00669 StringUtilities::toString(size2).c_str());
00670 }
00671
00672 currentSize = size1;
00673 T(*activeVal)[size2];
00674 activeVal = (T(*)[size2]) pFV->activeBuffer((char*) pFV);
00675 for (uint32_t i = 0; i < size1; i++) {
00676 column[i] = activeVal[i][index];
00677 }
00678 }
00679
00680 template<typename T>
00681 const T* AcqFieldArray2D<T>::getRow(uint32_t index, uint32_t& size,
00682 MultiplexingContext* context) {
00683
00684 if (context == NULL)
00685 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00686
00687 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00688 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00689 this->name_.c_str());
00690
00691 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00692 : this->multiplexingManager_->getSlot(*context);
00693 FieldValue<T[][1]>* pFV = this->getFieldValue(slot);
00694
00695 uint32_t size1, size2;
00696 pFV->getActiveCurrentSize(size1, size2);
00697 if ((index+1) > size1) {
00698 throw FesaException(__FILE__, __LINE__,
00699 FesaErrorFieldCurrentDimensionOutOfBound.c_str(),
00700 StringUtilities::toString(index).c_str(), this->name_.c_str(),
00701 StringUtilities::toString(size1).c_str());
00702 }
00703
00704 size = size2;
00705 T(*activeVal)[size2];
00706 activeVal = (T(*)[size2]) pFV->activeBuffer((char*) pFV);
00707 return activeVal[index];
00708 }
00709
00710 template<typename T>
00711 void AcqFieldArray2D<T>::set(const T* const * val, uint32_t size1,
00712 uint32_t size2, MultiplexingContext* context) {
00713
00714 if (context == NULL)
00715 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00716
00717 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00718 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00719 this->name_.c_str());
00720
00721 if (!(context->getAcquisitionAccessMask() & MultiplexingContext::SET_ALLOWED))
00722 throw FesaException(__FILE__, __LINE__, FesaErrorWrongSourceContextAcquisitionField.c_str(),
00723 this->name_.c_str());
00724
00725 this->checkMaxDimensions(size1, size2);
00726
00727 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00728 : this->multiplexingManager_->requireSlot(*context);
00729 FieldValue<T[][1]>* pFV = this->getFieldValue(slot);
00730
00731 pFV->setPendingCurrentSize(size1, size2);
00732
00733 std::memcpy(pFV->pendingBuffer((char*) pFV), val, size1 * size2 * sizeof(T));
00734 }
00735
00736 template<typename T>
00737 void AcqFieldArray2D<T>::setColumn(const T* val, uint32_t index,
00738 uint32_t size, MultiplexingContext* context) {
00739
00740 if (context == NULL)
00741 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00742
00743 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00744 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00745 this->name_.c_str());
00746
00747 if (!(context->getAcquisitionAccessMask() & MultiplexingContext::SET_ALLOWED))
00748 throw FesaException(__FILE__, __LINE__, FesaErrorWrongSourceContextAcquisitionField.c_str(),
00749 this->name_.c_str());
00750
00751 this->checkMaxDimensions(size, index+1);
00752
00753 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00754 : this->multiplexingManager_->requireSlot(*context);
00755 FieldValue<T[][1]>* pFV = this->getFieldValue(slot);
00756
00757 uint32_t size1, size2;
00758 pFV->getPendingCurrentSize(size1, size2);
00759 uint32_t newSize1 = (size > size1) ? size : size1;
00760 uint32_t newSize2 = ((index+1) > size2) ? (index+1) : size2;
00761 pFV->setPendingCurrentSize(newSize1, newSize2);
00762
00763 T(*activeVal)[newSize2];
00764 activeVal = (T(*)[newSize2]) pFV->pendingBuffer((char*) pFV);
00765 for (uint32_t i = 0; i < size; i++) {
00766 activeVal[i][index] = val[i];
00767 }
00768 }
00769
00770 template<typename T>
00771 void AcqFieldArray2D<T>::setRow(const T* val, uint32_t index,
00772 uint32_t size, MultiplexingContext* context) {
00773
00774 if (context == NULL)
00775 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00776
00777 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00778 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00779 this->name_.c_str());
00780
00781 if (!(context->getAcquisitionAccessMask() & MultiplexingContext::SET_ALLOWED))
00782 throw FesaException(__FILE__, __LINE__, FesaErrorWrongSourceContextAcquisitionField.c_str(),
00783 this->name_.c_str());
00784
00785 this->checkMaxDimensions(index+1, size);
00786
00787 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00788 : this->multiplexingManager_->requireSlot(*context);
00789 FieldValue<T[][1]>* pFV = this->getFieldValue(slot);
00790
00791 uint32_t size1, size2;
00792 pFV->getPendingCurrentSize(size1, size2);
00793 uint32_t newSize1 = ((index+1) > size1) ? (index+1) : size1;
00794 uint32_t newSize2 = (size > size2) ? size : size2;
00795 pFV->setPendingCurrentSize(newSize1, newSize2);
00796
00797
00798 T(*pendingVal)[newSize2];
00799 pendingVal = (T(*)[newSize2]) pFV->pendingBuffer((char*) pFV);
00800 std::memcpy(pendingVal[index], val, size * sizeof(T));
00801 }
00802
00803 template<typename T>
00804 void AcqFieldArray2D<T>::getSize(uint32_t& size1, uint32_t& size2, MultiplexingContext* context) {
00805
00806 if (context == NULL)
00807 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00808
00809 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00810 : this->multiplexingManager_->requireSlot(*context);
00811 FieldValue<T[][1]>* pFV = this->getFieldValue(slot);
00812 pFV->getActiveCurrentSize(size1, size2);
00813 }
00814
00815
00816
00817 template<typename T>
00818 class AcqFieldScalarArray2D: public AcqFieldArray2D<T> {
00819 public:
00826 AcqFieldScalarArray2D(const std::string& fieldName, bool multiplexed,
00827 DataStore* pDataStore, bool persistent, int32_t size1, int32_t size2,
00828 DataIntegrity bufferType = SingleBuffered);
00829
00833 ~AcqFieldScalarArray2D();
00834
00842 T getCell(uint32_t index1, uint32_t index2,
00843 MultiplexingContext* context);
00844
00852 void setCell(T val, uint32_t index1, uint32_t index2,
00853 MultiplexingContext* context);
00854
00855 };
00856
00857 template<typename T>
00858 AcqFieldScalarArray2D<T>::AcqFieldScalarArray2D(const std::string& fieldName,
00859 bool multiplexed, DataStore* pDataStore, bool persistent, int32_t size1, int32_t size2,
00860 DataIntegrity bufferType) :
00861 AcqFieldArray2D<T> (fieldName, multiplexed, pDataStore, persistent, size1, size2,
00862 bufferType) {
00863
00864 }
00865
00866 template<typename T>
00867 T AcqFieldScalarArray2D<T>::getCell(uint32_t index1, uint32_t index2,
00868 MultiplexingContext* context) {
00869
00870 if (context == NULL)
00871 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00872
00873 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00874 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00875 this->name_.c_str());
00876
00877 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00878 : this->multiplexingManager_->getSlot(*context);
00879 FieldValue<T[][1]>* pFV = this->getFieldValue(slot);
00880
00881 uint32_t size1, size2;
00882 pFV->getActiveCurrentSize(size1, size2);
00883 if ( ((index1+1) > size1) || ((index2+1) > size2) ) {
00884 throw FesaException(__FILE__, __LINE__,
00885 FesaErrorFieldCurrentDimensionsOutOfBound.c_str(),
00886 StringUtilities::toString(index1).c_str(),
00887 StringUtilities::toString(index2).c_str(),
00888 this->name_.c_str(),
00889 StringUtilities::toString(size1).c_str(),
00890 StringUtilities::toString(size2).c_str());
00891 }
00892
00893 T(*activeVal)[size2];
00894 activeVal = (T(*)[size2]) pFV->activeBuffer((char*) pFV);
00895 return activeVal[index1][index2];
00896 }
00897
00898 template<typename T>
00899 void AcqFieldScalarArray2D<T>::setCell(T val, uint32_t index1,
00900 uint32_t index2, MultiplexingContext* context) {
00901
00902 if (context == NULL)
00903 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00904
00905 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00906 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00907 this->name_.c_str());
00908
00909 if (!(context->getAcquisitionAccessMask() & MultiplexingContext::SET_ALLOWED))
00910 throw FesaException(__FILE__, __LINE__, FesaErrorWrongSourceContextAcquisitionField.c_str(),
00911 this->name_.c_str());
00912
00913 this->checkMaxDimensions((index1+1), (index2+1));
00914
00915 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00916 : this->multiplexingManager_->requireSlot(*context);
00917 FieldValue<T[][1]>* pFV = this->getFieldValue(slot);
00918
00919 uint32_t size1, size2;
00920 pFV->getPendingCurrentSize(size1, size2);
00921 uint32_t newSize1 = ((index1+1) > size1) ? (index1+1) : size1;
00922 uint32_t newSize2 = ((index2+1) > size2) ? (index2+1) : size2;
00923 pFV->setPendingCurrentSize(newSize1, newSize2);
00924
00925 T(*activeVal)[newSize2];
00926 activeVal = (T(*)[newSize2]) pFV->pendingBuffer((char*) pFV);
00927 activeVal[index1][index2] = val;
00928 }
00929
00930 template<typename T>
00931 AcqFieldScalarArray2D<T>::~AcqFieldScalarArray2D() {
00932
00933 }
00934
00935
00936
00937 template<typename T>
00938 class AcqFieldStructArray2D: public AcqFieldArray2D<T> {
00939 public:
00946 AcqFieldStructArray2D(const std::string& fieldName, bool multiplexed,
00947 DataStore* pDataStore, bool persistent, int32_t size1, int32_t size2,
00948 DataIntegrity bufferType = SingleBuffered);
00949
00953 ~AcqFieldStructArray2D();
00954
00962 const T* getCell(uint32_t index1, uint32_t index2,
00963 MultiplexingContext* context = 0);
00964
00972 void setCell(T* val, uint32_t index1, uint32_t index2,
00973 MultiplexingContext* context);
00974
00975 };
00976
00977 template<typename T>
00978 AcqFieldStructArray2D<T>::AcqFieldStructArray2D(const std::string& fieldName,
00979 bool multiplexed, DataStore* pDataStore, bool persistent, int32_t size1, int32_t size2,
00980 DataIntegrity bufferType) :
00981 AcqFieldArray2D<T> (fieldName, multiplexed, pDataStore, persistent, size1, size2,
00982 bufferType) {
00983
00984 }
00985
00986 template<typename T>
00987 const T* AcqFieldStructArray2D<T>::getCell(uint32_t index1,
00988 uint32_t index2, MultiplexingContext* context) {
00989
00990 if (context == NULL)
00991 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
00992
00993 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
00994 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
00995 this->name_.c_str());
00996
00997 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
00998 : this->multiplexingManager_->getSlot(*context);
00999 FieldValue<T[][1]>* pFV = this->getFieldValue(slot);
01000
01001 uint32_t size1, size2;
01002 pFV->getActiveCurrentSize(size1, size2);
01003 if ( ((index1+1) > size1) || ((index2+1) > size2) ) {
01004 throw FesaException(__FILE__, __LINE__,
01005 FesaErrorFieldCurrentDimensionsOutOfBound.c_str(),
01006 StringUtilities::toString(index1).c_str(),
01007 StringUtilities::toString(index2).c_str(),
01008 this->name_.c_str(),
01009 StringUtilities::toString(size1).c_str(),
01010 StringUtilities::toString(size2).c_str());
01011 }
01012
01013 T(*activeVal)[size2];
01014 activeVal = (T(*)[size2]) pFV->activeBuffer((char*) pFV);
01015 return &(activeVal[index1][index2]);
01016 }
01017
01018 template<typename T>
01019 void AcqFieldStructArray2D<T>::setCell(T* val, uint32_t index1,
01020 uint32_t index2, MultiplexingContext* context) {
01021
01022 if (context == NULL)
01023 throw FesaException(__FILE__, __LINE__, FesaErrorNULLPointerToContext.c_str());
01024
01025 if (this->multiplexingManager_ && context->getType() == MultiplexingContext::NoneCtxt)
01026 throw FesaException(__FILE__, __LINE__, FesaErrorNoneContextforMuxedField.c_str(),
01027 this->name_.c_str());
01028
01029 if (!(context->getAcquisitionAccessMask() & MultiplexingContext::SET_ALLOWED))
01030 throw FesaException(__FILE__, __LINE__, FesaErrorWrongSourceContextAcquisitionField.c_str(),
01031 this->name_.c_str());
01032
01033 this->checkMaxDimensions((index1+1), (index2+1));
01034
01035 uint32_t slot = (this->multiplexingManager_ == NULL) ? 0
01036 : this->multiplexingManager_->requireSlot(*context);
01037 FieldValue<T[][1]>* pFV = this->getFieldValue(slot);
01038
01039 uint32_t size1, size2;
01040 pFV->getPendingCurrentSize(size1, size2);
01041 uint32_t newSize1 = ((index1+1) > size1) ? (index1+1) : size1;
01042 uint32_t newSize2 = ((index2+1) > size2) ? (index2+1) : size2;
01043 pFV->setPendingCurrentSize(newSize1, newSize2);
01044
01045 T(*pendingVal)[newSize2];
01046 pendingVal = (T(*)[newSize2]) pFV->pendingBuffer((char*) pFV);
01047 std::memcpy(&(pendingVal[index1][index2]), val, sizeof(T));
01048 }
01049
01050 template<typename T>
01051 AcqFieldStructArray2D<T>::~AcqFieldStructArray2D() {
01052
01053 }
01054
01055
01056
01057 class AcqFieldString: public FieldString {
01058 public:
01065 AcqFieldString(const std::string& fieldName, bool multiplexed,
01066 DataStore* pDataStore, bool persistent, int32_t size,
01067 DataIntegrity bufferType = SingleBuffered);
01068
01069 ~AcqFieldString();
01070
01076 const char* get(MultiplexingContext* context);
01077
01083 void set(const char* val, MultiplexingContext* context);
01084
01085 };
01086
01087
01088
01089 class AcqFieldStringArray: public FieldStringArray {
01090 public:
01097 AcqFieldStringArray(const std::string& fieldName, bool multiplexed,
01098 DataStore* pDataStore, bool persistent, int32_t size1, int32_t size2,
01099 DataIntegrity bufferType = SingleBuffered);
01103 ~AcqFieldStringArray();
01104
01110 const char** get(uint32_t& size1, MultiplexingContext* context);
01111
01118 const char* getString(uint32_t index, MultiplexingContext* context);
01119
01125 void set(const char** val, uint32_t size1,
01126 MultiplexingContext* context);
01127
01134 void setString(const char* val, uint32_t index,
01135 MultiplexingContext* context);
01136
01137 };
01138
01139
01140
01141 }
01142
01143 #endif // ACQUISITION_FIELD_H_