/******************************************************************************** * Copyright (C) 2017 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ #include #include #include #include using FairMQDevicePtr = FairMQDevice*; // to be implemented by the user to return a child class of FairMQDevice FairMQDevicePtr getDevice(const FairMQProgOptions& config); // to be implemented by the user to add custom command line options (or just with empty body) void addCustomOptions(boost::program_options::options_description&); int main(int argc, char* argv[]) { using namespace fair::mq; using namespace fair::mq::hooks; try { fair::mq::DeviceRunner runner{argc, argv}; // runner.AddHook([](DeviceRunner& r){ // // for example: // r.fPluginManager->SetSearchPaths({"/lib", "/lib/plugins"}); // r.fPluginManager->LoadPlugin("asdf"); // }); runner.AddHook([](DeviceRunner& r){ boost::program_options::options_description customOptions("Custom options"); addCustomOptions(customOptions); r.fConfig.AddToCmdLineOptions(customOptions); }); // runner.AddHook([](DeviceRunner& r){ // // for example: // r.fRawCmdLineArgs.push_back("--blubb"); // }); runner.AddHook([](DeviceRunner& r){ r.fDevice = std::shared_ptr{getDevice(r.fConfig)}; }); return runner.Run(); // Run with builtin catch all exception handler, just: // return runner.RunWithExceptionHandlers(); } catch (std::exception& e) { LOG(ERROR) << "Unhandled exception reached the top of main: " << e.what() << ", application will now exit"; return 1; } catch (...) { LOG(ERROR) << "Non-exception instance being thrown. Please make sure you use std::runtime_exception() instead. Application will now exit."; return 1; } }