FairMQ
1.4.33
C++ Message Queuing Library and Framework
|
Facilitates communication between devices and plugins. More...
#include <fairmq/PluginServices.h>
Classes | |
struct | DeviceControlError |
Public Types | |
using | DeviceState = fair::mq::State |
using | DeviceStateTransition = fair::mq::Transition |
Public Member Functions | |
PluginServices (ProgOptions &config, FairMQDevice &device) | |
PluginServices (const PluginServices &)=delete | |
PluginServices | operator= (const PluginServices &)=delete |
auto | GetCurrentDeviceState () const -> DeviceState |
auto | TakeDeviceControl (const std::string &controller) -> void |
Become device controller. More... | |
auto | StealDeviceControl (const std::string &controller) -> void |
Become device controller by force. More... | |
auto | ReleaseDeviceControl (const std::string &controller) -> void |
Release device controller role. More... | |
auto | GetDeviceController () const -> boost::optional< std::string > |
Get current device controller. | |
auto | WaitForReleaseDeviceControl () -> void |
Block until control is released. | |
auto | ChangeDeviceState (const std::string &controller, const DeviceStateTransition next) -> bool |
Request a device state transition. More... | |
auto | SubscribeToDeviceStateChange (const std::string &subscriber, std::function< void(DeviceState)> callback) -> void |
Subscribe with a callback to device state changes. More... | |
auto | UnsubscribeFromDeviceStateChange (const std::string &subscriber) -> void |
Unsubscribe from device state changes. More... | |
auto | PropertyExists (const std::string &key) const -> bool |
Checks a property with the given key exist in the configuration. More... | |
template<typename T > | |
auto | SetProperty (const std::string &key, T val) -> void |
Set config property. More... | |
void | SetProperties (const fair::mq::Properties &props) |
Set multiple config properties. More... | |
template<typename T > | |
bool | UpdateProperty (const std::string &key, T val) |
Updates an existing config property (or fails if it doesn't exist) More... | |
bool | UpdateProperties (const fair::mq::Properties &input) |
Updates multiple existing config properties (or fails of any of then do not exist, leaving property store unchanged) More... | |
void | DeleteProperty (const std::string &key) |
Deletes a property with the given key from the config store. More... | |
template<typename T > | |
auto | GetProperty (const std::string &key) const -> T |
Read config property, throw if no property with this key exists. More... | |
template<typename T > | |
T | GetProperty (const std::string &key, const T &ifNotFound) const |
Read config property, return provided value if no property with this key exists. More... | |
auto | GetPropertyAsString (const std::string &key) const -> std::string |
Read config property as string, throw if no property with this key exists. More... | |
auto | GetPropertyAsString (const std::string &key, const std::string &ifNotFound) const -> std::string |
Read config property, return provided value if no property with this key exists. More... | |
fair::mq::Properties | GetProperties (const std::string &q) const |
Read several config properties whose keys match the provided regular expression. More... | |
fair::mq::Properties | GetPropertiesStartingWith (const std::string &q) const |
Read several config properties whose keys start with the provided string. More... | |
std::map< std::string, std::string > | GetPropertiesAsString (const std::string &q) const |
Read several config properties as string whose keys match the provided regular expression. More... | |
std::map< std::string, std::string > | GetPropertiesAsStringStartingWith (const std::string &q) const |
Read several config properties as string whose keys start with the provided string. More... | |
auto | GetChannelInfo () const -> std::unordered_map< std::string, int > |
Retrieve current channel information. More... | |
auto | GetPropertyKeys () const -> std::vector< std::string > |
Discover the list of property keys. More... | |
template<typename T > | |
auto | SubscribeToPropertyChange (const std::string &subscriber, std::function< void(const std::string &key, T)> callback) const -> void |
Subscribe to property updates of type T. More... | |
template<typename T > | |
auto | UnsubscribeFromPropertyChange (const std::string &subscriber) -> void |
Unsubscribe from property updates of type T. More... | |
auto | SubscribeToPropertyChangeAsString (const std::string &subscriber, std::function< void(const std::string &key, std::string)> callback) const -> void |
Subscribe to property updates. More... | |
auto | UnsubscribeFromPropertyChangeAsString (const std::string &subscriber) -> void |
Unsubscribe from property updates that convert to string. More... | |
auto | CycleLogConsoleSeverityUp () -> void |
Increases console logging severity, or sets it to lowest if it is already highest. | |
auto | CycleLogConsoleSeverityDown () -> void |
Decreases console logging severity, or sets it to highest if it is already lowest. | |
auto | CycleLogVerbosityUp () -> void |
Increases logging verbosity, or sets it to lowest if it is already highest. | |
auto | CycleLogVerbosityDown () -> void |
Decreases logging verbosity, or sets it to highest if it is already lowest. | |
Static Public Member Functions | |
static auto | ToDeviceState (const std::string &state) -> DeviceState |
Convert string to DeviceState. More... | |
static auto | ToDeviceStateTransition (const std::string &transition) -> DeviceStateTransition |
Convert string to DeviceStateTransition. More... | |
static auto | ToStr (DeviceState state) -> std::string |
Convert DeviceState to string. More... | |
static auto | ToStr (DeviceStateTransition transition) -> std::string |
Convert DeviceStateTransition to string. More... | |
Facilitates communication between devices and plugins.
auto PluginServices::ChangeDeviceState | ( | const std::string & | controller, |
const DeviceStateTransition | next | ||
) | -> bool |
Request a device state transition.
controller | id |
next | state transition |
fair::mq::PluginServices::DeviceControlError | if control role is not currently owned by passed controller id. |
The state transition may not happen immediately, but when the current state evaluates the pending transition event and terminates. In other words, the device states are scheduled cooperatively. If the device control role has not been taken yet, calling this function will take over control implicitely.
|
inline |
Deletes a property with the given key from the config store.
key |
|
inline |
Retrieve current channel information.
|
inline |
|
inline |
Read several config properties whose keys match the provided regular expression.
q | regex string to match for |
|
inline |
Read several config properties as string whose keys match the provided regular expression.
q | regex string to match for |
|
inline |
Read several config properties as string whose keys start with the provided string.
q | string to match for |
Typically more performant than GetPropertiesAsString with regex
|
inline |
Read several config properties whose keys start with the provided string.
q | string to match for |
Typically more performant than GetProperties with regex
|
inline |
Read config property, throw if no property with this key exists.
key |
|
inline |
Read config property, return provided value if no property with this key exists.
key | |
ifNotFound | value to return if key is not found |
|
inline |
Read config property as string, throw if no property with this key exists.
key |
Supports conversion to string for a fixed set of types, for custom/unsupported types add them via fair::mq::PropertyHelper::AddType<MyType>("optional label")
the provided type must then be convertible to string via operator<<
|
inline |
Read config property, return provided value if no property with this key exists.
key | |
ifNotFound | value to return if key is not found |
Supports conversion to string for a fixed set of types, for custom/unsupported types add them via fair::mq::PropertyHelper::AddType<MyType>("optional label")
the provided type must then be convertible to string via operator<<
|
inline |
Discover the list of property keys.
|
inline |
Checks a property with the given key exist in the configuration.
key |
auto PluginServices::ReleaseDeviceControl | ( | const std::string & | controller | ) | -> void |
Release device controller role.
controller | id |
fair::mq::PluginServices::DeviceControlError | if passed controller id is not the current device controller. |
|
inline |
Set multiple config properties.
props | fair::mq::Properties as an alias for std::map<std::string, Property>, where property is boost::any |
|
inline |
Set config property.
key | |
val | Setting a config property will store the value in the FairMQ internal config store and notify any subscribers about the update. It is property dependent, if the call to this method will have an immediate, delayed or any effect at all. |
auto PluginServices::StealDeviceControl | ( | const std::string & | controller | ) | -> void |
Become device controller by force.
controller | id |
Take over device controller privileges by force. Does not trigger the ReleaseDeviceControl condition! This function is intended to implement override/emergency control functionality (e.g. device shutdown on SIGINT).
|
inline |
Subscribe with a callback to device state changes.
subscriber | id |
callback | The callback will be called at the beginning of a new state. The callback is called from the thread the state is running in. |
|
inline |
Subscribe to property updates of type T.
subscriber | |
callback | function |
Subscribe to property changes with a callback to monitor property changes in an event based fashion.
|
inline |
Subscribe to property updates.
subscriber | |
callback | function |
Subscribe to property changes with a callback to monitor property changes in an event based fashion. Will convert the property to string.
auto PluginServices::TakeDeviceControl | ( | const std::string & | controller | ) | -> void |
Become device controller.
controller | id |
fair::mq::PluginServices::DeviceControlError | if there is already a device controller. |
Only one plugin can succeed to take control over device state transitions at a time.
|
inlinestatic |
Convert string to DeviceState.
state | to convert |
std::out_of_range | if a string cannot be resolved to a DeviceState |
|
inlinestatic |
Convert string to DeviceStateTransition.
transition | to convert |
std::out_of_range | if a string cannot be resolved to a DeviceStateTransition |
|
inlinestatic |
Convert DeviceState to string.
state | to convert |
|
inlinestatic |
Convert DeviceStateTransition to string.
transition | to convert |
|
inline |
Unsubscribe from device state changes.
subscriber | id |
|
inline |
Unsubscribe from property updates of type T.
subscriber |
|
inline |
Unsubscribe from property updates that convert to string.
subscriber |
|
inline |
Updates multiple existing config properties (or fails of any of then do not exist, leaving property store unchanged)
props | (fair::mq::Properties as an alias for std::map<std::string, Property>, where property is boost::any) |
|
inline |
Updates an existing config property (or fails if it doesn't exist)
key | |
val |