Skip to content

Commit 90bce56

Browse files
chiarazampollishahor02
authored andcommitted
De-templating some functions
so that detectors can override them if deriving from DCSProcessor. clang
1 parent 5b06915 commit 90bce56

3 files changed

Lines changed: 107 additions & 141 deletions

File tree

Detectors/DCS/include/DetectorsDCS/DCSProcessor.h

Lines changed: 45 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,20 @@ class DCSProcessor
8484
template <typename T>
8585
void checkFlagsAndFill(const std::pair<DPID, DPVAL>& dpcom, int64_t& latestTimeStamp, std::unordered_map<DPID, T>& destmap);
8686

87-
template <typename T>
88-
void process(const DPID& alias, std::deque<T>& aliasDeque);
87+
virtual void processCharDP(const DPID& alias);
88+
virtual void processIntDP(const DPID& alias);
89+
virtual void processDoubleDP(const DPID& alias);
90+
virtual void processUIntDP(const DPID& alias);
91+
virtual void processBoolDP(const DPID& alias);
92+
virtual void processStringDP(const DPID& alias);
93+
virtual void processTimeDP(const DPID& alias);
94+
virtual void processBinaryDP(const DPID& alias);
95+
96+
virtual uint64_t processFlag(uint64_t flag, const char* alias);
8997

9098
template <typename T>
9199
void doSimpleMovingAverage(int nelements, std::deque<T>& vect, float& avg, bool& isSMA);
92100

93-
virtual void processChars();
94-
virtual void processInts();
95-
virtual void processDoubles();
96-
virtual void processUInts();
97-
virtual void processBools();
98-
virtual void processStrings();
99-
virtual void processTimes();
100-
virtual void processBinaries();
101-
virtual uint64_t processFlag(uint64_t flag, const char* alias);
102-
103101
DQChars& getVectorForAliasChar(const DPID& id) { return mDpscharsmap[id]; }
104102
DQInts& getVectorForAliasInt(const DPID& id) { return mDpsintsmap[id]; }
105103
DQDoubles& getVectorForAliasDouble(const DPID& id) { return mDpsdoublesmap[id]; }
@@ -129,6 +127,9 @@ class DCSProcessor
129127
template <typename T>
130128
void prepareCCDBobject(T& obj, CcdbObjectInfo& info, const std::string& path, TFType tf, const std::map<std::string, std::string>& md);
131129

130+
void setName(std::string name) { mName = name; }
131+
const std::string getName() const { return mName; }
132+
132133
private:
133134
bool mFullMapSent = false; // set to true as soon as a full map was sent. No delta can be received if there was never a full map sent
134135
int64_t mNCyclesNoFullMap = 0; // number of times the delta was sent withoug a full map
@@ -163,6 +164,7 @@ class DCSProcessor
163164
std::unordered_map<std::string, float> mccdbSimpleMovingAverage; // unordered map in which to store the CCDB entry for the DPs for which we calculated the simple moving average
164165
CcdbObjectInfo mccdbSimpleMovingAverageInfo; // info to store the output of the calibration for the DPs for which we calculated the simple moving average
165166
TFType mTF = 0; // TF index for processing, used to store CCDB object
167+
std::string mName = ""; // to be used to determine CCDB path
166168

167169
ClassDefNV(DCSProcessor, 0);
168170
};
@@ -186,28 +188,39 @@ int DCSProcessor::processArrayType(const std::vector<DPID>& array, DeliveryType
186188
// processing the array of type T
187189

188190
int found = 0;
189-
auto s = array.size();
190-
if (s > 0) { // we have at least one DP of type T
191-
//#ifdef WITH_OPENMP
192-
//omp_set_num_threads(mNThreads);
193-
//#pragma omp parallel for schedule(dynamic)
194-
//#endif
195-
for (size_t i = 0; i != s; ++i) {
196-
auto it = findAndCheckAlias(array[i], type, map);
197-
if (it == map.end()) {
198-
if (!mIsDelta) {
199-
LOG(ERROR) << "Element " << array[i] << " not found " << std::endl;
200-
} else {
201-
latestTimeStamp[i] = -latestTimeStamp[i];
202-
}
203-
continue;
191+
//#ifdef WITH_OPENMP
192+
//omp_set_num_threads(mNThreads);
193+
//#pragma omp parallel for schedule(dynamic)
194+
//#endif
195+
for (size_t i = 0; i != array.size(); ++i) {
196+
auto it = findAndCheckAlias(array[i], type, map);
197+
if (it == map.end()) {
198+
if (!mIsDelta) {
199+
LOG(ERROR) << "Element " << array[i] << " not found " << std::endl;
204200
}
205-
found++;
206-
std::pair<DPID, DPVAL> pairIt = *it;
207-
checkFlagsAndFill(pairIt, latestTimeStamp[i], destmap);
208-
process(array[i], destmap[array[i]]);
209-
// todo: better to move the "found++" after the process, in case it fails?
201+
continue;
202+
}
203+
found++;
204+
std::pair<DPID, DPVAL> pairIt = *it;
205+
checkFlagsAndFill(pairIt, latestTimeStamp[i], destmap);
206+
if (type == RAW_CHAR) {
207+
processCharDP(array[i]);
208+
} else if (type == RAW_INT) {
209+
processIntDP(array[i]);
210+
} else if (type == RAW_DOUBLE) {
211+
processDoubleDP(array[i]);
212+
} else if (type == RAW_UINT) {
213+
processUIntDP(array[i]);
214+
} else if (type == RAW_BOOL) {
215+
processBoolDP(array[i]);
216+
} else if (type == RAW_STRING) {
217+
processStringDP(array[i]);
218+
} else if (type == RAW_TIME) {
219+
processTimeDP(array[i]);
220+
} else if (type == RAW_BINARY) {
221+
processBinaryDP(array[i]);
210222
}
223+
// todo: better to move the "found++" after the process, in case it fails?
211224
}
212225
return found;
213226
}
@@ -247,20 +260,6 @@ void DCSProcessor::checkFlagsAndFill(const std::pair<DPID, DPVAL>& dpcom, int64_
247260

248261
//______________________________________________________________________
249262

250-
template <typename T>
251-
void DCSProcessor::process(const DPID& alias, std::deque<T>& aliasdeque)
252-
{
253-
// processing the single alias
254-
return;
255-
}
256-
257-
//______________________________________________________________________
258-
259-
template <>
260-
void DCSProcessor::process(const DPID& alias, std::deque<int>& aliasdeque);
261-
262-
//______________________________________________________________________
263-
264263
template <typename T>
265264
void DCSProcessor::doSimpleMovingAverage(int nelements, std::deque<T>& vect, float& avg, bool& isSMA)
266265
{

0 commit comments

Comments
 (0)