ADTF
Loading...
Searching...
No Matches
streamtype_intf.h
Go to the documentation of this file.
1
7#pragma once
8
12#include <adtfbase/properties.h>
14
15#include <string>
16
17namespace adtf
18{
19namespace streaming
20{
21namespace ant
22{
23class IStreamType;
24
37{
38protected:
40 ~IStreamMetaType() = default;
41public:
42
43public:
45 ADTF_IID(IStreamMetaType, "streamtypedef.ant.streaming.adtf.iid");
46
53 virtual tResult GetMetaTypeName(base::ant::IString&& strTypeName) const = 0;
54
59 virtual adtf::util::tVersion GetVersion() const = 0;
60
68
78
87 virtual tResult IsCompatible(const IStreamType& oTypeToCheck, const IStreamType& oExpectedType) const = 0;
88};//class IStreamMetaType
89
96{
97protected:
99 ~IStreamType() = default;
100
101public:
103 ADTF_IID(IStreamType, "streamtype.ant.streaming.adtf.iid");
104
111 virtual tResult GetMetaTypeName(base::ant::IString&& strTypeName) const = 0;
112
117 virtual adtf::util::tVersion GetVersion() const = 0;
118
126
134
142};//class IStreamType
143
144}
145
146namespace spider
147{
148
156inline tResult is_equal(const ant::IStreamType& oLeftType, const ant::IStreamType& oRightType)
157{
158 if (&oLeftType == &oRightType)
159 {
161 }
162
163 if (IS_FAILED(oLeftType.GetMetaTypeName(base::cStringRedirect([&](const base::IString& strLeftValue) -> tResult
164 {
165 return oRightType.GetMetaTypeName(base::cStringRedirect([&](const base::IString& strRightValue) -> tResult
166 {
167 if (std::string_view(strLeftValue.Get(), strLeftValue.GetLength()) !=
168 std::string_view(strRightValue.Get(), strRightValue.GetLength()))
169 {
170 RETURN_ERROR(ERR_FAILED);
171 }
172 RETURN_NOERROR;
173 }));
174 }))))
175 {
176 RETURN_ERROR(ERR_FAILED);
177 }
178
180 RETURN_IF_FAILED(oLeftType.GetConfig(pPropertiesLeft));
182 RETURN_IF_FAILED(oRightType.GetConfig(pPropertiesRight));
183
184 return base::is_equal(*pPropertiesLeft, *pPropertiesRight);
185}
186
187}
188namespace ant
189{
190
199template<typename T>
200bool operator==(const IStreamType& oStreamType, T /* oValue */)
201{
202 adtf::util::cString strMetaTypeName;
203 oStreamType.GetMetaTypeName(adtf_string_intf(strMetaTypeName));
204 return strMetaTypeName.IsEqual(T::MetaTypeName);
205}
206
216template<typename T>
217bool operator!=(const IStreamType& oStreamType, T oValue)
218{
219 return !(oStreamType == oValue);
220}
221
230inline bool operator==(const IStreamType& oStreamTypeLeft, const IStreamType& oStreamTypeRight)
231{
232 return IS_OK(spider::is_equal(oStreamTypeLeft, oStreamTypeRight));
233}
234
243inline bool operator!=(const IStreamType& oStreamTypeLeft, const IStreamType& oStreamTypeRight)
244{
245 return !(oStreamTypeLeft == oStreamTypeRight);
246}
247
256template<typename VALUETYPE>
257tResult set_property(IStreamType& oStreamType, const char* strNameOfValue, VALUETYPE oValue)
258{
260 RETURN_IF_FAILED(oStreamType.GetConfig(pProperties));
261 return adtf::base::set_property<VALUETYPE>(*pProperties, strNameOfValue, oValue);
262}
263
271inline tResult set_property(IStreamType& oStreamType, const char* strNameOfValue, const char* poValue)
272{
274 RETURN_IF_FAILED(oStreamType.GetConfig(pProperties));
275 return adtf::base::set_property<adtf_util::cString>(*pProperties, strNameOfValue, adtf_util::cString(poValue));
276}
277
286template<typename VALUETYPE>
287VALUETYPE get_property(const IStreamType& oStreamType, const char* strNameOfValue, VALUETYPE oDefaultValue)
288{
290 if (IS_OK(oStreamType.GetConfig(pProperties)))
291 {
292 return adtf::base::get_property<VALUETYPE>(*pProperties, strNameOfValue, oDefaultValue);
293 }
294 else
295 {
296 return oDefaultValue;
297 }
298}
299
306template<typename VALUETYPE>
307VALUETYPE get_property(const IStreamType& oStreamType, const char* strNameOfValue)
308{
309 return get_property<VALUETYPE>(oStreamType, strNameOfValue, VALUETYPE());
310}
311
312} //namespace ant
313
314namespace flash
315{
316
324 const ant::IStreamType& oExpectedType);
325
334
343
351 const ant::IStreamType& oExpectedType);
352
358template <typename T>
360{
362 typedef char one;
364 typedef long two;
365
370 template <typename C> static one test( decltype(&C::MetaTypeName) ) ;
371
376 template <typename C> static two test(...);
377
378public:
382 enum { value = sizeof(test<T>(nullptr)) == sizeof(char) };
383};
384
385}
386
387namespace ant
388{
389
399template<typename T,
400 typename std::enable_if_t<flash::is_stream_meta_type<T>::value, int> = 0>
402 const T& oValue)
403{
404 if (!pStreamType.Get())
405 {
406 return false;
407 }
408 return *pStreamType.Get() == oValue;
409}
410
420template<typename T,
421 typename std::enable_if_t<flash::is_stream_meta_type<T>::value, int> = 0>
423 const T& oValue)
424{
425 return !(pStreamType == oValue);
426}
427
428}
429
430using ant::IStreamMetaType;
431using ant::IStreamType;
432using ant::get_property;
433using ant::set_property;
434using flash::is_compatible;
435using flash::is_stream_meta_type;
436using spider::is_equal;
437
438} //namespac streaming
439} // namespace adtf
#define IS_FAILED(s)
Check if result is failed.
Definition result.h:20
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_ERROR(code)
Return specific error code, which requires the calling function's return type to be tResult.
Definition result.h:42
#define IS_OK(s)
Check if result is OK.
Definition result.h:17
tBool IsEqual(const tError< ErrorCode > &i_oErrorVal) const noexcept
Check whether an error code is equal to the contained one.
Definition result.h:442
Definition string_intf.h:29
Definition string_intf.h:398
Defines access methods for a Stream Meta Type.
Definition streamtype_intf.h:37
~IStreamMetaType()=default
not destructable
virtual tResult GetDefaultConfig(ucom::ant::iobject_ptr< const base::ant::IProperties > &pProperties) const =0
Get the default configuration values for a Stream Type.
virtual tResult GetParent(ucom::ant::iobject_ptr< const IStreamMetaType > &pParent) const =0
This GetParent function is deprecated.
virtual tResult GetMetaTypeName(base::ant::IString &&strTypeName) const =0
Gets the unique meta type name.
virtual tResult IsCompatible(const IStreamType &oTypeToCheck, const IStreamType &oExpectedType) const =0
Compares the Stream Type oTypeToCheck based on this meta type. It alway depends on the concete implem...
virtual adtf::util::tVersion GetVersion() const =0
Get version of a Stream Type.
ADTF_IID(IStreamMetaType, "streamtypedef.ant.streaming.adtf.iid")
Interface ID for the Stream Typedef interface.
Defines access methods for the interface of a Stream Type.
Definition streamtype_intf.h:96
~IStreamType()=default
not destructable
virtual adtf::util::tVersion GetVersion() const =0
Get version of this instance of the StreamMetaType.
virtual tResult GetConfig(ucom::ant::iobject_ptr< base::ant::IProperties > &pProperties)=0
Get all properties of a Stream Type (read/write)
ADTF_IID(IStreamType, "streamtype.ant.streaming.adtf.iid")
Interface ID for the Stream Type interface.
virtual tResult GetMetaType(ucom::ant::iobject_ptr< const IStreamMetaType > &pMetaType) const =0
Get the Stream Meta Type definition of the Stream Type.
virtual tResult GetMetaTypeName(base::ant::IString &&strTypeName) const =0
Get the meta type name of this instance.
virtual tResult GetConfig(ucom::ant::iobject_ptr< const base::ant::IProperties > &pProperties) const =0
Get all properties of a Stream Type (read only) - const correct.
Definition streamtype_intf.h:360
Definition object_intf.h:33
virtual T * Get() const =0
Get raw pointer to shared object.
Base object pointer to realize binary compatible reference counting in interface methods.
Definition object_ptr_intf.h:112
Definition object_ptr.h:384
tResult is_equal(const ant::IProperties &oLeftProperties, const ant::IProperties &oRightProperties)
VALUETYPE get_property(const IConfiguration &oConfiguration, const char *strNameOfValue, VALUETYPE oDefaultValue)
Get the property content converted to the VALUETYPE.
Definition configuration.h:291
tResult set_property(IConfiguration &oConfiguration, const char *strNameOfValue, VALUETYPE oValue)
Set the property.
Definition configuration.h:327
Namespace for all functionality of the ADTF Streaming SDK provided since v3.0.
Definition bindingproxyoutport.h:16
bool operator==(const tStreamImageFormat &sLeft, const tStreamImageFormat &sRight)
VALUETYPE get_property(const IStreamType &oStreamType, const char *strNameOfValue, VALUETYPE oDefaultValue)
Definition streamtype_intf.h:287
tResult set_property(IStreamType &oStreamType, const char *strNameOfValue, VALUETYPE oValue)
Definition streamtype_intf.h:257
bool operator!=(const tStreamImageFormat &sLeft, const tStreamImageFormat &sRight)
tResult is_compatible(const ant::IStreamType &oCheckedType, const ant::IStreamType &oExpectedType)
Namespace for all functionality of the ADTF Streaming SDK provided since v3.18.
Definition graph_element_editors.h:79
tResult is_equal(const ant::IStreamType &oLeftType, const ant::IStreamType &oRightType)
Definition streamtype_intf.h:156
Namespace for the ADTF Streaming SDK.
Definition bindingproxyinport.h:14
ant::IObject IObject
Alias always bringing the latest version of ant::IObject into scope.
Definition object_intf.h:109
Namespace for all functionality provided by ADTF and its SDKs.
Definition adtf_client_connector.h:14
#define adtf_string_intf(__string__)
Definition string_intf.h:465