autobahn::wamp_invocation_impl Class Reference

Public Types

using result_type = enum{final=0, intermediary}
 
using send_result_fn = std::function< void(const std::shared_ptr< wamp_message > &)>
 

Public Member Functions

 wamp_invocation_impl (wamp_invocation_impl &&)=delete
 
const std::string & uri () const
 Invocatition procedure URI. More...
 
std::size_t number_of_arguments () const
 The number of positional arguments passed to the invocation.
 
std::size_t number_of_kw_arguments () const
 The number of keyword arguments passed to the invocation.
 
template<typename T >
argument (std::size_t index) const
 The positional argument passed to the invocation with the given index, converted to type T. More...
 
template<typename List >
List arguments () const
 The positional arguments passed to the invocation, converted to a list type. More...
 
template<typename List >
void get_arguments (List &args) const
 Convert and assign the positional arguments 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 passed to the invocation 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 passed to the invocation 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 passed to the invocation, converted to a map type. More...
 
template<typename Map >
void get_kw_arguments (Map &kw_args) const
 Convert and assign the keyword arguments to the given kw_args map. More...
 
template<typename T >
detail (const std::string &key) const
 The call detail passed to the invocation with the given key, converted to type T. More...
 
template<typename T >
detail (const char *key) const
 
template<typename T >
detail_or (const std::string &key, const T &fallback) const
 The call detail passed to the invocation with the given key, converted to type T, or the given fallback if no such key was passed. More...
 
template<typename T >
detail_or (const char *key, const T &fallback) const
 
template<typename Map >
Map details () const
 The call details passed to the invocation, converted to a map type. More...
 
template<typename Map >
void get_details (Map &details) const
 Convert and assign the call details to the given details map. More...
 
bool progressive_results_expected () const
 Checks if caller expects progressive results.
 
void empty_result ()
 Reply to the invocation with an empty result.
 
template<typename List >
void progress (const List &arguments)
 Send progressive/partial result with positional arguments.
 
template<typename List , typename Map >
void progress (const List &arguments, const Map &kw_arguments)
 Send progressive/partial result with positional and keyword arguments.
 
template<typename List >
void result (const List &arguments)
 Reply to the invocation with positional arguments.
 
template<typename List , typename Map >
void result (const List &arguments, const Map &kw_arguments)
 Reply to the invocation with positional and keyword arguments.
 
void error (const std::string &error_uri)
 Reply to the invocation with an error and no further details.
 
template<typename List >
void error (const std::string &error_uri, const List &arguments)
 Reply to the invocation with an error, including positional arguments.
 
template<typename List , typename Map >
void error (const std::string &error_uri, const List &arguments, const Map &kw_arguments)
 Reply to the invocation with an error, including positional and keyword arguments.
 
void set_send_result_fn (send_result_fn &&)
 
void set_details (const msgpack::object &details)
 
void set_request_id (std::uint64_t)
 
void set_zone (msgpack::zone &&)
 
void set_arguments (const msgpack::object &arguments)
 
void set_kw_arguments (const msgpack::object &kw_arguments)
 
bool sendable () const
 

Detailed Description

Definition at line 46 of file wamp_invocation.hpp.

Member Function Documentation

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

The positional argument passed to the invocation with the given index, converted to type T.

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

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

The positional arguments passed to the invocation, converted to a list type.

Example: auto args = invocation->arguments<std::tuple<std::string>>();

Exceptions
std::bad_cast
template<typename T >
T autobahn::wamp_invocation_impl::detail ( const std::string &  key) const

The call detail passed to the invocation 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 details<Map>() or get_details<Map>(map), then access the items from there.

Example: std::string caller_authid = invocation->detail<std::string>("caller_authid");

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

The call detail passed to the invocation 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 details<Map>() or get_details<Map>(map), then access the items from there.

Example: std::string caller_authid = invocation->detail_or("caller_authid", std::string());

Exceptions
std::bad_cast
template<typename Map >
Map autobahn::wamp_invocation_impl::details ( ) const

The call details passed to the invocation, converted to a map type.

Example: auto kw_args = invocation->details<std::unordered_map<std::string, msgpack::object>>();

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

Convert and assign the positional arguments to the given args list.

Example:

std::tuple<std::string> args;
invocation->get_arguments(args);
Exceptions
std::bad_cast
template<typename Map >
void autobahn::wamp_invocation_impl::get_details ( Map &  details) const

Convert and assign the call details to the given details map.

Example:

std::unordered_map<std::string, msgpack::object> kw_args;
invocation->get_details(details);
Exceptions
std::bad_cast
template<typename... T>
void autobahn::wamp_invocation_impl::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_invocation_impl::get_kw_arguments ( Map &  kw_args) const

Convert and assign the keyword arguments to the given kw_args map.

Example:

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

The keyword argument passed to the invocation 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 = invocation->kw_argument<std::string>("id");

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

The keyword argument passed to the invocation 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 = invocation->kw_argument_or("id", std::string());

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

The keyword arguments passed to the invocation, converted to a map type.

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

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

Invocatition procedure URI.

Used by prefix & wildcard registered procedures