Electroneum
Loading...
Searching...
No Matches
levin_abstract_invoke2.h File Reference
#include "portable_storage_template_helper.h"
#include <boost/utility/value_init.hpp>
#include <functional>
#include "span.h"
#include "net/levin_base.h"
Include dependency graph for levin_abstract_invoke2.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  epee
namespace  epee::net_utils

Macros

#define ELECTRONEUM_DEFAULT_LOG_CATEGORY   "net"
#define CHAIN_LEVIN_INVOKE_MAP2(context_type)
#define CHAIN_LEVIN_NOTIFY_MAP2(context_type)
#define CHAIN_LEVIN_INVOKE_MAP()
#define CHAIN_LEVIN_NOTIFY_MAP()
#define CHAIN_LEVIN_NOTIFY_STUB()
#define BEGIN_INVOKE_MAP2(owner_type)
#define HANDLE_INVOKE2(command_id, func, type_name_in, typename_out)
#define HANDLE_INVOKE_T2(COMMAND, func)
#define HANDLE_NOTIFY2(command_id, func, type_name_in)
#define HANDLE_NOTIFY_T2(NOTIFY, func)
#define CHAIN_INVOKE_MAP2(func)
#define CHAIN_INVOKE_MAP_TO_OBJ2(obj)
#define CHAIN_INVOKE_MAP_TO_OBJ_FORCE_CONTEXT(obj, context_type)
#define END_INVOKE_MAP2()

Functions

template<class t_arg, class t_result, class t_transport>
bool epee::net_utils::invoke_remote_command2 (int command, const t_arg &out_struct, t_result &result_struct, t_transport &transport)
template<class t_arg, class t_transport>
bool epee::net_utils::notify_remote_command2 (int command, const t_arg &out_struct, t_transport &transport)
template<class t_arg, class t_result, class t_transport>
bool epee::net_utils::invoke_remote_command2 (boost::uuids::uuid conn_id, int command, const t_arg &out_struct, t_result &result_struct, t_transport &transport)
template<class t_result, class t_arg, class callback_t, class t_transport>
bool epee::net_utils::async_invoke_remote_command2 (boost::uuids::uuid conn_id, int command, const t_arg &out_struct, t_transport &transport, const callback_t &cb, size_t inv_timeout=LEVIN_DEFAULT_TIMEOUT_PRECONFIGURED)
template<class t_arg, class t_transport>
bool epee::net_utils::notify_remote_command2 (boost::uuids::uuid conn_id, int command, const t_arg &out_struct, t_transport &transport)
template<class t_owner, class t_in_type, class t_out_type, class t_context, class callback_t>
int epee::net_utils::buff_to_t_adapter (int command, const epee::span< const uint8_t > in_buff, std::string &buff_out, callback_t cb, t_context &context)
template<class t_owner, class t_in_type, class t_context, class callback_t>
int epee::net_utils::buff_to_t_adapter (t_owner *powner, int command, const epee::span< const uint8_t > in_buff, callback_t cb, t_context &context)

Macro Definition Documentation

◆ BEGIN_INVOKE_MAP2

#define BEGIN_INVOKE_MAP2 ( owner_type)
Value:
template <class t_context> int handle_invoke_map(bool is_notify, int command, const epee::span<const uint8_t> in_buff, std::string& buff_out, t_context& context, bool& handled) \
{ \
typedef owner_type internal_owner_type_name;
Non-owning sequence of data. Does not deep copy.
Definition span.h:57

Definition at line 254 of file levin_abstract_invoke2.h.

254#define BEGIN_INVOKE_MAP2(owner_type) \
255 template <class t_context> int handle_invoke_map(bool is_notify, int command, const epee::span<const uint8_t> in_buff, std::string& buff_out, t_context& context, bool& handled) \
256 { \
257 typedef owner_type internal_owner_type_name;

◆ CHAIN_INVOKE_MAP2

#define CHAIN_INVOKE_MAP2 ( func)
Value:
{ \
int res = func(is_notify, command, in_buff, buff_out, context, handled); \
if(handled) \
return res; \
}
const char * res

Definition at line 277 of file levin_abstract_invoke2.h.

277#define CHAIN_INVOKE_MAP2(func) \
278 { \
279 int res = func(is_notify, command, in_buff, buff_out, context, handled); \
280 if(handled) \
281 return res; \
282 }

◆ CHAIN_INVOKE_MAP_TO_OBJ2

#define CHAIN_INVOKE_MAP_TO_OBJ2 ( obj)
Value:
{ \
int res = obj.handle_invoke_map(is_notify, command, in_buff, buff_out, context, handled); \
if(handled) \
return res; \
}

Definition at line 284 of file levin_abstract_invoke2.h.

284#define CHAIN_INVOKE_MAP_TO_OBJ2(obj) \
285 { \
286 int res = obj.handle_invoke_map(is_notify, command, in_buff, buff_out, context, handled); \
287 if(handled) \
288 return res; \
289 }

◆ CHAIN_INVOKE_MAP_TO_OBJ_FORCE_CONTEXT

#define CHAIN_INVOKE_MAP_TO_OBJ_FORCE_CONTEXT ( obj,
context_type )
Value:
{ \
int res = obj.handle_invoke_map(is_notify, command, in_buff, buff_out, static_cast<context_type>(context), handled); \
if(handled) return res; \
}

Definition at line 291 of file levin_abstract_invoke2.h.

291#define CHAIN_INVOKE_MAP_TO_OBJ_FORCE_CONTEXT(obj, context_type) \
292 { \
293 int res = obj.handle_invoke_map(is_notify, command, in_buff, buff_out, static_cast<context_type>(context), handled); \
294 if(handled) return res; \
295 }

◆ CHAIN_LEVIN_INVOKE_MAP

#define CHAIN_LEVIN_INVOKE_MAP ( )
Value:
int invoke(int command, const epee::span<const uint8_t> in_buff, std::string& buff_out, epee::net_utils::connection_context_base& context) \
{ \
bool handled = false; \
return handle_invoke_map(false, command, in_buff, buff_out, context, handled); \
}

Definition at line 234 of file levin_abstract_invoke2.h.

234#define CHAIN_LEVIN_INVOKE_MAP() \
235 int invoke(int command, const epee::span<const uint8_t> in_buff, std::string& buff_out, epee::net_utils::connection_context_base& context) \
236 { \
237 bool handled = false; \
238 return handle_invoke_map(false, command, in_buff, buff_out, context, handled); \
239 }

◆ CHAIN_LEVIN_INVOKE_MAP2

#define CHAIN_LEVIN_INVOKE_MAP2 ( context_type)
Value:
int invoke(int command, const epee::span<const uint8_t> in_buff, std::string& buff_out, context_type& context) \
{ \
bool handled = false; \
return handle_invoke_map(false, command, in_buff, buff_out, context, handled); \
}

Definition at line 219 of file levin_abstract_invoke2.h.

219#define CHAIN_LEVIN_INVOKE_MAP2(context_type) \
220 int invoke(int command, const epee::span<const uint8_t> in_buff, std::string& buff_out, context_type& context) \
221 { \
222 bool handled = false; \
223 return handle_invoke_map(false, command, in_buff, buff_out, context, handled); \
224 }

◆ CHAIN_LEVIN_NOTIFY_MAP

#define CHAIN_LEVIN_NOTIFY_MAP ( )
Value:
int notify(int command, const epee::span<const uint8_t> in_buff, epee::net_utils::connection_context_base& context) \
{ \
bool handled = false; std::string fake_str;\
return handle_invoke_map(true, command, in_buff, fake_str, context, handled); \
}

Definition at line 241 of file levin_abstract_invoke2.h.

241#define CHAIN_LEVIN_NOTIFY_MAP() \
242 int notify(int command, const epee::span<const uint8_t> in_buff, epee::net_utils::connection_context_base& context) \
243 { \
244 bool handled = false; std::string fake_str;\
245 return handle_invoke_map(true, command, in_buff, fake_str, context, handled); \
246 }

◆ CHAIN_LEVIN_NOTIFY_MAP2

#define CHAIN_LEVIN_NOTIFY_MAP2 ( context_type)
Value:
int notify(int command, const epee::span<const uint8_t> in_buff, context_type& context) \
{ \
bool handled = false; std::string fake_str;\
return handle_invoke_map(true, command, in_buff, fake_str, context, handled); \
}

Definition at line 226 of file levin_abstract_invoke2.h.

226#define CHAIN_LEVIN_NOTIFY_MAP2(context_type) \
227 int notify(int command, const epee::span<const uint8_t> in_buff, context_type& context) \
228 { \
229 bool handled = false; std::string fake_str;\
230 return handle_invoke_map(true, command, in_buff, fake_str, context, handled); \
231 }

◆ CHAIN_LEVIN_NOTIFY_STUB

#define CHAIN_LEVIN_NOTIFY_STUB ( )
Value:
int notify(int command, const epee::span<const uint8_t> in_buff, epee::net_utils::connection_context_base& context) \
{ \
return -1; \
}

Definition at line 248 of file levin_abstract_invoke2.h.

248#define CHAIN_LEVIN_NOTIFY_STUB() \
249 int notify(int command, const epee::span<const uint8_t> in_buff, epee::net_utils::connection_context_base& context) \
250 { \
251 return -1; \
252 }

◆ ELECTRONEUM_DEFAULT_LOG_CATEGORY

#define ELECTRONEUM_DEFAULT_LOG_CATEGORY   "net"

Definition at line 36 of file levin_abstract_invoke2.h.

◆ END_INVOKE_MAP2

#define END_INVOKE_MAP2 ( )
Value:
LOG_ERROR("Unknown command:" << command); \
}
#define LEVIN_ERROR_CONNECTION_HANDLER_NOT_DEFINED
Definition levin_base.h:99
#define LOG_ERROR(x)
Definition misc_log_ex.h:98

Definition at line 298 of file levin_abstract_invoke2.h.

298#define END_INVOKE_MAP2() \
299 LOG_ERROR("Unknown command:" << command); \
300 return LEVIN_ERROR_CONNECTION_HANDLER_NOT_DEFINED; \
301 }

◆ HANDLE_INVOKE2

#define HANDLE_INVOKE2 ( command_id,
func,
type_name_in,
typename_out )
Value:
if(!is_notify && command_id == command) \
{handled=true;return epee::net_utils::buff_to_t_adapter<internal_owner_type_name, type_name_in, typename_out>(this, command, in_buff, buff_out, std::bind(func, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4), context);}
int buff_to_t_adapter(int command, const epee::span< const uint8_t > in_buff, std::string &buff_out, callback_t cb, t_context &context)

Definition at line 259 of file levin_abstract_invoke2.h.

259#define HANDLE_INVOKE2(command_id, func, type_name_in, typename_out) \
260 if(!is_notify && command_id == command) \
261 {handled=true;return epee::net_utils::buff_to_t_adapter<internal_owner_type_name, type_name_in, typename_out>(this, command, in_buff, buff_out, std::bind(func, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4), context);}

◆ HANDLE_INVOKE_T2

#define HANDLE_INVOKE_T2 ( COMMAND,
func )
Value:
if(!is_notify && COMMAND::ID == command) \
{handled=true;return epee::net_utils::buff_to_t_adapter<internal_owner_type_name, typename COMMAND::request, typename COMMAND::response>(command, in_buff, buff_out, std::bind(func, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4), context);}

Definition at line 263 of file levin_abstract_invoke2.h.

263#define HANDLE_INVOKE_T2(COMMAND, func) \
264 if(!is_notify && COMMAND::ID == command) \
265 {handled=true;return epee::net_utils::buff_to_t_adapter<internal_owner_type_name, typename COMMAND::request, typename COMMAND::response>(command, in_buff, buff_out, std::bind(func, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4), context);}

◆ HANDLE_NOTIFY2

#define HANDLE_NOTIFY2 ( command_id,
func,
type_name_in )
Value:
if(is_notify && command_id == command) \
{handled=true;return epee::net_utils::buff_to_t_adapter<internal_owner_type_name, type_name_in>(this, command, in_buff, std::bind(func, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3), context);}

Definition at line 268 of file levin_abstract_invoke2.h.

268#define HANDLE_NOTIFY2(command_id, func, type_name_in) \
269 if(is_notify && command_id == command) \
270 {handled=true;return epee::net_utils::buff_to_t_adapter<internal_owner_type_name, type_name_in>(this, command, in_buff, std::bind(func, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3), context);}

◆ HANDLE_NOTIFY_T2

#define HANDLE_NOTIFY_T2 ( NOTIFY,
func )
Value:
if(is_notify && NOTIFY::ID == command) \
{handled=true;return epee::net_utils::buff_to_t_adapter<internal_owner_type_name, typename NOTIFY::request>(this, command, in_buff, std::bind(func, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3), context);}

Definition at line 272 of file levin_abstract_invoke2.h.

272#define HANDLE_NOTIFY_T2(NOTIFY, func) \
273 if(is_notify && NOTIFY::ID == command) \
274 {handled=true;return epee::net_utils::buff_to_t_adapter<internal_owner_type_name, typename NOTIFY::request>(this, command, in_buff, std::bind(func, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3), context);}