mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-28 17:10:03 +02:00
added const methods for detector
This commit is contained in:
parent
e8556abbe7
commit
1fefc001f9
@ -2410,79 +2410,117 @@ void Module::preSendArgsCheck(const void *args, size_t args_size, void *retval,
|
|||||||
static_assert(!std::is_same<ARG, std::nullptr_t>::value, \
|
static_assert(!std::is_same<ARG, std::nullptr_t>::value, \
|
||||||
"nullptr_t type is incompatible with templated " DST);
|
"nullptr_t type is incompatible with templated " DST);
|
||||||
|
|
||||||
void Module::sendToDetector(int fnum, const void *args, size_t args_size,
|
|
||||||
void *retval, size_t retval_size) {
|
|
||||||
static_cast<const Module &>(*this).sendToDetector(fnum, args, args_size,
|
|
||||||
retval, retval_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Module::sendToDetector(int fnum, const void *args, size_t args_size,
|
void Module::sendToDetector(int fnum, const void *args, size_t args_size,
|
||||||
void *retval, size_t retval_size) const {
|
void *retval, size_t retval_size) const {
|
||||||
|
// This is the only function that actually sends data to the detector
|
||||||
|
// the other versions use templates to deduce sizes and create
|
||||||
|
// the return type
|
||||||
preSendArgsCheck(args, args_size, retval, retval_size);
|
preSendArgsCheck(args, args_size, retval, retval_size);
|
||||||
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
||||||
client.sendCommandThenRead(fnum, args, args_size, retval, retval_size);
|
client.sendCommandThenRead(fnum, args, args_size, retval, retval_size);
|
||||||
client.close();
|
client.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Module::sendToDetector(int fnum, const void *args, size_t args_size,
|
||||||
|
void *retval, size_t retval_size) {
|
||||||
|
static_cast<const Module &>(*this).sendToDetector(fnum, args, args_size,
|
||||||
|
retval, retval_size);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename Arg, typename Ret>
|
template <typename Arg, typename Ret>
|
||||||
void Module::sendToDetector(int fnum, const Arg &args, Ret &retval) {
|
void Module::sendToDetector(int fnum, const Arg &args, Ret &retval) const {
|
||||||
LOG(logDEBUG1) << "Sending: ["
|
LOG(logDEBUG1) << "Sending: ["
|
||||||
<< getFunctionNameFromEnum(static_cast<detFuncs>(fnum))
|
<< getFunctionNameFromEnum(static_cast<detFuncs>(fnum))
|
||||||
<< ", nullptr, 0, " << typeid(Ret).name() << ", "
|
<< ", nullptr, 0, " << typeid(Ret).name() << ", "
|
||||||
<< sizeof(Ret) << "]";
|
<< sizeof(Ret) << "]";
|
||||||
|
STATIC_ASSERT_ARG(Arg, "sendToDetector")
|
||||||
|
STATIC_ASSERT_ARG(Ret, "sendToDetector")
|
||||||
sendToDetector(fnum, &args, sizeof(args), &retval, sizeof(retval));
|
sendToDetector(fnum, &args, sizeof(args), &retval, sizeof(retval));
|
||||||
LOG(logDEBUG1) << "Got back: " << ToString(retval);
|
LOG(logDEBUG1) << "Got back: " << ToString(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename Arg, typename Ret>
|
||||||
|
void Module::sendToDetector(int fnum, const Arg &args, Ret &retval) {
|
||||||
|
static_cast<const Module &>(*this).sendToDetector(fnum, args, retval);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename Arg>
|
template <typename Arg>
|
||||||
void Module::sendToDetector(int fnum, const Arg &args, std::nullptr_t) {
|
void Module::sendToDetector(int fnum, const Arg &args, std::nullptr_t) const {
|
||||||
LOG(logDEBUG1) << "Sending: ["
|
LOG(logDEBUG1) << "Sending: ["
|
||||||
<< getFunctionNameFromEnum(static_cast<detFuncs>(fnum))
|
<< getFunctionNameFromEnum(static_cast<detFuncs>(fnum))
|
||||||
<< ", " << typeid(Arg).name() << ", " << sizeof(Arg)
|
<< ", " << typeid(Arg).name() << ", " << sizeof(Arg)
|
||||||
<< ", nullptr, 0 ]";
|
<< ", nullptr, 0 ]";
|
||||||
|
STATIC_ASSERT_ARG(Arg, "sendToDetector")
|
||||||
sendToDetector(fnum, &args, sizeof(args), nullptr, 0);
|
sendToDetector(fnum, &args, sizeof(args), nullptr, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename Arg>
|
||||||
|
void Module::sendToDetector(int fnum, const Arg &args, std::nullptr_t) {
|
||||||
|
static_cast<const Module &>(*this).sendToDetector(fnum, args, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename Ret>
|
template <typename Ret>
|
||||||
void Module::sendToDetector(int fnum, std::nullptr_t, Ret &retval) {
|
void Module::sendToDetector(int fnum, std::nullptr_t, Ret &retval) const {
|
||||||
LOG(logDEBUG1) << "Sending: ["
|
LOG(logDEBUG1) << "Sending: ["
|
||||||
<< getFunctionNameFromEnum(static_cast<detFuncs>(fnum))
|
<< getFunctionNameFromEnum(static_cast<detFuncs>(fnum))
|
||||||
<< ", nullptr, 0, " << typeid(Ret).name() << ", "
|
<< ", nullptr, 0, " << typeid(Ret).name() << ", "
|
||||||
<< sizeof(Ret) << "]";
|
<< sizeof(Ret) << "]";
|
||||||
|
STATIC_ASSERT_ARG(Ret, "sendToDetector")
|
||||||
sendToDetector(fnum, nullptr, 0, &retval, sizeof(retval));
|
sendToDetector(fnum, nullptr, 0, &retval, sizeof(retval));
|
||||||
LOG(logDEBUG1) << "Got back: " << ToString(retval);
|
LOG(logDEBUG1) << "Got back: " << ToString(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::sendToDetector(int fnum) {
|
template <typename Ret>
|
||||||
|
void Module::sendToDetector(int fnum, std::nullptr_t, Ret &retval) {
|
||||||
|
static_cast<const Module &>(*this).sendToDetector(fnum, nullptr, retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Module::sendToDetector(int fnum) const {
|
||||||
LOG(logDEBUG1) << "Sending: ["
|
LOG(logDEBUG1) << "Sending: ["
|
||||||
<< getFunctionNameFromEnum(static_cast<detFuncs>(fnum))
|
<< getFunctionNameFromEnum(static_cast<detFuncs>(fnum))
|
||||||
<< "]";
|
<< "]";
|
||||||
sendToDetector(fnum, nullptr, 0, nullptr, 0);
|
sendToDetector(fnum, nullptr, 0, nullptr, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Ret> Ret Module::sendToDetector(int fnum) {
|
void Module::sendToDetector(int fnum) {
|
||||||
|
static_cast<const Module &>(*this).sendToDetector(fnum);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Ret> Ret Module::sendToDetector(int fnum) const {
|
||||||
LOG(logDEBUG1) << "Sending: ["
|
LOG(logDEBUG1) << "Sending: ["
|
||||||
<< getFunctionNameFromEnum(static_cast<detFuncs>(fnum))
|
<< getFunctionNameFromEnum(static_cast<detFuncs>(fnum))
|
||||||
<< ", nullptr, 0, " << typeid(Ret).name() << ", "
|
<< ", nullptr, 0, " << typeid(Ret).name() << ", "
|
||||||
<< sizeof(Ret) << "]";
|
<< sizeof(Ret) << "]";
|
||||||
|
STATIC_ASSERT_ARG(Ret, "sendToDetector")
|
||||||
Ret retval{};
|
Ret retval{};
|
||||||
sendToDetector(fnum, nullptr, 0, &retval, sizeof(retval));
|
sendToDetector(fnum, nullptr, 0, &retval, sizeof(retval));
|
||||||
LOG(logDEBUG1) << "Got back: " << ToString(retval);
|
LOG(logDEBUG1) << "Got back: " << ToString(retval);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename Ret> Ret Module::sendToDetector(int fnum) {
|
||||||
|
return static_cast<const Module &>(*this).sendToDetector<Ret>(fnum);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename Ret, typename Arg>
|
template <typename Ret, typename Arg>
|
||||||
Ret Module::sendToDetector(int fnum, const Arg &args) {
|
Ret Module::sendToDetector(int fnum, const Arg &args) const {
|
||||||
LOG(logDEBUG1) << "Sending: ["
|
LOG(logDEBUG1) << "Sending: ["
|
||||||
<< getFunctionNameFromEnum(static_cast<detFuncs>(fnum))
|
<< getFunctionNameFromEnum(static_cast<detFuncs>(fnum))
|
||||||
<< ", " << args << ", " << sizeof(args) << ", "
|
<< ", " << args << ", " << sizeof(args) << ", "
|
||||||
<< typeid(Ret).name() << ", " << sizeof(Ret) << "]";
|
<< typeid(Ret).name() << ", " << sizeof(Ret) << "]";
|
||||||
|
STATIC_ASSERT_ARG(Arg, "sendToDetector")
|
||||||
|
STATIC_ASSERT_ARG(Ret, "sendToDetector")
|
||||||
Ret retval{};
|
Ret retval{};
|
||||||
sendToDetector(fnum, &args, sizeof(args), &retval, sizeof(retval));
|
sendToDetector(fnum, &args, sizeof(args), &retval, sizeof(retval));
|
||||||
LOG(logDEBUG1) << "Got back: " << ToString(retval);
|
LOG(logDEBUG1) << "Got back: " << ToString(retval);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename Ret, typename Arg>
|
||||||
|
Ret Module::sendToDetector(int fnum, const Arg &args) {
|
||||||
|
return static_cast<const Module &>(*this).sendToDetector<Ret>(fnum, args);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------- sendToDetectorStop
|
//---------------------------------------------------------- sendToDetectorStop
|
||||||
|
|
||||||
void Module::sendToDetectorStop(int fnum, const void *args, size_t args_size,
|
void Module::sendToDetectorStop(int fnum, const void *args, size_t args_size,
|
||||||
@ -2508,6 +2546,8 @@ void Module::sendToDetectorStop(int fnum, const Arg &args, Ret &retval) const {
|
|||||||
<< getFunctionNameFromEnum(static_cast<detFuncs>(fnum))
|
<< getFunctionNameFromEnum(static_cast<detFuncs>(fnum))
|
||||||
<< ", " << args << ", " << sizeof(args) << ", "
|
<< ", " << args << ", " << sizeof(args) << ", "
|
||||||
<< typeid(Ret).name() << ", " << sizeof(Ret) << "]";
|
<< typeid(Ret).name() << ", " << sizeof(Ret) << "]";
|
||||||
|
STATIC_ASSERT_ARG(Arg, "sendToDetectorStop")
|
||||||
|
STATIC_ASSERT_ARG(Ret, "sendToDetectorStop")
|
||||||
sendToDetectorStop(fnum, &args, sizeof(args), &retval, sizeof(retval));
|
sendToDetectorStop(fnum, &args, sizeof(args), &retval, sizeof(retval));
|
||||||
LOG(logDEBUG1) << "Got back: " << ToString(retval);
|
LOG(logDEBUG1) << "Got back: " << ToString(retval);
|
||||||
}
|
}
|
||||||
@ -2524,6 +2564,7 @@ void Module::sendToDetectorStop(int fnum, const Arg &args,
|
|||||||
<< getFunctionNameFromEnum(static_cast<detFuncs>(fnum))
|
<< getFunctionNameFromEnum(static_cast<detFuncs>(fnum))
|
||||||
<< ", " << typeid(Arg).name() << ", " << sizeof(Arg)
|
<< ", " << typeid(Arg).name() << ", " << sizeof(Arg)
|
||||||
<< ", nullptr, 0 ]";
|
<< ", nullptr, 0 ]";
|
||||||
|
STATIC_ASSERT_ARG(Arg, "sendToDetectorStop")
|
||||||
sendToDetectorStop(fnum, &args, sizeof(args), nullptr, 0);
|
sendToDetectorStop(fnum, &args, sizeof(args), nullptr, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2538,13 +2579,15 @@ void Module::sendToDetectorStop(int fnum, std::nullptr_t, Ret &retval) const {
|
|||||||
<< getFunctionNameFromEnum(static_cast<detFuncs>(fnum))
|
<< getFunctionNameFromEnum(static_cast<detFuncs>(fnum))
|
||||||
<< ", nullptr, 0, " << typeid(Ret).name() << ", "
|
<< ", nullptr, 0, " << typeid(Ret).name() << ", "
|
||||||
<< sizeof(Ret) << "]";
|
<< sizeof(Ret) << "]";
|
||||||
|
STATIC_ASSERT_ARG(Ret, "sendToDetectorStop")
|
||||||
sendToDetectorStop(fnum, nullptr, 0, &retval, sizeof(retval));
|
sendToDetectorStop(fnum, nullptr, 0, &retval, sizeof(retval));
|
||||||
LOG(logDEBUG1) << "Got back: " << retval;
|
LOG(logDEBUG1) << "Got back: " << retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Ret>
|
template <typename Ret>
|
||||||
void Module::sendToDetectorStop(int fnum, std::nullptr_t, Ret &retval) {
|
void Module::sendToDetectorStop(int fnum, std::nullptr_t, Ret &retval) {
|
||||||
static_cast<const Module &>(*this).sendToDetectorStop(fnum, nullptr, retval);
|
static_cast<const Module &>(*this).sendToDetectorStop(fnum, nullptr,
|
||||||
|
retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::sendToDetectorStop(int fnum) const {
|
void Module::sendToDetectorStop(int fnum) const {
|
||||||
@ -2558,40 +2601,42 @@ void Module::sendToDetectorStop(int fnum) {
|
|||||||
static_cast<const Module &>(*this).sendToDetectorStop(fnum);
|
static_cast<const Module &>(*this).sendToDetectorStop(fnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Ret> Ret Module::sendToDetectorStop(int fnum) {
|
|
||||||
LOG(logDEBUG1) << "Sending to Stop: ["
|
|
||||||
<< getFunctionNameFromEnum(static_cast<detFuncs>(fnum))
|
|
||||||
<< ", nullptr, 0, " << typeid(Ret).name() << ", "
|
|
||||||
<< sizeof(Ret) << "]";
|
|
||||||
Ret retval{};
|
|
||||||
sendToDetectorStop(fnum, nullptr, 0, &retval, sizeof(retval));
|
|
||||||
LOG(logDEBUG1) << "Got back: " << retval;
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Ret> Ret Module::sendToDetectorStop(int fnum) const {
|
template <typename Ret> Ret Module::sendToDetectorStop(int fnum) const {
|
||||||
LOG(logDEBUG1) << "Sending to Stop: ["
|
LOG(logDEBUG1) << "Sending to Stop: ["
|
||||||
<< getFunctionNameFromEnum(static_cast<detFuncs>(fnum))
|
<< getFunctionNameFromEnum(static_cast<detFuncs>(fnum))
|
||||||
<< ", nullptr, 0, " << typeid(Ret).name() << ", "
|
<< ", nullptr, 0, " << typeid(Ret).name() << ", "
|
||||||
<< sizeof(Ret) << "]";
|
<< sizeof(Ret) << "]";
|
||||||
|
STATIC_ASSERT_ARG(Ret, "sendToDetectorStop")
|
||||||
Ret retval{};
|
Ret retval{};
|
||||||
sendToDetectorStop(fnum, nullptr, 0, &retval, sizeof(retval));
|
sendToDetectorStop(fnum, nullptr, 0, &retval, sizeof(retval));
|
||||||
LOG(logDEBUG1) << "Got back: " << retval;
|
LOG(logDEBUG1) << "Got back: " << retval;
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename Ret> Ret Module::sendToDetectorStop(int fnum) {
|
||||||
|
return static_cast<const Module &>(*this).sendToDetectorStop<Ret>(fnum);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename Ret, typename Arg>
|
template <typename Ret, typename Arg>
|
||||||
Ret Module::sendToDetectorStop(int fnum, const Arg &args) {
|
Ret Module::sendToDetectorStop(int fnum, const Arg &args) const {
|
||||||
LOG(logDEBUG1) << "Sending to Stop: ["
|
LOG(logDEBUG1) << "Sending to Stop: ["
|
||||||
<< getFunctionNameFromEnum(static_cast<detFuncs>(fnum))
|
<< getFunctionNameFromEnum(static_cast<detFuncs>(fnum))
|
||||||
<< ", " << args << ", " << sizeof(args) << ", "
|
<< ", " << args << ", " << sizeof(args) << ", "
|
||||||
<< typeid(Ret).name() << ", " << sizeof(Ret) << "]";
|
<< typeid(Ret).name() << ", " << sizeof(Ret) << "]";
|
||||||
|
STATIC_ASSERT_ARG(Arg, "sendToDetectorStop")
|
||||||
|
STATIC_ASSERT_ARG(Ret, "sendToDetectorStop")
|
||||||
Ret retval{};
|
Ret retval{};
|
||||||
sendToDetectorStop(fnum, &args, sizeof(args), &retval, sizeof(retval));
|
sendToDetectorStop(fnum, &args, sizeof(args), &retval, sizeof(retval));
|
||||||
LOG(logDEBUG1) << "Got back: " << ToString(retval);
|
LOG(logDEBUG1) << "Got back: " << ToString(retval);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename Ret, typename Arg>
|
||||||
|
Ret Module::sendToDetectorStop(int fnum, const Arg &args) {
|
||||||
|
return static_cast<const Module &>(*this).sendToDetectorStop<Ret>(fnum,
|
||||||
|
args);
|
||||||
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------- sendToReceiver
|
//-------------------------------------------------------------- sendToReceiver
|
||||||
|
|
||||||
void Module::sendToReceiver(int fnum, const void *args, size_t args_size,
|
void Module::sendToReceiver(int fnum, const void *args, size_t args_size,
|
||||||
|
@ -518,7 +518,8 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
uint64_t getReceiverCurrentFrameIndex() const;
|
uint64_t getReceiverCurrentFrameIndex() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void preSendArgsCheck(const void * args, size_t args_size, void * retval, size_t retval_size) const;
|
void preSendArgsCheck(const void *args, size_t args_size, void *retval,
|
||||||
|
size_t retval_size) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send function parameters to detector (control server)
|
* Send function parameters to detector (control server)
|
||||||
@ -536,17 +537,34 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
|
|
||||||
template <typename Arg, typename Ret>
|
template <typename Arg, typename Ret>
|
||||||
void sendToDetector(int fnum, const Arg &args, Ret &retval);
|
void sendToDetector(int fnum, const Arg &args, Ret &retval);
|
||||||
|
|
||||||
|
template <typename Arg, typename Ret>
|
||||||
|
void sendToDetector(int fnum, const Arg &args, Ret &retval) const;
|
||||||
|
|
||||||
template <typename Arg>
|
template <typename Arg>
|
||||||
void sendToDetector(int fnum, const Arg &args, std::nullptr_t);
|
void sendToDetector(int fnum, const Arg &args, std::nullptr_t);
|
||||||
|
|
||||||
|
template <typename Arg>
|
||||||
|
void sendToDetector(int fnum, const Arg &args, std::nullptr_t) const;
|
||||||
|
|
||||||
template <typename Ret>
|
template <typename Ret>
|
||||||
void sendToDetector(int fnum, std::nullptr_t, Ret &retval);
|
void sendToDetector(int fnum, std::nullptr_t, Ret &retval);
|
||||||
|
|
||||||
|
template <typename Ret>
|
||||||
|
void sendToDetector(int fnum, std::nullptr_t, Ret &retval) const;
|
||||||
|
|
||||||
void sendToDetector(int fnum);
|
void sendToDetector(int fnum);
|
||||||
|
void sendToDetector(int fnum) const;
|
||||||
|
|
||||||
template <typename Ret> Ret sendToDetector(int fnum);
|
template <typename Ret> Ret sendToDetector(int fnum);
|
||||||
|
template <typename Ret> Ret sendToDetector(int fnum) const;
|
||||||
|
|
||||||
template <typename Ret, typename Arg>
|
template <typename Ret, typename Arg>
|
||||||
Ret sendToDetector(int fnum, const Arg &args);
|
Ret sendToDetector(int fnum, const Arg &args);
|
||||||
|
|
||||||
|
template <typename Ret, typename Arg>
|
||||||
|
Ret sendToDetector(int fnum, const Arg &args) const;
|
||||||
|
|
||||||
/** Send function parameters to detector (stop server) */
|
/** Send function parameters to detector (stop server) */
|
||||||
void sendToDetectorStop(int fnum, const void *args, size_t args_size,
|
void sendToDetectorStop(int fnum, const void *args, size_t args_size,
|
||||||
void *retval, size_t retval_size);
|
void *retval, size_t retval_size);
|
||||||
@ -583,6 +601,9 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
template <typename Ret, typename Arg>
|
template <typename Ret, typename Arg>
|
||||||
Ret sendToDetectorStop(int fnum, const Arg &args);
|
Ret sendToDetectorStop(int fnum, const Arg &args);
|
||||||
|
|
||||||
|
template <typename Ret, typename Arg>
|
||||||
|
Ret sendToDetectorStop(int fnum, const Arg &args) const;
|
||||||
|
|
||||||
/** Send function parameters to receiver */
|
/** Send function parameters to receiver */
|
||||||
void sendToReceiver(int fnum, const void *args, size_t args_size,
|
void sendToReceiver(int fnum, const void *args, size_t args_size,
|
||||||
void *retval, size_t retval_size);
|
void *retval, size_t retval_size);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user