pars 0.2.1
Loading...
Searching...
No Matches
pipe.h
Go to the documentation of this file.
1/*
2Copyright (c) 2025 Giuseppe Roberti.
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without modification,
6are permitted provided that the following conditions are met:
7
81. Redistributions of source code must retain the above copyright notice, this
9list of conditions and the following disclaimer.
10
112. Redistributions in binary form must reproduce the above copyright notice,
12this list of conditions and the following disclaimer in the documentation and/or
13other materials provided with the distribution.
14
153. Neither the name of the copyright holder nor the names of its contributors
16may be used to endorse or promote products derived from this software without
17specific prior written permission.
18
19THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29*/
30#pragma once
31
32#include "nngxx/pipe.h"
33#include "nngxx/socket.h"
34
35#include "pars/fmt/nng.h"
36
37#include <format>
38
39namespace pars::net
40{
41
42class pipe : public nngxx::pipe_view
43{
44public:
46 : id_m{0}
47 , socket_id_m{0}
48 {
49 }
50
51 pipe(nngxx::pipe_view& pv) noexcept
53 , id_m{pv.id()}
54 , socket_id_m{pv.get_socket().id()}
55 {
56 }
57
58 int id() const noexcept { return id_m; }
59
60 int socket_id() const { return socket_id_m; }
61
62 operator bool() { return nngxx::pipe_view::operator bool(); }
63
64 auto format_to(std::format_context& ctx) const -> decltype(ctx.out())
65 {
66 return std::format_to(ctx.out(), "{}",
67 static_cast<nngxx::pipe_view>(*this));
68 }
69
70private:
71 const int id_m;
72
73 const int socket_id_m;
74};
75
76} // namespace pars::net
int id() const noexcept
Definition pipe.h:58
pipe(nngxx::pipe_view &pv) noexcept
Definition pipe.h:51
auto format_to(std::format_context &ctx) const -> decltype(ctx.out())
Definition pipe.h:64
int socket_id() const
Definition pipe.h:60
clev::iface< nng_pipe > pipe_view
Definition pipe.h:37