generic call for hostname and sgetDetectorsType

This commit is contained in:
Erik Frojdh 2018-05-29 16:59:55 +02:00
parent e3088d822f
commit ceed0eaa9b
2 changed files with 25 additions and 30 deletions

View File

@ -595,47 +595,23 @@ string multiSlsDetector::ssetDetectorsType(string name, int pos)
string multiSlsDetector::getHostname(int pos)
{
string hostnames;
if (pos >= 0) {
if (detectors[pos])
return detectors[pos]->getHostname();
} else {
for (int ip = 0; ip < thisMultiDetector->numberOfDetectors; ++ip) {
if (detectors[ip])
hostnames += detectors[ip]->getHostname() + "+";
}
}
return hostnames;
return concatResultOrPos(&slsDetector::getHostname, pos);
}
slsDetectorDefs::detectorType multiSlsDetector::getDetectorsType(int pos)
{
detectorType s = GENERIC;
#ifdef VERBOSE
cout << "returning type of detector with ID " << pos << endl;
#endif
detectorType dt = GENERIC;
if (pos >= 0) {
if (detectors[pos])
return detectors[pos]->getDetectorsType();
} else if (detectors[0])
return detectors[0]->getDetectorsType();
return s;
return dt;
}
string multiSlsDetector::sgetDetectorsType(int pos)
std::string multiSlsDetector::sgetDetectorsType(int pos)
{
string s;
if (pos >= 0) {
if (detectors[pos])
return detectors[pos]->sgetDetectorsType();
} else {
for (int ip = 0; ip < thisMultiDetector->numberOfDetectors; ++ip) {
if (detectors[ip])
s += detectors[ip]->sgetDetectorsType() + "+";
}
}
return s;
return concatResultOrPos(&slsDetector::sgetDetectorsType, pos);
}
int multiSlsDetector::getDetectorId(int pos)
@ -3279,6 +3255,21 @@ void multiSlsDetector::setErrorMaskFromAllDetectors()
}
}
std::string multiSlsDetector::concatResultOrPos(std::string (slsDetector::*somefunc)(int), int pos)
{
if (pos >= 0) {
if (detectors[pos])
return (detectors[pos]->*somefunc)(pos);
} else {
std::string s;
for (int i = 0; i < thisMultiDetector->numberOfDetectors; ++i) {
if (detectors[i])
s += (detectors[i]->*somefunc)(pos) + "+";
}
return s;
}
}
template <typename T>
T multiSlsDetector::callDetectorMember(T (slsDetector::*somefunc)())
{
@ -5962,6 +5953,7 @@ bool multiSlsDetector::isAcquireReady()
return OK;
}
int multiSlsDetector::checkVersionCompatibility(portType t) {
int multiSlsDetector::checkVersionCompatibility(portType t)
{
return parallelCallDetectorMember(&slsDetector::checkVersionCompatibility, t);
}

View File

@ -1044,6 +1044,9 @@ class multiSlsDetector : public slsDetectorUtils {
void setErrorMaskFromAllDetectors();
std::string concatResultOrPos(std::string (slsDetector::*somefunc)(int), int pos);
template<typename T>
bool allElemetsEqual(const std::vector<T>&);