BAOS SDK v2  1.0.1
An SDK providing access to IP-BAOS devices through BAOS binary protocol version 2.x
Indication.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2002-2023 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_INDICATION_H__
14 #define __BAOSLIB_INDICATION_H__
15 
16 #include "baos/BaosLib_export.h"
17 #include "baos/config.h"
18 #include "baos/protocol/Defines.h"
19 #include "baos/protocol/Response.h"
20 #include "wzcpp/features/concurrent/concurrent_queue.h"
21 
23 #include <future>
24 #include <memory>
25 #include <variant>
27 
28 
34 namespace wz::baos::protocol
35 {
36 
37 using IndPromise = std::promise<protocol::BaseResponse>;
38 using IndFuture = std::future<protocol::BaseResponse>;
39 
40 
46 class BAOSLIB_EXPORT IndicationEvent
47 {
48 public:
49  using UPtr = std::unique_ptr<IndicationEvent>;
50  using EventDataType =
51  std::variant<protocol::ServerItems, protocol::DatapointValueStates>;
52 
54  enum class Type
55  {
56  SERVERITEM,
57  DP_VALUE,
58  UNKNOWN
59  };
60  IndicationEvent() = default;
61 
70  IndicationEvent(Type eventT, EventDataType&& pkt, IndPromise&& prom, std::uint64_t mID = 0)
71  : eventType{eventT},
72  msgID{mID},
73  indPromise{std::move(prom)}
74  {
75  data_ = std::move(pkt);
76  }
77 
78 public:
79  Type eventType{Type::UNKNOWN};
80  std::uint64_t msgID{0};
82 
83  // private:
85 };
86 
87 
89 inline std::string toString(IndicationEvent::Type typ)
90 {
91  switch (typ)
92  {
94  return "SERVERITEM";
96  return "DP_VALUE";
97  default:
98  return "Unhandled IOEvent type";
99  }
100 }
101 
102 
104  wzcpp::ConcurrentDeque<IndicationEvent>;
105 
106 } // namespace wz::baos::protocol
107 
108 #endif //__BAOSLIB_INDICATION_H__
Global BAOS protocol defines and types.
Classes regarding response telegrams.
An Indication event.
Definition: Indication.h:47
std::variant< protocol::ServerItems, protocol::DatapointValueStates > EventDataType
The possible different payload types.
Definition: Indication.h:51
Type
The indication types.
Definition: Indication.h:55
@ SERVERITEM
A server item indication.
@ DP_VALUE
A datapoint value change indication.
EventDataType data_
The payload.
Definition: Indication.h:84
std::unique_ptr< IndicationEvent > UPtr
Alias for an unique pointer from this class.
Definition: Indication.h:49
IndicationEvent(Type eventT, EventDataType &&pkt, IndPromise &&prom, std::uint64_t mID=0)
Construct a new Indication Event object.
Definition: Indication.h:70
IndicationEvent()=default
The default constructor.
IndPromise indPromise
The indication promise.
Definition: Indication.h:81
Global types and configuration for the whole SDK.
Groups BAOS binary protocol specific types , defines and classes for Indications, Responses etc.
Definition: Defines.h:32
std::string toString(IndicationEvent::Type typ)
Convert IndicationEvent into human readable string.
Definition: Indication.h:89
std::future< protocol::BaseResponse > IndFuture
Strong type for a indication future.
Definition: Indication.h:38
wzcpp::ConcurrentDeque< IndicationEvent > BaosIndQueue
Alias for a wzcpp::ConcurrentDeque holding indication events.
Definition: Indication.h:104
std::promise< protocol::BaseResponse > IndPromise
Strong type for a indication promise.
Definition: Indication.h:37