mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-18 07:47:12 +02:00
deduce parallel call only on function signature and some const&
This commit is contained in:
@ -45,9 +45,11 @@ void multiSlsDetector::setupMultiDetector(bool verify, bool update) {
|
||||
updateUserdetails();
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <typename RT, typename... CT>
|
||||
std::vector<RT> multiSlsDetector::serialCall(RT (slsDetector::*somefunc)(CT...),
|
||||
CT... Args) {
|
||||
typename NonDeduced<CT>::type... Args) {
|
||||
std::vector<RT> result;
|
||||
result.reserve(detectors.size());
|
||||
for (auto &d : detectors)
|
||||
@ -57,7 +59,7 @@ std::vector<RT> multiSlsDetector::serialCall(RT (slsDetector::*somefunc)(CT...),
|
||||
|
||||
template <typename RT, typename... CT>
|
||||
std::vector<RT>
|
||||
multiSlsDetector::parallelCall(RT (slsDetector::*somefunc)(CT...), CT... Args) {
|
||||
multiSlsDetector::parallelCall(RT (slsDetector::*somefunc)(CT...), typename NonDeduced<CT>::type... Args) {
|
||||
std::vector<std::future<RT>> futures;
|
||||
for (auto &d : detectors)
|
||||
futures.push_back(
|
||||
|
@ -141,8 +141,10 @@ class multiSlsDetector : public virtual slsDetectorDefs,
|
||||
* Loop through the detectors serially
|
||||
* and return a vector of results
|
||||
*/
|
||||
template <class CT>
|
||||
struct NonDeduced { using type = CT; };
|
||||
template <typename RT, typename... CT>
|
||||
std::vector<RT> serialCall(RT (slsDetector::*somefunc)(CT...), CT... Args);
|
||||
std::vector<RT> serialCall(RT (slsDetector::*somefunc)(CT...), typename NonDeduced<CT>::type... Args);
|
||||
|
||||
/**
|
||||
* Loop through the detectors in parallel threads
|
||||
@ -150,7 +152,7 @@ class multiSlsDetector : public virtual slsDetectorDefs,
|
||||
*/
|
||||
template <typename RT, typename... CT>
|
||||
std::vector<RT> parallelCall(RT (slsDetector::*somefunc)(CT...),
|
||||
CT... Args);
|
||||
typename NonDeduced<CT>::type... Args);
|
||||
|
||||
/**
|
||||
* If specific position, then provide result with that detector at position
|
||||
|
@ -1511,7 +1511,7 @@ std::string slsDetector::getSettingsFile() {
|
||||
}
|
||||
|
||||
|
||||
int slsDetector::writeSettingsFile(std::string fname) {
|
||||
int slsDetector::writeSettingsFile(const std::string& fname) {
|
||||
return writeSettingsFile(fname, detectorModules[0]);
|
||||
}
|
||||
|
||||
@ -3066,7 +3066,7 @@ std::string slsDetector::setClientStreamingPort(std::string port) {
|
||||
}
|
||||
|
||||
|
||||
std::string slsDetector::setReceiverStreamingPort(std::string port) {
|
||||
std::string slsDetector::setReceiverStreamingPort(const std::string& port) {
|
||||
// copy now else it is lost if rx_hostname not set yet
|
||||
thisDetector->receiver_zmqport = stoi(port);
|
||||
|
||||
@ -3094,7 +3094,7 @@ std::string slsDetector::setReceiverStreamingPort(std::string port) {
|
||||
}
|
||||
|
||||
|
||||
std::string slsDetector::setClientStreamingIP(std::string sourceIP) {
|
||||
std::string slsDetector::setClientStreamingIP(const std::string& sourceIP) {
|
||||
struct addrinfo *result;
|
||||
// on failure to convert to a valid ip
|
||||
if (dataSocket->ConvertHostnameToInternetAddress(sourceIP.c_str(), &result)) {
|
||||
@ -3167,7 +3167,7 @@ std::string slsDetector::setReceiverStreamingIP(std::string sourceIP) {
|
||||
}
|
||||
|
||||
|
||||
std::string slsDetector::setAdditionalJsonHeader(std::string jsonheader) {
|
||||
std::string slsDetector::setAdditionalJsonHeader(const std::string& jsonheader) {
|
||||
int fnum = F_ADDITIONAL_JSON_HEADER;
|
||||
int ret = FAIL;
|
||||
char args[MAX_STR_LENGTH] = {0};
|
||||
@ -3331,7 +3331,7 @@ int slsDetector::digitalTest( digitalTestMode mode, int ival) {
|
||||
}
|
||||
|
||||
|
||||
int slsDetector::loadImageToDetector(imageType index,std::string const fname) {
|
||||
int slsDetector::loadImageToDetector(imageType index, const std::string& fname) {
|
||||
int ret = FAIL;
|
||||
int nChan = getTotalNumberOfChannels();
|
||||
short int args[nChan];
|
||||
@ -3374,7 +3374,7 @@ int slsDetector::sendImageToDetector(imageType index,short int imageVals[]) {
|
||||
}
|
||||
|
||||
|
||||
int slsDetector::writeCounterBlockFile(std::string const fname,int startACQ) {
|
||||
int slsDetector::writeCounterBlockFile(const std::string& fname,int startACQ) {
|
||||
int ret = FAIL;
|
||||
int nChan = getTotalNumberOfChannels();
|
||||
short int retvals[nChan];
|
||||
@ -3961,7 +3961,7 @@ int slsDetector::setStoragecellStart(int pos) {
|
||||
}
|
||||
|
||||
|
||||
int slsDetector::programFPGA(std::string fname) {
|
||||
int slsDetector::programFPGA(const std::string& fname) {
|
||||
// only jungfrau implemented (client processing, so check now)
|
||||
if (thisDetector->myDetectorType != JUNGFRAU && thisDetector->myDetectorType != CHIPTESTBOARD) {
|
||||
FILE_LOG(logERROR) << "Not implemented for this detector";
|
||||
@ -4524,7 +4524,7 @@ std::string slsDetector::checkReceiverOnline() {
|
||||
}
|
||||
|
||||
|
||||
int slsDetector::setReceiverTCPSocket(std::string const name, int const receiver_port) {
|
||||
int slsDetector::setReceiverTCPSocket(const std::string& name, int const receiver_port) {
|
||||
char thisName[MAX_STR_LENGTH] = {0};
|
||||
int thisRP = 0;
|
||||
int ret = OK;
|
||||
@ -4652,7 +4652,7 @@ int slsDetector::exitReceiver() {
|
||||
}
|
||||
|
||||
|
||||
int slsDetector::execReceiverCommand(std::string cmd) {
|
||||
int slsDetector::execReceiverCommand(const std::string& cmd) {
|
||||
int fnum = F_EXEC_RECEIVER_COMMAND;
|
||||
int ret = FAIL;
|
||||
char arg[MAX_STR_LENGTH] = {0};
|
||||
@ -4859,13 +4859,13 @@ std::string slsDetector::getFilePath() {
|
||||
}
|
||||
|
||||
|
||||
std::string slsDetector::setFilePath(std::string s) {
|
||||
if (!s.empty()) {
|
||||
std::string slsDetector::setFilePath(const std::string& path) {
|
||||
if (!path.empty()) {
|
||||
int fnum = F_SET_RECEIVER_FILE_PATH;
|
||||
int ret = FAIL;
|
||||
char args[MAX_STR_LENGTH] = {0};
|
||||
char retvals[MAX_STR_LENGTH] = {0};
|
||||
strcpy(args, s.c_str());
|
||||
strcpy(args, path.c_str());
|
||||
FILE_LOG(logDEBUG1) << "Sending file path to receiver: " << args;
|
||||
|
||||
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) {
|
||||
@ -4874,7 +4874,7 @@ std::string slsDetector::setFilePath(std::string s) {
|
||||
|
||||
// handle ret
|
||||
if (ret == FAIL) {
|
||||
if (!s.empty()) {
|
||||
if (!path.empty()) {
|
||||
FILE_LOG(logERROR) << "file path does not exist";
|
||||
setErrorMask((getErrorMask())|(FILE_PATH_DOES_NOT_EXIST));
|
||||
} else
|
||||
@ -4896,13 +4896,13 @@ std::string slsDetector::getFileName() {
|
||||
}
|
||||
|
||||
|
||||
std::string slsDetector::setFileName(std::string s) {
|
||||
if (!s.empty()) {
|
||||
std::string slsDetector::setFileName(const std::string& fname) {
|
||||
if (!fname.empty()) {
|
||||
int fnum = F_SET_RECEIVER_FILE_NAME;
|
||||
int ret = FAIL;
|
||||
char args[MAX_STR_LENGTH] = {0};
|
||||
char retvals[MAX_STR_LENGTH] = {0};
|
||||
strcpy(args, s.c_str());
|
||||
char args[MAX_STR_LENGTH] = {""};
|
||||
char retvals[MAX_STR_LENGTH] = {""};
|
||||
strcpy(args, fname.c_str());
|
||||
FILE_LOG(logDEBUG1) << "Sending file name to receiver: " << args;
|
||||
|
||||
if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) {
|
||||
@ -5462,7 +5462,7 @@ int slsDetector::restreamStopFromReceiver() {
|
||||
|
||||
|
||||
|
||||
int slsDetector::setCTBPattern(std::string fname) {
|
||||
int slsDetector::setCTBPattern(const std::string& fname) {
|
||||
uint64_t word;
|
||||
int addr = 0;
|
||||
FILE *fd = fopen(fname.c_str(),"r");
|
||||
@ -5644,7 +5644,7 @@ slsDetectorDefs::sls_detector_module* slsDetector::interpolateTrim(
|
||||
}
|
||||
|
||||
|
||||
slsDetectorDefs::sls_detector_module* slsDetector::readSettingsFile(std::string fname,
|
||||
slsDetectorDefs::sls_detector_module* slsDetector::readSettingsFile(const std::string& fname,
|
||||
sls_detector_module* myMod, int tb) {
|
||||
|
||||
FILE_LOG(logDEBUG1) << "Read settings file " << fname;
|
||||
@ -5789,7 +5789,7 @@ slsDetectorDefs::sls_detector_module* slsDetector::readSettingsFile(std::string
|
||||
}
|
||||
|
||||
|
||||
int slsDetector::writeSettingsFile(std::string fname, sls_detector_module mod) {
|
||||
int slsDetector::writeSettingsFile(const std::string& fname, sls_detector_module mod) {
|
||||
|
||||
FILE_LOG(logDEBUG1) << "Write settings file " << fname;
|
||||
|
||||
|
@ -608,7 +608,7 @@ public:
|
||||
* @returns OK or FAIL if the file could not be written
|
||||
* \sa ::sls_detector_module sharedSlsDetector mythenDetector::writeSettingsFile(string, int)
|
||||
*/
|
||||
int writeSettingsFile(std::string fname);
|
||||
int writeSettingsFile(const std::string& fname);
|
||||
|
||||
/**
|
||||
* Get detector settings
|
||||
@ -1004,14 +1004,14 @@ public:
|
||||
* calculate individual ports)
|
||||
* @returns the receiver zmq port
|
||||
*/
|
||||
std::string setReceiverStreamingPort(std::string port);
|
||||
std::string setReceiverStreamingPort(const std::string& port);
|
||||
|
||||
/**
|
||||
* Sets the client zmq ip\sa sharedSlsDetector
|
||||
* @param sourceIP client zmq ip
|
||||
* @returns the client zmq ip, returns "none" if default setting and no custom ip set
|
||||
*/
|
||||
std::string setClientStreamingIP(std::string sourceIP);
|
||||
std::string setClientStreamingIP(const std::string& sourceIP);
|
||||
|
||||
/**
|
||||
* Sets the receiver zmq ip\sa sharedSlsDetector
|
||||
@ -1034,7 +1034,7 @@ public:
|
||||
* @param fname file name from which to load image
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int loadImageToDetector(imageType index,std::string const fname);
|
||||
int loadImageToDetector(imageType index, const std::string& fname);
|
||||
|
||||
/**
|
||||
* Called from loadImageToDetector to send the image to detector
|
||||
@ -1050,7 +1050,7 @@ public:
|
||||
* @param startACQ is 1 to start acquisition after reading counter
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int writeCounterBlockFile(std::string const fname,int startACQ=0);
|
||||
int writeCounterBlockFile(const std::string& fname,int startACQ=0);
|
||||
|
||||
/**
|
||||
* Gets counter memory block in detector (Gotthard)
|
||||
@ -1233,7 +1233,7 @@ public:
|
||||
* @param fname file name
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int programFPGA(std::string fname);
|
||||
int programFPGA(const std::string& fname);
|
||||
|
||||
/**
|
||||
* Resets FPGA (Jungfrau)
|
||||
@ -1323,7 +1323,7 @@ public:
|
||||
* @returns OK is connection succeded, FAIL otherwise
|
||||
* \sa sharedSlsDetector
|
||||
*/
|
||||
int setReceiverTCPSocket(std::string const name="", int const receiver_port=-1);
|
||||
int setReceiverTCPSocket(const std::string& name="", int const receiver_port=-1);
|
||||
|
||||
/**
|
||||
* Locks/Unlocks the connection to the receiver
|
||||
@ -1350,7 +1350,7 @@ public:
|
||||
* @param cmd command to be executed
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int execReceiverCommand(std::string cmd);
|
||||
int execReceiverCommand(const std::string& cmd);
|
||||
|
||||
/**
|
||||
updates the shared memory receiving the data from the detector (without asking and closing the connection
|
||||
@ -1394,7 +1394,7 @@ public:
|
||||
* @param s file directory
|
||||
* @returns file dir
|
||||
*/
|
||||
std::string setFilePath(std::string s);
|
||||
std::string setFilePath(const std::string& path);
|
||||
|
||||
/**
|
||||
* Returns file name prefix
|
||||
@ -1407,7 +1407,7 @@ public:
|
||||
* @param s file name prefix
|
||||
* @returns file name prefix
|
||||
*/
|
||||
std::string setFileName(std::string s);
|
||||
std::string setFileName(const std::string& fname);
|
||||
|
||||
/**
|
||||
* Sets the max frames per file in receiver
|
||||
@ -1574,7 +1574,7 @@ public:
|
||||
* @param fname pattern file to open
|
||||
* @returns OK/FAIL
|
||||
*/
|
||||
int setCTBPattern(std::string fname);
|
||||
int setCTBPattern(const std::string& fname);
|
||||
|
||||
/**
|
||||
* Writes a pattern word to the CTB
|
||||
@ -1723,7 +1723,7 @@ private:
|
||||
* @param jsonheader additional json header
|
||||
* @returns additional json header, returns "none" if default setting and no custom ip set
|
||||
*/
|
||||
std::string setAdditionalJsonHeader(std::string jsonheader);
|
||||
std::string setAdditionalJsonHeader(const std::string& jsonheader);
|
||||
|
||||
/**
|
||||
* Sets the receiver UDP socket buffer size
|
||||
@ -1782,7 +1782,7 @@ private:
|
||||
* @returns the pointer to myMod or NULL if reading the file failed
|
||||
*/
|
||||
|
||||
sls_detector_module* readSettingsFile(std::string fname, sls_detector_module* myMod=nullptr, int tb=1);
|
||||
sls_detector_module* readSettingsFile(const std::string& fname, sls_detector_module* myMod=nullptr, int tb=1);
|
||||
|
||||
/**
|
||||
* writes a trim/settings file
|
||||
@ -1790,7 +1790,7 @@ private:
|
||||
* @param mod module structure which has to be written to file
|
||||
* @returns OK or FAIL if the file could not be written
|
||||
*/
|
||||
int writeSettingsFile(std::string fname, sls_detector_module mod);
|
||||
int writeSettingsFile(const std::string& fname, sls_detector_module mod);
|
||||
|
||||
|
||||
/** slsDetector Id or position in the detectors list */
|
||||
|
Reference in New Issue
Block a user