pars 0.2.1.99
Loading...
Searching...
No Matches
pars::net::tool_view Class Reference

Represents an nng_socket or nng_ctx view. More...

#include <tool_view.h>

Public Member Functions

 tool_view (nngxx::ctx_view c)
 Construct a tool_view from an nng_ctx view.
 
 tool_view (nngxx::socket_view s)
 Construct a tool_view from an nng_socket view.
 
const std::type_info & type () const
 Get the std::type_info of the underlying variant.
 
const char * who () const
 Get a string that represents the type of the underlying variant.
 
int id () const
 The id of the underlying variant.
 
auto format_to (std::format_context &ctx) const -> decltype(ctx.out())
 Formatter for debugging purpose.
 

Detailed Description

Represents an nng_socket or nng_ctx view.

Definition at line 47 of file tool_view.h.

Constructor & Destructor Documentation

◆ tool_view() [1/2]

pars::net::tool_view::tool_view ( nngxx::ctx_view c)
inlineexplicit

Construct a tool_view from an nng_ctx view.

Definition at line 51 of file tool_view.h.

52 : tool_m{c}
53 {
54 }

◆ tool_view() [2/2]

pars::net::tool_view::tool_view ( nngxx::socket_view s)
inlineexplicit

Construct a tool_view from an nng_socket view.

Definition at line 57 of file tool_view.h.

58 : tool_m{s}
59 {
60 }

Member Function Documentation

◆ format_to()

auto pars::net::tool_view::format_to ( std::format_context & ctx) const -> decltype(ctx.out())
inline

Formatter for debugging purpose.

Definition at line 78 of file tool_view.h.

79 {
80 return std::format_to(ctx.out(), "{} #{}", who(), id());
81 }
const char * who() const
Get a string that represents the type of the underlying variant.
Definition tool_view.h:69
clev::own< nng_ctx > ctx
Definition ctx.h:39

References who().

Here is the call graph for this function:

◆ id()

int pars::net::tool_view::id ( ) const
inline

The id of the underlying variant.

Definition at line 72 of file tool_view.h.

73 {
74 return std::visit([](const auto& t) { return t.id(); }, tool_m);
75 }

Referenced by pars::net::context_registry::of().

Here is the caller graph for this function:

◆ type()

const std::type_info & pars::net::tool_view::type ( ) const
inline

Get the std::type_info of the underlying variant.

Definition at line 63 of file tool_view.h.

64 {
65 return std::visit([](auto& t) { return std::ref(typeid(t)); }, tool_m);
66 }

Referenced by pars::net::context_registry::of().

Here is the caller graph for this function:

◆ who()

const char * pars::net::tool_view::who ( ) const
inline

Get a string that represents the type of the underlying variant.

Definition at line 69 of file tool_view.h.

69{ return tool_m.index() == 0 ? "Context" : "Socket"; }

Referenced by format_to().

Here is the caller graph for this function:

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