Lely core libraries 2.3.4
gw_txt.hpp
Go to the documentation of this file.
1
23#ifndef LELY_CO_GW_TXT_HPP_
24#define LELY_CO_GW_TXT_HPP_
25
26#if !defined(__cplusplus) || LELY_NO_CXX
27#error "include <lely/co/gw_txt.h> for the C interface"
28#endif
29
30#include <lely/util/c_type.hpp>
31
32namespace lely {
33class COGWTxt;
34}
37
38#include <lely/co/gw_txt.h>
39
40namespace lely {
41
43template <>
45 typedef __co_gw_txt value_type;
46 typedef value_type& reference;
47 typedef const value_type& const_reference;
48 typedef value_type* pointer;
49 typedef const value_type* const_pointer;
50
51 static void*
52 alloc() noexcept {
53 return __co_gw_txt_alloc();
54 }
55 static void
56 free(void* ptr) noexcept {
57 __co_gw_txt_free(ptr);
58 }
59
60 static pointer
61 init(pointer p) noexcept {
62 return __co_gw_txt_init(p);
63 }
64 static void
65 fini(pointer p) noexcept {
66 __co_gw_txt_fini(p);
67 }
68};
69
71class COGWTxt : public incomplete_c_type<__co_gw_txt> {
73
74 public:
75 COGWTxt() : c_base() {}
76
77 int
78 iec() noexcept {
79 return co_gw_txt_iec(this);
80 }
81
82 ::std::size_t
83 pending() const noexcept {
84 return co_gw_txt_pending(this);
85 }
86
87 int
88 recv(const co_gw_srv* srv) noexcept {
89 return co_gw_txt_recv(this, srv);
90 }
91
92 void
93 getRecvFunc(co_gw_txt_recv_func_t** pfunc, void** pdata) const noexcept {
95 }
96
97 void
98 setRecvFunc(co_gw_txt_recv_func_t* func, void* data) noexcept {
99 co_gw_txt_set_recv_func(this, func, data);
100 }
101
102 template <class F>
103 void
104 setRecvFunc(F* f) noexcept {
106 static_cast<void*>(f));
107 }
108
110 void
111 setRecvFunc(C* obj) noexcept {
113 static_cast<void*>(obj));
114 }
115
116 int
117 send(const char* begin, const char* end = 0, floc* at = 0) noexcept {
118 return co_gw_txt_send(this, begin, end, at);
119 }
120
121 void
122 getSendFunc(co_gw_txt_send_func_t** pfunc, void** pdata) const noexcept {
124 }
125
126 void
127 setSendFunc(co_gw_txt_send_func_t* func, void* data) noexcept {
128 co_gw_txt_set_send_func(this, func, data);
129 }
130
131 template <class F>
132 void
133 setSendFunc(F* f) noexcept {
135 static_cast<void*>(f));
136 }
137
139 void
140 setSendFunc(C* obj) noexcept {
142 static_cast<void*>(obj));
143 }
144
145 protected:
146 ~COGWTxt() = default;
147};
148
149} // namespace lely
150
151#endif // !LELY_CO_GW_TXT_HPP_
This header file is part of the utilities library; it contains the C to C++ interface declarations.
An opaque CANopen ASCII gateway client type.
Definition gw_txt.hpp:71
A CANopen value.
Definition val.hpp:42
The base class for a C++ interface to an incomplete C type.
Definition c_type.hpp:249
This header file is part of the CANopen library; it contains the ASCII gateway declarations (see CiA ...
void co_gw_txt_set_send_func(co_gw_txt_t *gw, co_gw_txt_send_func_t *func, void *data)
Sets the callback function used to send requests from the user to a CANopen gateway.
Definition gw_txt.c:782
int co_gw_txt_recv_func_t(const char *txt, void *data)
The type of a CANopen ASCII gateway receive callback function, invoked when when an indication of con...
Definition gw_txt.h:58
void co_gw_txt_get_recv_func(const co_gw_txt_t *gw, co_gw_txt_recv_func_t **pfunc, void **pdata)
Retrieves the callback function used to forward indications and confirmations received by a CANopen g...
Definition gw_txt.c:486
int co_gw_txt_send_func_t(const struct co_gw_req *req, void *data)
The type of a CANopen ASCII gateway send callback function, invoked when a request has been issued by...
Definition gw_txt.h:70
void co_gw_txt_get_send_func(const co_gw_txt_t *gw, co_gw_txt_send_func_t **pfunc, void **pdata)
Retrieves the callback function used to send requests from the user to a CANopen gateway.
Definition gw_txt.c:770
size_t co_gw_txt_send(co_gw_txt_t *gw, const char *begin, const char *end, struct floc *at)
Sends a user request to a CANopen gateway.
Definition gw_txt.c:498
void co_gw_txt_set_recv_func(co_gw_txt_t *gw, co_gw_txt_recv_func_t *func, void *data)
Sets the callback function used to forward indications and confirmations received by a CANopen gatewa...
Definition gw_txt.c:760
int co_gw_txt_recv(co_gw_txt_t *gw, const struct co_gw_srv *srv)
Receives and forwards an indication or confirmation from a CANopen gateway.
Definition gw_txt.c:389
int co_gw_txt_iec(co_gw_txt_t *gw)
Returns (and clears) the last internal error code.
Definition gw_txt.c:371
size_t co_gw_txt_pending(const co_gw_txt_t *gw)
Returns the number of pending (i.e., unconfirmed) requests.
Definition gw_txt.c:381
lely::COGWTxt co_gw_txt_t
An opaque CANopen ASCII gateway client type.
Definition gw_txt.hpp:36
A CANopen ASCII gateway.
Definition gw_txt.c:45
The common parameters of a CANopen gateway service.
Definition gw.h:263
A location in a text file.
Definition diag.h:39
A class template supplying a uniform interface to certain attributes of C types.
Definition c_type.hpp:350