mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 08:41:16 +00:00
Bump coolness factor
Log ascii logo with some metadata. Metadata added to header <fairmq/Version.h>.
This commit is contained in:
parent
2c6b2e7f04
commit
c2bea85b90
|
@ -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 <fairmq/Tools.h>
|
||||
|
||||
#include <exception>
|
||||
#include <fairmq/Tools.h>
|
||||
#include <fairmq/Version.h>
|
||||
|
||||
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<hooks::SetCustomCmdLineOptions>(*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<hooks::ModifyRawCmdLineArgs>(*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<hooks::InstantiateDevice>(*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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 <string>
|
||||
#include <vector>
|
||||
|
||||
namespace fair
|
||||
{
|
||||
namespace mq
|
||||
{
|
||||
namespace fair {
|
||||
namespace mq {
|
||||
|
||||
/**
|
||||
* @class DeviceRunner DeviceRunner.h <fairmq/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<typename H>
|
||||
auto AddHook(std::function<void(DeviceRunner&)> hook) -> void { fEvents.Subscribe<H>("runner", hook); }
|
||||
auto AddHook(std::function<void(DeviceRunner&)> hook) -> void
|
||||
{
|
||||
fEvents.Subscribe<H>("runner", hook);
|
||||
}
|
||||
template<typename H>
|
||||
auto RemoveHook() -> void { fEvents.Unsubscribe<H>("runner"); }
|
||||
auto RemoveHook() -> void
|
||||
{
|
||||
fEvents.Unsubscribe<H>("runner");
|
||||
}
|
||||
|
||||
std::vector<std::string> fRawCmdLineArgs;
|
||||
FairMQProgOptions fConfig;
|
||||
std::unique_ptr<FairMQDevice> fDevice;
|
||||
PluginManager fPluginManager;
|
||||
const bool fPrintLogo;
|
||||
|
||||
private:
|
||||
EventManager fEvents;
|
||||
};
|
||||
|
||||
namespace hooks
|
||||
{
|
||||
namespace hooks {
|
||||
struct LoadPlugins : Event<DeviceRunner&> {};
|
||||
struct SetCustomCmdLineOptions : Event<DeviceRunner&> {};
|
||||
struct ModifyRawCmdLineArgs : Event<DeviceRunner&> {};
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user