BAOS SDK v2  1.2.1
An SDK providing access to IP-BAOS devices through BAOS binary protocol version 2.x
IOEvent.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2002-2026 WEINZIERL ENGINEERING GmbH
3 // All rights reserved.
4 //
5 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7 // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
8 // SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY,
9 // WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
10 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
11 //
12 
13 #ifndef __BAOSLIB_EVENT_H__
14 #define __BAOSLIB_EVENT_H__
15 
16 #include "baos/BaosLib_export.h"
17 #include "baos/config.h"
18 #include "baos/ip/IpGeneral.h"
19 #include "baos/protocol/Response.h"
20 #include "wzcpp/features/concurrent/concurrent_queue.h"
21 
23 #include <array>
24 #include <future>
25 #include <memory>
26 #include <optional>
27 #include <variant>
29 
35 namespace wz::baos
36 {
37 
43 class BAOSLIB_EXPORT IOEvent
44 {
45 public:
46  using TimerIdList = std::vector<std::uint64_t>;
47  using UPtr = std::unique_ptr<IOEvent>;
48  using EventDataType = std::variant<std::monostate, ip::Ip4SocketAddress,
49  std::unique_ptr<Buffer>, TimerIdList>;
51 
53  enum class Type
54  {
55  UNKNOWN,
56  OPEN,
57  CLOSE,
58  SOCKETERROR,
59  RESPONSETIMEOUT,
60  HEARTBEAT,
61  RX_PACKET,
62  TX_PACKET,
63  STACK_CONNECT_RESULT,
64  STACK_DISCONNECT_RESULT,
65  TIMER_ELAPSED,
66 
67  };
68  IOEvent() = default;
69 
78  IOEvent(Type eventT, EventDataType&& pkt, protocol::ResponsePromise&& prom, std::uint64_t mID = 0);
79 
80 public:
81  Type eventType{Type::UNKNOWN};
82  std::uint64_t msgID{0};
84  bool promiseMoved{false};
86 };
87 
94 BAOSLIB_EXPORT std::string toString(IOEvent::Type typ);
95 
96 using BaosMsgQueue = wzcpp::ConcurrentDeque<IOEvent>;
97 using TransportMsgQueue = wzcpp::ConcurrentDeque<IOEvent>;
98 } // namespace wz::baos
99 
100 #endif //__BAOSLIB_TCP_IO_H__
Provides the structures for devices with IP capabilities.
Classes regarding response telegrams.
Represents an IOEvent.
Definition: IOEvent.h:44
std::unique_ptr< IOEvent > UPtr
An alias for an unique pointer to an IOEvent.
Definition: IOEvent.h:47
Type
The different possible event types.
Definition: IOEvent.h:54
EventDataType data_
The payload/data for this event.
Definition: IOEvent.h:85
IOEvent(Type eventT, EventDataType &&pkt, protocol::ResponsePromise &&prom, std::uint64_t mID=0)
Construct a new IOEvent object.
IOEvent()=default
Default constructor, generating an empty IOEvent.
std::variant< std::monostate, ip::Ip4SocketAddress, std::unique_ptr< Buffer >, TimerIdList > EventDataType
datatypes inside an IOEvent
Definition: IOEvent.h:50
protocol::ResponsePromise responsePromise
Stores the response promise to resolve later.
Definition: IOEvent.h:83
Global types and configuration for the whole SDK.
std::promise< BaseResponse::SPtr > ResponsePromise
Definition: Response.h:95
Global BAOS sdk namespace.
Definition: config.h:69
wzcpp::ConcurrentDeque< IOEvent > BaosMsgQueue
Alias for a concurrent queue with IOEvents.
Definition: IOEvent.h:96
wzcpp::ConcurrentDeque< IOEvent > TransportMsgQueue
Alias for a concurrent queue with IOEvents used by the transport layer.
Definition: IOEvent.h:97
Represent the pair of IP address as string in the form "10.0.0.1020" and a port.
Definition: IpGeneral.h:34