FieldValue.cpp

Go to the documentation of this file.
00001 // Copyright CERN 2012 - Developed in collaboration with GSI
00002 
00003 #include <fesa-core/DataStore/FieldValue.h>
00004 
00005 
00006 namespace fesa
00007 {
00008 
00009 FieldValue<char[]>::FieldValue(DataIntegrity dataIntegrity, uint32_t size)
00010 {
00011 
00012     phase_ = P1;
00013     toBeSync_ = false;
00014     pendingChanged_ = false;
00015     offset_[0] = sizeof(FieldValue<char[]> );
00016 
00017     if (dataIntegrity == DoubleBuffered)
00018     {
00019         offset_[1] = static_cast<uint32_t>(sizeof(FieldValue<char[]>)) + static_cast<uint32_t>(sizeof(char)) * (size + 1);
00020     }
00021     else
00022     {
00023         offset_[1] = offset_[0];
00024     }
00025 
00026 }
00027 
00028 char* FieldValue<char[]>::pendingBuffer(char* pFV)
00029 {
00030     return (this->phase_ == this->P1) ? pFV + offset_[0] : pFV + offset_[1];
00031 }
00032 
00033 char* FieldValue<char[]>::activeBuffer(char* pFV)
00034 {
00035     return (this->phase_ == this->P1) ? pFV + offset_[1] : pFV + offset_[0];
00036 }
00037 
00038 /************************ END SPECIALIZATION FOR STRING ****************************/
00039 
00040 FieldValue<char *[]>::FieldValue(DataIntegrity dataIntegrity, uint32_t size)
00041 {
00042 
00043     phase_ = P1;
00044     toBeSync_ = false;
00045     pendingChanged_ = false;
00046     currentSize_[0] = size;
00047     currentSize_[1] = size;
00048     offset_[0] = 0;
00049 
00050     if (dataIntegrity == DoubleBuffered)
00051     {
00052         offset_[1] = 1;
00053         isSingleBuffer_ = false;
00054     }
00055     else
00056     {
00057         offset_[1] = 0;
00058         isSingleBuffer_ = true;
00059     }
00060 
00061 }
00062 
00063 uint32_t FieldValue<char *[]>::pendingBuffer()
00064 {
00065 
00066 
00067     if (this->phase_ == this->P1)
00068     {
00069         return offset_[1];
00070     }
00071     else
00072     {
00073         return offset_[0];
00074     }
00075 }
00076 
00077 uint32_t FieldValue<char *[]>::activeBuffer()
00078 {
00079 
00080     if (this->phase_ == this->P1)
00081     {
00082         return offset_[0];
00083     }
00084     else
00085     {
00086         return offset_[1];
00087     }
00088 }
00089 
00090 uint32_t FieldValue<char* []>::getPendingCurrentSize()
00091 {
00092     // In case of single buffer dimension is get from position 0 else it's driven by the phase
00093     if (isSingleBuffer_)
00094         return currentSize_[0];
00095     else
00096         return (this->phase_ == this->P1) ? currentSize_[0] : currentSize_[1];
00097 }
00098 
00099 uint32_t FieldValue<char* []>::getActiveCurrentSize()
00100 {
00101     // In case of single buffer dimension is get from position 0 else it's driven by the phase
00102     if (isSingleBuffer_)
00103         return currentSize_[0];
00104     else
00105         return (this->phase_ == this->P1) ? currentSize_[1] : currentSize_[0];
00106 }
00107 
00108 void FieldValue<char* []>::setPendingCurrentSize(uint32_t currentSize)
00109 {
00110     // In case of single buffer dimension is written in position 0 else it's driven by the phase
00111     if (isSingleBuffer_ || this->phase_ == this->P1)
00112     {
00113         currentSize_[0] = currentSize;
00114     }
00115     else
00116     {
00117         currentSize_[1] = currentSize;
00118     }
00119 }
00120 
00121 void FieldValue<char* []>::setActiveCurrentSize(uint32_t currentSize)
00122 {
00123     // In case of single buffer dimension is written in position 0 else it's driven by the phase
00124     if (isSingleBuffer_ || this->phase_ == this->P2)
00125     {
00126         currentSize_[0] = currentSize;
00127     }
00128     else
00129     {
00130         currentSize_[1] = currentSize;
00131     }
00132 }
00133 
00134 } // fesa

Generated on 18 Jan 2013 for Fesa by  doxygen 1.6.1