diff --git a/fairmq/DeviceRunner.cxx b/fairmq/DeviceRunner.cxx index b39a09d05..a2fea031e 100644 --- a/fairmq/DeviceRunner.cxx +++ b/fairmq/DeviceRunner.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2017 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2017-2018 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -7,16 +7,19 @@ ********************************************************************************/ #include "DeviceRunner.h" -#include + #include +#include +#include using namespace fair::mq; -DeviceRunner::DeviceRunner(int argc, char* const argv[]) +DeviceRunner::DeviceRunner(int argc, char* const argv[], bool printLogo) : fRawCmdLineArgs(tools::ToStrVector(argc, argv, false)) , fConfig() , fDevice(nullptr) , fPluginManager(fRawCmdLineArgs) + , fPrintLogo(printLogo) , fEvents() {} @@ -33,26 +36,34 @@ auto DeviceRunner::Run() -> int fEvents.Emit(*this); //////////////////////// - fPluginManager.ForEachPluginProgOptions([&](boost::program_options::options_description options){ - fConfig.AddToCmdLineOptions(options); - }); + fPluginManager.ForEachPluginProgOptions( + [&](boost::program_options::options_description options) { + fConfig.AddToCmdLineOptions(options); + }); fConfig.AddToCmdLineOptions(fPluginManager.ProgramOptions()); ////// CALL HOOK /////// fEvents.Emit(*this); //////////////////////// - if (fConfig.ParseAll(fRawCmdLineArgs, true)) - { + if (fConfig.ParseAll(fRawCmdLineArgs, true)) { return 0; } + if (fPrintLogo) { + LOG(info) << std::endl + << " ______ _ _______ _________ " << std::endl + << " / ____/___ _(_)_______ |/ /_ __ \\ version " << FAIRMQ_GIT_VERSION << std::endl + << " / /_ / __ `/ / ___/__ /|_/ /_ / / / build " << FAIRMQ_BUILD_TYPE << std::endl + << " / __/ / /_/ / / / _ / / / / /_/ / " << FAIRMQ_REPO_URL << std::endl + << " /_/ \\__,_/_/_/ /_/ /_/ \\___\\_\\ " << FAIRMQ_LICENSE << " © " << FAIRMQ_COPYRIGHT << std::endl; + } + ////// CALL HOOK /////// fEvents.Emit(*this); //////////////////////// - if (!fDevice) - { + if (!fDevice) { LOG(error) << "getDevice(): no valid device provided. Exiting."; return 1; } @@ -61,16 +72,14 @@ auto DeviceRunner::Run() -> int // Handle --print-channels fDevice->RegisterChannelEndpoints(); - if (fConfig.Count("print-channels")) - { + if (fConfig.Count("print-channels")) { fDevice->PrintRegisteredChannels(); fDevice->ChangeState(FairMQDevice::END); return 0; } // Handle --version - if (fConfig.Count("version")) - { + if (fConfig.Count("version")) { std::cout << "User device version: " << fDevice->GetVersion() << std::endl; std::cout << "FAIRMQ_INTERFACE_VERSION: " << FAIRMQ_INTERFACE_VERSION << std::endl; fDevice->ChangeState(FairMQDevice::END); @@ -99,18 +108,15 @@ auto DeviceRunner::Run() -> int auto DeviceRunner::RunWithExceptionHandlers() -> int { - try - { + try { return Run(); - } - catch (std::exception& e) - { - LOG(error) << "Unhandled exception reached the top of main: " << e.what() << ", application will now exit"; + } 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."; + } catch (...) { + LOG(error) << "Non-exception instance being thrown. Please make sure you use " + "std::runtime_exception() instead. Application will now exit."; return 1; } } diff --git a/fairmq/DeviceRunner.h b/fairmq/DeviceRunner.h index 5afb80868..2995583bc 100644 --- a/fairmq/DeviceRunner.h +++ b/fairmq/DeviceRunner.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2017 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2017-2018 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -20,10 +20,8 @@ #include #include -namespace fair -{ -namespace mq -{ +namespace fair { +namespace mq { /** * @class DeviceRunner DeviceRunner.h @@ -31,7 +29,8 @@ namespace mq * * Runs a single FairMQ device with config and plugin support. * - * For customization user hooks are executed at various steps during device launch/shutdown in the following sequence: + * For customization user hooks are executed at various steps during device launch/shutdown in the + * following sequence: * * LoadPlugins * | @@ -44,34 +43,41 @@ namespace mq * v * InstatiateDevice * - * Each hook has access to all members of the DeviceRunner and really only differs by the point in time it is called. + * Each hook has access to all members of the DeviceRunner and really only differs by the point in + * time it is called. * * For an example usage of this class see the fairmq/runFairMQDevice.h header. */ class DeviceRunner { public: - DeviceRunner(int argc, char* const argv[]); + DeviceRunner(int argc, char* const argv[], bool printLogo = true); auto Run() -> int; auto RunWithExceptionHandlers() -> int; template - auto AddHook(std::function hook) -> void { fEvents.Subscribe("runner", hook); } + auto AddHook(std::function hook) -> void + { + fEvents.Subscribe("runner", hook); + } template - auto RemoveHook() -> void { fEvents.Unsubscribe("runner"); } + auto RemoveHook() -> void + { + fEvents.Unsubscribe("runner"); + } std::vector fRawCmdLineArgs; FairMQProgOptions fConfig; std::unique_ptr fDevice; PluginManager fPluginManager; + const bool fPrintLogo; private: EventManager fEvents; }; -namespace hooks -{ +namespace hooks { struct LoadPlugins : Event {}; struct SetCustomCmdLineOptions : Event {}; struct ModifyRawCmdLineArgs : Event {}; diff --git a/fairmq/Version.h.in b/fairmq/Version.h.in index 17c2e4580..932867b64 100644 --- a/fairmq/Version.h.in +++ b/fairmq/Version.h.in @@ -15,5 +15,9 @@ #define FAIRMQ_VERSION_PATCH @PROJECT_VERSION_PATCH@ #define FAIRMQ_GIT_VERSION "@PROJECT_GIT_VERSION@" #define FAIRMQ_GIT_DATE "@PROJECT_GIT_DATE@" +#define FAIRMQ_REPO_URL "https://github.com/FairRootGroup/FairMQ" +#define FAIRMQ_LICENSE "LGPL-3.0" +#define FAIRMQ_COPYRIGHT "2012-2018 GSI" +#define FAIRMQ_BUILD_TYPE "@CMAKE_BUILD_TYPE@" #endif // FAIR_MQ_VERSION_H