Zserio C++17 runtime library 1.3.0
Built for Zserio 2.20.0
Loading...
Searching...
No Matches
IService.h
Go to the documentation of this file.
1#ifndef ZSERIO_ISERVICE_H_INC
2#define ZSERIO_ISERVICE_H_INC
3
4#include <string_view>
5
8#include "zserio/Span.h"
9#include "zserio/Types.h"
10#include "zserio/Vector.h"
11#include "zserio/View.h"
12
13namespace zserio
14{
15
21template <typename ALLOC = std::allocator<uint8_t>>
23{
24public:
26 virtual ~IBasicServiceData() = default;
27
34
40 virtual Span<const uint8_t> getData() const = 0;
41};
42
44template <typename ALLOC = std::allocator<uint8_t>>
45using IBasicServiceDataPtr = std::shared_ptr<IBasicServiceData<ALLOC>>;
46
53template <typename ZSERIO_OBJECT, typename ALLOC = std::allocator<uint8_t>>
55{
56public:
64 m_object(object),
65 m_introspectable(introspectable(View(m_object), allocator)),
66 m_data(allocator)
67 {}
68
76 m_object(std::move(object)),
77 m_introspectable(introspectable(View(m_object), allocator)),
78 m_data(allocator)
79 {}
80
82 {
83 return m_introspectable;
84 }
85
92 {
93 if (m_introspectable && m_data.getBitSize() == 0)
94 {
95 // lazy initialization
96 m_data = m_introspectable->serialize(m_data.get_allocator());
97 }
98 return m_data.getData();
99 }
100
101private:
102 ZSERIO_OBJECT m_object;
104 mutable BasicBitBuffer<ALLOC> m_data;
105};
106
110template <typename ALLOC = std::allocator<uint8_t>>
112{
113public:
120 template <typename ZSERIO_OBJECT>
121 explicit BasicObjectServiceData(const ZSERIO_OBJECT& object, const ALLOC& allocator = ALLOC()) :
123 {}
124
126 {
127 return nullptr;
128 }
129
131 {
132 return m_data.getData();
133 }
134
135private:
137};
138
142template <typename ALLOC = std::allocator<uint8_t>>
144{
145public:
154
161 m_data(std::move(rawData))
162 {}
163
165 {
166 return nullptr;
167 }
168
170 {
171 return m_data;
172 }
173
174private:
176};
177
183template <typename ALLOC = std::allocator<uint8_t>>
185{
186public:
195
197 {
198 return nullptr;
199 }
200
202 {
203 return m_data;
204 }
205
206private:
207 Span<const uint8_t> m_data;
208};
209
213template <typename ALLOC = std::allocator<uint8_t>>
215{
216public:
217 virtual ~IBasicService() = default;
218
231 std::string_view methodName, Span<const uint8_t> requestData, void* context) = 0;
232};
233
237template <typename ALLOC = std::allocator<uint8_t>>
239{
240public:
241 virtual ~IBasicServiceClient() = default;
242
255 std::string_view methodName, const IBasicServiceData<ALLOC>& requestData, void* context) = 0;
256};
257
268template <typename ZSERIO_OBJECT>
275} // namespace zserio
276
277#endif // ifndef ZSERIO_ISERVICE_H_INC
BasicIntrospectableServiceData(const ZSERIO_OBJECT &object, const ALLOC &allocator=ALLOC())
Definition IService.h:63
BasicIntrospectableServiceData(ZSERIO_OBJECT &&object, const ALLOC &allocator=ALLOC())
Definition IService.h:75
Span< const uint8_t > getData() const override
Definition IService.h:91
IBasicIntrospectableViewConstPtr< ALLOC > getIntrospectable() const override
Definition IService.h:81
Span< const uint8_t > getData() const override
Definition IService.h:130
BasicObjectServiceData(const ZSERIO_OBJECT &object, const ALLOC &allocator=ALLOC())
Definition IService.h:121
IBasicIntrospectableViewConstPtr< ALLOC > getIntrospectable() const override
Definition IService.h:125
BasicRawServiceDataHolder(Vector< uint8_t, ALLOC > &&rawData)
Definition IService.h:160
IBasicIntrospectableViewConstPtr< ALLOC > getIntrospectable() const override
Definition IService.h:164
BasicRawServiceDataHolder(const Vector< uint8_t, ALLOC > &rawData)
Definition IService.h:151
Span< const uint8_t > getData() const override
Definition IService.h:169
IBasicIntrospectableViewConstPtr< ALLOC > getIntrospectable() const override
Definition IService.h:196
Span< const uint8_t > getData() const override
Definition IService.h:201
BasicRawServiceDataView(zserio::Span< const uint8_t > rawData)
Definition IService.h:192
virtual ~IBasicServiceClient()=default
virtual Vector< uint8_t, ALLOC > callMethod(std::string_view methodName, const IBasicServiceData< ALLOC > &requestData, void *context)=0
virtual Span< const uint8_t > getData() const =0
virtual IBasicIntrospectableViewConstPtr< ALLOC > getIntrospectable() const =0
virtual ~IBasicServiceData()=default
virtual IBasicServiceDataPtr< ALLOC > callMethod(std::string_view methodName, Span< const uint8_t > requestData, void *context)=0
virtual ~IBasicService()=default
BasicBitBuffer< ALLOC > serialize(const T &data, const ALLOC &allocator, ARGS &&... arguments)
IBasicIntrospectableViewConstPtr< ALLOC > introspectable(const View< T > &view, const ALLOC &allocator=ALLOC())
std::shared_ptr< IBasicServiceData< ALLOC > > IBasicServiceDataPtr
Definition IService.h:45