ADTF
Loading...
Searching...
No Matches
streamitem_intf.h
Go to the documentation of this file.
1
7#pragma once
8
9#include "sample_intf.h"
10#include "streamtype_intf.h"
11
12#include <variant>
13
14namespace adtf
15{
16namespace streaming
17{
18namespace ant
19{
20
25{
26protected:
28 ~IStreamItem() = default;
29
30public:
32 enum class tType : uint32_t
33 {
34 Undefined = 0,
38 Sample = 2,
39 };
40
46 virtual tType GetType() const = 0;
47
55
65
75
87
99};
100
105{
106private:
107 std::variant<std::monostate,
110 m_oPtr;
111
112public:
114 constexpr cStreamItem() noexcept
115 {
116 }
117
120 {
121 switch (oItem.GetType())
122 {
124 {
125 auto& pTypePtr = m_oPtr.emplace<adtf::ucom::ant::object_ptr<const IStreamType>>();
126 THROW_IF_FAILED(oItem.GetStreamType(pTypePtr));
127 break;
128 }
129 case tType::Sample:
130 {
131 auto& pSamplePtr = m_oPtr.emplace<adtf::ucom::ant::object_ptr<const ISample>>();
132 THROW_IF_FAILED(oItem.GetSample(pSamplePtr));
133 break;
134 }
135 default:
136 {
137 break;
138 }
139 }
140 }
141
144 constexpr cStreamItem(const ucom::ant::iobject_ptr<const ISample>& pSample) noexcept:
145 m_oPtr(std::in_place_type<adtf::ucom::ant::object_ptr<const ISample>>, pSample)
146 {
147 }
148
151 constexpr cStreamItem(const ucom::ant::iobject_ptr<const IStreamType>& pStreamType) noexcept:
152 m_oPtr(std::in_place_type<adtf::ucom::ant::object_ptr<const IStreamType>>, pStreamType)
153 {
154 }
155
157 cStreamItem(const cStreamItem& oOther) noexcept: m_oPtr(oOther.m_oPtr)
158 {
159 }
160
161 cStreamItem(cStreamItem&& oOther) noexcept: m_oPtr(std::move(oOther.m_oPtr))
162 {
163 }
164
168
169 tType GetType() const noexcept override
170 {
171 if (std::holds_alternative<adtf::ucom::ant::object_ptr<const IStreamType>>(m_oPtr))
172 {
173 return tType::StreamType;
174 }
175 else if (std::holds_alternative<adtf::ucom::ant::object_ptr<const ISample>>(m_oPtr))
176 {
177 return tType::Sample;
178 }
179 else
180 {
181 return tType::Undefined;
182 }
183 }
184
186 {
187 if (std::holds_alternative<adtf::ucom::ant::object_ptr<const IStreamType>>(m_oPtr))
188 {
189 RETURN_IF_FAILED(pObject.Reset(std::get<adtf::ucom::ant::object_ptr<const IStreamType>>(m_oPtr)));
191 }
192 else if (std::holds_alternative<adtf::ucom::ant::object_ptr<const ISample>>(m_oPtr))
193 {
194 RETURN_IF_FAILED(pObject.Reset(std::get<adtf::ucom::ant::object_ptr<const ISample>>(m_oPtr)));
196 }
197 else
198 {
199 RETURN_ERROR(ERR_INVALID_TYPE);
200 }
201 }
202
204 {
205 if (std::holds_alternative<adtf::ucom::ant::object_ptr<const ISample>>(m_oPtr))
206 {
207 RETURN_IF_FAILED(pSample.Reset(std::get<adtf::ucom::ant::object_ptr<const ISample>>(m_oPtr)));
209 }
210 else
211 {
212 RETURN_ERROR(ERR_INVALID_TYPE);
213 }
214 }
215
217 {
218 if (std::holds_alternative<adtf::ucom::ant::object_ptr<const IStreamType>>(m_oPtr))
219 {
220 RETURN_IF_FAILED(pStreamType.Reset(std::get<adtf::ucom::ant::object_ptr<const IStreamType>>(m_oPtr)));
222 }
223 else
224 {
225 RETURN_ERROR(ERR_INVALID_TYPE);
226 }
227 }
228
230 {
231 RETURN_IF_THROWS(*this = cStreamItem(pSample));
233 }
234
236 {
237 RETURN_IF_THROWS(*this = cStreamItem(pStreamType));
239 }
240
247 tResult CopyTo(IStreamItem& oDest) const noexcept
248 {
249 if (std::holds_alternative<adtf::ucom::ant::object_ptr<const IStreamType>>(m_oPtr))
250 {
251 RETURN_IF_FAILED(oDest.SetStreamType(std::get<adtf::ucom::ant::object_ptr<const IStreamType>>(m_oPtr)));
253 }
254 else if (std::holds_alternative<adtf::ucom::ant::object_ptr<const ISample>>(m_oPtr))
255 {
256 RETURN_IF_FAILED(oDest.SetSample(std::get<adtf::ucom::ant::object_ptr<const ISample>>(m_oPtr)));
258 }
259 else
260 {
261 RETURN_ERROR(ERR_INVALID_TYPE);
262 }
263 }
264};
265} // namespace ant
266
268using ant::IStreamItem;
269using ant::cStreamItem;
270
271} // namespace streaming
272} // namespace adtf
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
Definition result.h:736
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
Definition result.h:29
#define RETURN_IF_THROWS(s)
if the expression throws an exception, returns a tResult containing the exception information.
Definition result.h:123
#define RETURN_ERROR(code)
Return specific error code, which requires the calling function's return type to be tResult.
Definition result.h:42
#define THROW_IF_FAILED(s)
throws if the expression returns a failed tResult
Definition result.h:88
Definition streamitem_intf.h:25
~IStreamItem()=default
not destructable
virtual tType GetType() const =0
virtual tResult GetSample(ucom::ant::iobject_ptr< const ISample > &pSample) const =0
tType
serval types are defined
Definition streamitem_intf.h:33
@ StreamType
item is a IStreamType. Mind: All StreamType changes will be queue too !!
Definition streamitem_intf.h:36
@ Sample
item is a queue item contains a ISample
Definition streamitem_intf.h:38
virtual tResult GetStreamType(ucom::ant::iobject_ptr< const IStreamType > &pStreamType) const =0
virtual tResult SetSample(const ucom::ant::iobject_ptr< const ISample > &pSample)=0
virtual tResult GetObject(ucom::ant::iobject_ptr< const ucom::ant::IObject > &pObject) const =0
virtual tResult SetStreamType(const ucom::ant::iobject_ptr< const IStreamType > &pStreamType)=0
cStreamItem(const IStreamItem &oItem)
Definition streamitem_intf.h:119
cStreamItem & operator=(const cStreamItem &)=default
copy operator
tResult SetSample(const ucom::ant::iobject_ptr< const ISample > &pSample) noexcept override
Definition streamitem_intf.h:229
constexpr cStreamItem(const ucom::ant::iobject_ptr< const ISample > &pSample) noexcept
Definition streamitem_intf.h:144
tResult GetObject(ucom::ant::iobject_ptr< const ucom::ant::IObject > &pObject) const noexcept override
Definition streamitem_intf.h:185
constexpr cStreamItem() noexcept
CTOR.
Definition streamitem_intf.h:114
tResult SetStreamType(const ucom::ant::iobject_ptr< const IStreamType > &pStreamType) noexcept override
Definition streamitem_intf.h:235
tResult GetStreamType(ucom::ant::iobject_ptr< const IStreamType > &pStreamType) const noexcept override
Definition streamitem_intf.h:216
tType GetType() const noexcept override
Definition streamitem_intf.h:169
tResult GetSample(ucom::ant::iobject_ptr< const ISample > &pSample) const noexcept override
Definition streamitem_intf.h:203
cStreamItem & operator=(cStreamItem &&)=default
move operator
cStreamItem(const cStreamItem &oOther) noexcept
copy CTOR
Definition streamitem_intf.h:157
constexpr cStreamItem(const ucom::ant::iobject_ptr< const IStreamType > &pStreamType) noexcept
Definition streamitem_intf.h:151
tResult CopyTo(IStreamItem &oDest) const noexcept
Definition streamitem_intf.h:247
cStreamItem(cStreamItem &&oOther) noexcept
move CTOR
Definition streamitem_intf.h:161
Base object pointer to realize binary compatible reference counting in interface methods.
Definition object_ptr_intf.h:112
Definition object_ptr.h:384
Namespace for all functionality of the ADTF Streaming SDK provided since v3.0.
Definition bindingproxyoutport.h:16
Namespace for the ADTF Streaming SDK.
Definition bindingproxyinport.h:14
Namespace for all functionality provided by ADTF and its SDKs.
Definition adtf_client_connector.h:14