wamp_event.hpp
1 //
3 // Copyright (c) Crossbar.io Technologies GmbH and contributors
4 //
5 // Boost Software License - Version 1.0 - August 17th, 2003
6 //
7 // Permission is hereby granted, free of charge, to any person or organization
8 // obtaining a copy of the software and accompanying documentation covered by
9 // this license (the "Software") to use, reproduce, display, distribute,
10 // execute, and transmit the Software, and to prepare derivative works of the
11 // Software, and to permit third-parties to whom the Software is furnished to
12 // do so, all subject to the following:
13 //
14 // The copyright notices in the Software and this entire statement, including
15 // the above license grant, this restriction and the following disclaimer,
16 // must be included in all copies of the Software, in whole or in part, and
17 // all derivative works of the Software, unless such copies or derivative
18 // works are solely in the form of machine-executable object code generated by
19 // a source language processor.
20 //
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
24 // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
25 // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
26 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 // DEALINGS IN THE SOFTWARE.
28 //
30 
31 #ifndef AUTOBAHN_WAMP_EVENT_HPP
32 #define AUTOBAHN_WAMP_EVENT_HPP
33 
34 #include "wamp_arguments.hpp"
35 
36 #include <memory>
37 #include <msgpack.hpp>
38 #include <string>
39 
40 namespace autobahn {
41 
43 {
44 public:
45  wamp_event(msgpack::zone&& zone);
46 
47 
48  //add URI and details
52  const std::string& uri() const;
53 
57  std::size_t number_of_arguments() const;
58 
62  std::size_t number_of_kw_arguments() const;
63 
73  template <typename T>
74  T argument(std::size_t index) const;
75 
84  template <typename List>
85  List arguments() const;
86 
98  template <typename List>
99  void get_arguments(List& args) const;
100 
117  template <typename... T>
118  inline void get_each_argument(T&... args) const;
119 
137  template <typename T>
138  T kw_argument(const std::string& key) const;
139 
140  template <typename T>
141  T kw_argument(const char* key) const;
142 
160  template <typename T>
161  T kw_argument_or(const std::string& key, const T& fallback) const;
162 
163  template <typename T>
164  T kw_argument_or(const char* key, const T& fallback) const;
165 
174  template <typename Map>
175  Map kw_arguments() const;
176 
188  template <typename Map>
189  void get_kw_arguments(Map& kw_args) const;
190 
191  //
192  // functions only called internally by wamp_session
193 
194  void set_arguments(const msgpack::object& arguments);
195  void set_kw_arguments(const msgpack::object& kw_arguments);
196  void set_details(const msgpack::object& details);
197 
198 private:
199  msgpack::zone m_zone;
200  msgpack::object m_arguments;
201  msgpack::object m_kw_arguments;
202  std::string m_uri;
203 
204 };
205 
206 } // namespace autobahn
207 
208 #include "wamp_event.ipp"
209 
210 #endif // AUTOBAHN_WAMP_EVENT_HPP
List arguments() const
The positional arguments published by the event, converted to a list type.
const std::string & uri() const
Event URI.
T kw_argument(const std::string &key) const
The keyword argument published by the event with the given key, converted to type T...
void get_arguments(List &args) const
Convert and assign the positional arguments published by the event to the given args list...
std::size_t number_of_kw_arguments() const
The number of keyword arguments published by the event.
void get_each_argument(T &...args) const
Convert and assign the positional arguments to a given list of individual parameters.
void get_kw_arguments(Map &kw_args) const
Convert and assign the keyword arguments published by the event to the given kw_args map...
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...
T argument(std::size_t index) const
The positional argument published by the event with the given index, converted to type T...
Map kw_arguments() const
The keyword arguments published by the event, converted to a map type.
std::size_t number_of_arguments() const
The number of positional arguments published by the event.