help should doesn't create detector object (#508)

* help should doesn't create detector object instead passing nullptr to the Proxy
This commit is contained in:
Dhanya Thattil
2022-08-10 12:27:17 +02:00
committed by GitHub
parent 6bf9dbf6d3
commit 07ff28e9e5
2 changed files with 18 additions and 11 deletions

View File

@ -53,16 +53,18 @@ int main(int argc, char *argv[]) {
if (parser.isHelp())
action = slsDetectorDefs::HELP_ACTION;
else {
// Free shared memory should work also without a detector
// if we have an option for verify in the detector constructor
// we could avoid this but clutter the code
if (parser.command() == "free" && action != slsDetectorDefs::HELP_ACTION) {
if (parser.detector_id() != -1)
std::cout << "Cannot free shared memory of sub-detector\n";
else
sls::freeSharedMemory(parser.multi_id());
return 0;
// Free shared memory should work also without a detector
// if we have an option for verify in the detector constructor
// we could avoid this but clutter the code
if (parser.command() == "free") {
if (parser.detector_id() != -1)
std::cout << "Cannot free shared memory of sub-detector\n";
else
sls::freeSharedMemory(parser.multi_id());
return 0;
}
}
// prevent mem size check
@ -71,8 +73,11 @@ int main(int argc, char *argv[]) {
}
try {
sls::Detector det(parser.multi_id());
sls::CmdProxy proxy(&det);
std::unique_ptr<sls::Detector> det{nullptr};
if (action != slsDetectorDefs::HELP_ACTION) {
det = sls::make_unique<sls::Detector>(parser.multi_id());
}
sls::CmdProxy proxy(det.get());
proxy.Call(parser.command(), parser.arguments(), parser.detector_id(),
action, std::cout, parser.receiver_id());
} catch (const sls::RuntimeError &e) {