# FairMQ: fairmq/DeviceRunner.h Source File

DeviceRunner.h
/********************************************************************************
* 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, *
* 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 <fairmq/ProgOptions.h>
#include <FairMQDevice.h>
#include <functional>
#include <memory>
#include <string>
#include <vector>
namespace fair::mq
{
class DeviceRunner
{
public:
DeviceRunner(int argc, char*const* argv, bool printLogo = true);
auto Run() -> int;
auto RunWithExceptionHandlers() -> int;
static bool HandleGeneralOptions(const fair::mq::ProgOptions& config, bool printLogo = true);
void SubscribeForConfigChange();
void UnsubscribeFromConfigChange();
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;
fair::mq::ProgOptions fConfig;
std::unique_ptr<FairMQDevice> fDevice;
PluginManager fPluginManager;
const bool fPrintLogo;
private:
EventManager fEvents;
};
namespace hooks {
struct LoadPlugins : Event<DeviceRunner&> {};
struct SetCustomCmdLineOptions : Event<DeviceRunner&> {};
struct ModifyRawCmdLineArgs : Event<DeviceRunner&> {};
struct InstantiateDevice : Event<DeviceRunner&> {};
} /* namespace hooks */
} // namespace fair::mq
#endif /* FAIR_MQ_DEVICERUNNER_H */
fair::mq::ProgOptions
Definition: ProgOptions.h:41
fair::mq
Tools for interfacing containers to the transport via polymorphic allocators.
Definition: DeviceRunner.h:23
fair::mq::DeviceRunner
Utility class to facilitate a convenient top-level device launch/shutdown.
Definition: DeviceRunner.h:57

privacy