FairMQ  1.4.33
C++ Message Queuing Library and Framework
Public Member Functions | List of all members
fair::mq::ProgOptions Class Reference

Public Member Functions

void ParseAll (const std::vector< std::string > &cmdArgs, bool allowUnregistered)
 
void ParseAll (const int argc, char const *const *argv, bool allowUnregistered=true)
 
void Notify ()
 
void AddToCmdLineOptions (const boost::program_options::options_description optDesc, bool visible=true)
 
boost::program_options::options_description & GetCmdLineOptions ()
 
int Count (const std::string &key) const
 Checks a property with the given key exist in the configuration. More...
 
std::unordered_map< std::string, int > GetChannelInfo () const
 Retrieve current channel information. More...
 
std::vector< std::string > GetPropertyKeys () const
 Discover the list of property keys. More...
 
template<typename T >
GetProperty (const std::string &key) const
 Read config property, throw if no property with this key exists. More...
 
template<typename T >
GetProperty (const std::string &key, const T &ifNotFound) const
 Read config property, return provided value if no property with this key exists. More...
 
std::string GetPropertyAsString (const std::string &key) const
 Read config property as string, throw if no property with this key exists. More...
 
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. 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...
 
template<typename T >
void SetProperty (const std::string &key, T val)
 Set config property. 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...
 
void SetProperties (const fair::mq::Properties &input)
 Set multiple config properties. 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...
 
void AddChannel (const std::string &name, const FairMQChannel &channel)
 Takes the provided channel and creates properties based on it. More...
 
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. More...
 
template<typename T >
void Unsubscribe (const std::string &subscriber) const
 Unsubscribe from property updates of type T. More...
 
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. More...
 
void UnsubscribeAsString (const std::string &subscriber) const
 Unsubscribe from property updates that convert to string. More...
 
void PrintHelp () const
 prints full options description
 
void PrintOptions () const
 prints properties stored in the property container
 
void PrintOptionsRaw () const
 prints full options description in a compact machine-readable format
 
const boost::program_options::variables_map & GetVarMap () const
 returns the property container
 
template<typename T >
GetValue (const std::string &key) const
 Read config property, return default-constructed object if key doesn't exist. More...
 
template<typename T >
int SetValue (const std::string &key, T val)
 
std::string GetStringValue (const std::string &key) const
 Read config property as string, return default-constructed object if key doesn't exist. More...
 

Member Function Documentation

◆ AddChannel()

void fair::mq::ProgOptions::AddChannel ( const std::string &  name,
const FairMQChannel channel 
)

Takes the provided channel and creates properties based on it.

Parameters
namechannel name
channelFairMQChannel reference

◆ Count()

int fair::mq::ProgOptions::Count ( const std::string &  key) const

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

Parameters
key
Returns
1 if it exists, 0 otherwise

◆ DeleteProperty()

void fair::mq::ProgOptions::DeleteProperty ( const std::string &  key)

Deletes a property with the given key from the config store.

Parameters
key

◆ GetChannelInfo()

unordered_map< string, int > fair::mq::ProgOptions::GetChannelInfo ( ) const

Retrieve current channel information.

Returns
a map of <channel name, number of subchannels>

◆ GetProperties()

Properties fair::mq::ProgOptions::GetProperties ( const std::string &  q) const

Read several config properties whose keys match the provided regular expression.

Parameters
qregex 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)

◆ GetPropertiesAsString()

map< string, string > fair::mq::ProgOptions::GetPropertiesAsString ( const std::string &  q) const

Read several config properties as string whose keys match the provided regular expression.

Parameters
qregex 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)

◆ GetPropertiesAsStringStartingWith()

map< string, string > fair::mq::ProgOptions::GetPropertiesAsStringStartingWith ( const std::string &  q) const

Read several config properties as string whose keys start with the provided string.

Parameters
qstring to match for
Returns
container with properties (fair::mq::Properties as an alias for std::map<std::string, Property>, where property is boost::any)

Typically more performant than GetPropertiesAsString with regex

◆ GetPropertiesStartingWith()

Properties fair::mq::ProgOptions::GetPropertiesStartingWith ( const std::string &  q) const

Read several config properties whose keys start with the provided string.

Parameters
qstring to match for
Returns
container with properties (fair::mq::Properties as an alias for std::map<std::string, Property>, where property is boost::any)

Typically more performant than GetProperties with regex

◆ GetProperty() [1/2]

template<typename T >
T fair::mq::ProgOptions::GetProperty ( const std::string &  key) const
inline

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

Parameters
key
Returns
config property

◆ GetProperty() [2/2]

template<typename T >
T fair::mq::ProgOptions::GetProperty ( const std::string &  key,
const T &  ifNotFound 
) const
inline

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

Parameters
key
ifNotFoundvalue to return if key is not found
Returns
config property

◆ GetPropertyAsString() [1/2]

std::string fair::mq::ProgOptions::GetPropertyAsString ( const std::string &  key) const

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

Parameters
key
Returns
config property converted to string

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

◆ GetPropertyAsString() [2/2]

std::string fair::mq::ProgOptions::GetPropertyAsString ( const std::string &  key,
const std::string &  ifNotFound 
) const

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

Parameters
key
ifNotFoundvalue to return if key is not found
Returns
config property converted to string

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

◆ GetPropertyKeys()

vector< string > fair::mq::ProgOptions::GetPropertyKeys ( ) const

Discover the list of property keys.

Returns
list of property keys

◆ GetStringValue()

string fair::mq::ProgOptions::GetStringValue ( const std::string &  key) const

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

Parameters
key
Returns
config property

◆ GetValue()

template<typename T >
T fair::mq::ProgOptions::GetValue ( const std::string &  key) const
inline

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

Parameters
key
Returns
config property

◆ SetProperties()

void fair::mq::ProgOptions::SetProperties ( const fair::mq::Properties &  input)

Set multiple config properties.

Parameters
propsfair::mq::Properties as an alias for std::map<std::string, Property>, where property is boost::any

◆ SetProperty()

template<typename T >
void fair::mq::ProgOptions::SetProperty ( const std::string &  key,
val 
)
inline

Set config property.

Parameters
key
val

◆ Subscribe()

template<typename T >
void fair::mq::ProgOptions::Subscribe ( const std::string &  subscriber,
std::function< void(typename fair::mq::PropertyChange::KeyType, T)>  func 
) const
inline

Subscribe to property updates of type T.

Parameters
subscriber
callbackfunction

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

◆ SubscribeAsString()

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

Subscribe to property updates, with values converted to string.

Parameters
subscriber
callbackfunction

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

◆ Unsubscribe()

template<typename T >
void fair::mq::ProgOptions::Unsubscribe ( const std::string &  subscriber) const
inline

Unsubscribe from property updates of type T.

Parameters
subscriber

◆ UnsubscribeAsString()

void fair::mq::ProgOptions::UnsubscribeAsString ( const std::string &  subscriber) const
inline

Unsubscribe from property updates that convert to string.

Parameters
subscriber

◆ UpdateProperties()

bool fair::mq::ProgOptions::UpdateProperties ( const fair::mq::Properties &  input)

Updates multiple existing config properties (or fails of any of then do not exist, leaving property store unchanged)

Parameters
props(fair::mq::Properties as an alias for std::map<std::string, Property>, where property is boost::any)

◆ UpdateProperty()

template<typename T >
bool fair::mq::ProgOptions::UpdateProperty ( const std::string &  key,
val 
)
inline

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

Parameters
key
val

The documentation for this class was generated from the following files:

privacy