autobahn::wamp_event Class Reference

Public Member Functions

 wamp_event (msgpack::zone &&zone)
 
const std::string & uri () const
 Event URI. More...
 
std::size_t number_of_arguments () const
 The number of positional arguments published by the event.
 
std::size_t number_of_kw_arguments () const
 The number of keyword arguments published by the event.
 
template<typename T >
argument (std::size_t index) const
 The positional argument published by the event with the given index, converted to type T. More...
 
template<typename List >
List arguments () const
 The positional arguments published by the event, converted to a list type. More...
 
template<typename List >
void get_arguments (List &args) const
 Convert and assign the positional arguments published by the event to the given args list. More...
 
template<typename... T>
void get_each_argument (T &...args) const
 Convert and assign the positional arguments to a given list of individual parameters. More...
 
template<typename T >
kw_argument (const std::string &key) const
 The keyword argument published by the event with the given key, converted to type T. More...
 
template<typename T >
kw_argument (const char *key) const
 
template<typename T >
kw_argument_or (const std::string &key, const T &fallback) const
 The keyword argument published by the event with the given key, converted to type T, or the given fallback if no such key was passed. More...
 
template<typename T >
kw_argument_or (const char *key, const T &fallback) const
 
template<typename Map >
Map kw_arguments () const
 The keyword arguments published by the event, converted to a map type. More...
 
template<typename Map >
void get_kw_arguments (Map &kw_args) const
 Convert and assign the keyword arguments published by the event to the given kw_args map. More...
 
void set_arguments (const msgpack::object &arguments)
 
void set_kw_arguments (const msgpack::object &kw_arguments)
 
void set_details (const msgpack::object &details)
 

Detailed Description

Definition at line 42 of file wamp_event.hpp.

Member Function Documentation

template<typename T >
T autobahn::wamp_event::argument ( std::size_t  index) const

The positional argument published by the event with the given index, converted to type T.

Example: std::string id = event.argument<std::string>(0); // first positional argument

Exceptions
std::out_of_range
std::bad_cast
template<typename List >
List autobahn::wamp_event::arguments ( ) const

The positional arguments published by the event, converted to a list type.

Example: auto args = event.arguments<std::tuple<std::string>>();

Exceptions
std::bad_cast
template<typename List >
void autobahn::wamp_event::get_arguments ( List &  args) const

Convert and assign the positional arguments published by the event to the given args list.

Example:

std::tuple<std::string> args;
event.get_arguments(args);
Exceptions
std::bad_cast
template<typename... T>
void autobahn::wamp_event::get_each_argument ( T &...  args) const
inline

Convert and assign the positional arguments to a given list of individual parameters.

Enables a syntax that lets you declare variables individually, but list them in a single space to empathize parameter order. This will also throw if the number of arguments to the invocation doesn't match the number of given parameters.

Example:

uint64_t id;
std::string name;
invocation->get_each_argument(id, name);
Exceptions
std::bad_cast
template<typename Map >
void autobahn::wamp_event::get_kw_arguments ( Map &  kw_args) const

Convert and assign the keyword arguments published by the event to the given kw_args map.

Example:

std::unordered_map<std::string, msgpack::object> kw_args;
event.get_kw_arguments(kw_args);
Exceptions
std::bad_cast
template<typename T >
T autobahn::wamp_event::kw_argument ( const std::string &  key) const

The keyword argument published by the event with the given key, converted to type T.

Overloads are provided for std::string and char* as key type.

This function uses key string comparisons to find the matching value, O(n) with n being the number of map elements. Memory allocation for keys is avoided though. For larger maps, you might want to prioritize look-up performance by using std::map, std::unordered_map or custom types with custom deserialization. To do this, use kw_arguments<Map>() or get_kw_arguments<Map>(map), then access the items from there.

Example: std::string id = event.kw_argument<std::string>("id");

Exceptions
std::out_of_range
std::bad_cast
template<typename T >
T autobahn::wamp_event::kw_argument_or ( const std::string &  key,
const T &  fallback 
) const

The keyword argument published by the event with the given key, converted to type T, or the given fallback if no such key was passed.

Overloads are provided for std::string and char* as key type.

This function uses key string comparisons to find the matching value, O(n) with n being the number of map elements. Memory allocation for keys is avoided though. For larger maps, you might want to prioritize look-up performance by using std::map, std::unordered_map or custom types with custom deserialization. To do this, use kw_arguments<Map>() or get_kw_arguments<Map>(map), then access the items from there.

Example: std::string id = event.kw_argument_or("id", std::string());

Exceptions
std::bad_cast
template<typename Map >
Map autobahn::wamp_event::kw_arguments ( ) const

The keyword arguments published by the event, converted to a map type.

Example: auto kw_args = event.kw_arguments<std::unordered_map<std::string, msgpack::object>>();

Exceptions
std::bad_cast
const std::string& autobahn::wamp_event::uri ( ) const

Event URI.

Used by prefix & wildcard subscriptions