DeviceRunner.h
/********************************************************************************
* 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" *
********************************************************************************/
#ifndef FAIR_MQ_DEVICERUNNER_H
#define FAIR_MQ_DEVICERUNNER_H
#include <fairmq/EventManager.h>
#include <fairmq/PluginManager.h>
#include <FairMQDevice.h>
#include <FairMQLogger.h>
#include <options/FairMQProgOptions.h>
#include <functional>
#include <memory>
#include <string>
#include <vector>
namespace fair
{
namespace mq
{
class DeviceRunner
{
public:
DeviceRunner(int argc, char* const argv[]);
auto Run() -> int;
auto RunWithExceptionHandlers() -> int;
template<typename H>
auto AddHook(std::function<void(DeviceRunner&)> hook) -> void { fEvents.Subscribe<H>("runner", hook); }
template<typename H>
auto RemoveHook() -> void { fEvents.Unsubscribe<H>("runner"); }
std::vector<std::string> fRawCmdLineArgs;
std::shared_ptr<PluginManager> fPluginManager;
FairMQProgOptions fConfig;
std::shared_ptr<FairMQDevice> fDevice;
private:
EventManager fEvents;
};
namespace hooks
{
struct LoadPlugins : Event<DeviceRunner&> {};
struct SetCustomCmdLineOptions : Event<DeviceRunner&> {};
struct ModifyRawCmdLineArgs : Event<DeviceRunner&> {};
struct InstantiateDevice : Event<DeviceRunner&> {};
} /* namespace hooks */
} /* namespace mq */
} /* namespace fair */
#endif /* FAIR_MQ_DEVICERUNNER_H */
fair::mq::DeviceRunner
Utility class to facilitate a convenient top-level device launch/shutdown.
Definition: DeviceRunner.h:51
fair::mq::Event
Definition: EventManager.h:33
fair::mq::hooks::LoadPlugins
Definition: DeviceRunner.h:75
fair::mq::EventManager
Manages event callbacks from different subscribers.
Definition: EventManager.h:53
FairMQProgOptions
Definition: FairMQProgOptions.h:41
fair::mq::hooks::ModifyRawCmdLineArgs
Definition: DeviceRunner.h:77
fair::mq::hooks::InstantiateDevice
Definition: DeviceRunner.h:78
fair::mq::hooks::SetCustomCmdLineOptions
Definition: DeviceRunner.h:76
fair
Definition: DeviceRunner.h:23