Skip to content

API · fair::mq

ProgOptionsclass

#include <ProgOptions.h>fairmq/ProgOptions.h:32GitHub ↗

No comment in the header yet.

Functions

void ParseAll(const std::vector<std::string>& cmdArgs, bool allowUnregistered)

No comment in the header yet.

void ParseAll(int argc, char const*const* argv, bool allowUnregistered = true)

No comment in the header yet.

int Count(const std::string& key) const

Checks a property with the given key exist in the configuration.

key
—
Returns
1 if it exists, 0 otherwise
std::unordered_map<std::string, int> GetChannelInfo() const

Retrieve current channel information.

Returns
a map of <channel name, number of subchannels>
template<typename T>
T GetProperty(const std::string& key) const

Read config property, throw if no property with this key exists.

key
—
Returns
config property
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.

key
—
ifNotFound
value to return if key is not found
Returns
config property
std::string GetPropertyAsString(const std::string& key) const

Read config property as string, throw if no property with this key exists.

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<<

key
—
Returns
config property converted to string
std::string GetPropertyAsString(
    const std::string& key,
    const std::string& ifNotFound
) const

Read config property, return provided value if no property with this key exists.

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<<

key
—
ifNotFound
value to return if key is not found
Returns
config property converted to string
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.

q
regex string to match for
Returns
container with properties (fair::mq::Properties as an alias for std::map<std::string, Property>, where property is boost::any)
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.

Typically more performant than GetPropertiesAsString with regex

q
string to match for
Returns
container with properties (fair::mq::Properties as an alias for std::map<std::string, Property>, where property is boost::any)
template<typename T>
bool UpdateProperty(const std::string& key, T val)

Updates an existing config property (or fails if it doesn't exist)

key
—
val
—
void AddChannel(const std::string& name, const Channel& channel)

Takes the provided channel and creates properties based on it.

name
channel name
channel
FairMQChannel reference
template<typename T>
void Subscribe(
    const std::string& subscriber,
    std::function<void(typename fair::mq::PropertyChange::KeyType, T)> func
) const

Subscribe to property updates of type T.

Subscribe to property changes with a callback to monitor property changes in an event based fashion.

subscriber
—
callback
function
template<typename T>
void Unsubscribe(const std::string& subscriber) const

Unsubscribe from property updates of type T.

subscriber
—
void SubscribeAsString(
    const std::string& subscriber,
    std::function<void(typename fair::mq::PropertyChange::KeyType, std::string)> func
) const

Subscribe to property updates, with values converted to string.

Subscribe to property changes with a callback to monitor property changes in an event based fashion. Will convert the property to string.

subscriber
—
callback
function
template<typename T>
T GetValue(const std::string& key) const

Read config property, return default-constructed object if key doesn't exist.

key
—
Returns
config property
template<typename T>
int SetValue(const std::string& key, T val)

No comment in the header yet.

std::string GetStringValue(const std::string& key) const

Read config property as string, return default-constructed object if key doesn't exist.

key
—
Returns
config property