ADTF
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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
39{
40protected:
42 ~IStreamMetaType() = default;
43public:
44
45public:
47 ADTF_IID(IStreamMetaType, "streamtypedef.ant.streaming.adtf.iid");
48
55 virtual tResult GetMetaTypeName(base::ant::IString&& strTypeName) const = 0;
56
61 virtual adtf::util::tVersion GetVersion() const = 0;
62
70
80
93 virtual tResult IsCompatible(const IStreamType& oTypeToCheck, const IStreamType& oExpectedType) const = 0;
94};//class IStreamMetaType
95
103{
104protected:
106 ~IStreamType() = default;
107
108public:
110 ADTF_IID(IStreamType, "streamtype.ant.streaming.adtf.iid");
111
118 virtual tResult GetMetaTypeName(base::ant::IString&& strTypeName) const = 0;
119
124 virtual adtf::util::tVersion GetVersion() const = 0;
125
133
141
149};//class IStreamType
150
151}
152
153namespace spider
154{
155
163inline tResult is_equal(const ant::IStreamType& oLeftType, const ant::IStreamType& oRightType)
164{
165 if (&oLeftType == &oRightType)
166 {
168 }
169
170 if (IS_FAILED(oLeftType.GetMetaTypeName(base::cStringRedirect([&](const base::IString& strLeftValue) -> tResult
171 {
172 return oRightType.GetMetaTypeName(base::cStringRedirect([&](const base::IString& strRightValue) -> tResult
173 {
174 if (std::string_view(strLeftValue.Get(), strLeftValue.GetLength()) !=
175 std::string_view(strRightValue.Get(), strRightValue.GetLength()))
176 {
177 RETURN_ERROR(ERR_FAILED);
178 }
179 RETURN_NOERROR;
180 }));
181 }))))
182 {
183 RETURN_ERROR(ERR_FAILED);
184 }
185
187 RETURN_IF_FAILED(oLeftType.GetConfig(pPropertiesLeft));
189 RETURN_IF_FAILED(oRightType.GetConfig(pPropertiesRight));
190
191 return base::is_equal(*pPropertiesLeft, *pPropertiesRight);
192}
193
194}
195namespace ant
196{
197
206template<typename T>
207bool operator==(const IStreamType& oStreamType, T /* oValue */)
208{
209 adtf::util::cString strMetaTypeName;
210 oStreamType.GetMetaTypeName(adtf_string_intf(strMetaTypeName));
211 return strMetaTypeName.IsEqual(T::MetaTypeName);
212}
213
223template<typename T>
224bool operator!=(const IStreamType& oStreamType, T oValue)
225{
226 return !(oStreamType == oValue);
227}
228
237inline bool operator==(const IStreamType& oStreamTypeLeft, const IStreamType& oStreamTypeRight)
238{
239 return IS_OK(spider::is_equal(oStreamTypeLeft, oStreamTypeRight));
240}
241
250inline bool operator!=(const IStreamType& oStreamTypeLeft, const IStreamType& oStreamTypeRight)
251{
252 return !(oStreamTypeLeft == oStreamTypeRight);
253}
254
263template<typename VALUETYPE>
264tResult set_property(IStreamType& oStreamType, const char* strNameOfValue, VALUETYPE oValue)
265{
267 RETURN_IF_FAILED(oStreamType.GetConfig(pProperties));
268 return adtf::base::set_property<VALUETYPE>(*pProperties, strNameOfValue, oValue);
269}
270
278inline tResult set_property(IStreamType& oStreamType, const char* strNameOfValue, const char* poValue)
279{
281 RETURN_IF_FAILED(oStreamType.GetConfig(pProperties));
282 return adtf::base::set_property<adtf_util::cString>(*pProperties, strNameOfValue, adtf_util::cString(poValue));
283}
284
293template<typename VALUETYPE>
294VALUETYPE get_property(const IStreamType& oStreamType, const char* strNameOfValue, VALUETYPE oDefaultValue)
295{
297 if (IS_OK(oStreamType.GetConfig(pProperties)))
298 {
299 return adtf::base::get_property<VALUETYPE>(*pProperties, strNameOfValue, oDefaultValue);
300 }
301 else
302 {
303 return oDefaultValue;
304 }
305}
306
313template<typename VALUETYPE>
314VALUETYPE get_property(const IStreamType& oStreamType, const char* strNameOfValue)
315{
316 return get_property<VALUETYPE>(oStreamType, strNameOfValue, VALUETYPE());
317}
318
319} //namespace ant
320
321namespace flash
322{
323
332 const ant::IStreamType& oExpectedType);
333
343
353
362 const ant::IStreamType& oExpectedType);
363
369template <typename T>
371{
373 typedef char one;
375 typedef long two;
376
381 template <typename C> static one test( decltype(&C::MetaTypeName) ) ;
382
387 template <typename C> static two test(...);
388
389public:
393 enum { value = sizeof(test<T>(nullptr)) == sizeof(char) };
394};
395
396}
397
398namespace ant
399{
400
410template<typename T,
411 typename std::enable_if_t<flash::is_stream_meta_type<T>::value, int> = 0>
413 const T& oValue)
414{
415 if (!pStreamType.Get())
416 {
417 return false;
418 }
419 return *pStreamType.Get() == oValue;
420}
421
431template<typename T,
432 typename std::enable_if_t<flash::is_stream_meta_type<T>::value, int> = 0>
434 const T& oValue)
435{
436 return !(pStreamType == oValue);
437}
438
439}
440
441using ant::IStreamMetaType;
442using ant::IStreamType;
443using ant::get_property;
444using ant::set_property;
445using flash::is_compatible;
446using flash::is_stream_meta_type;
447using spider::is_equal;
448
449} //namespac streaming
450} // namespace adtf
Copyright © Audi Electronics Venture GmbH.
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
#define RETURN_IF_FAILED(s)
Return if expression is failed, which requires the calling function's return type to be tResult.
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
#define RETURN_ERROR(code)
Return specific error code, which requires the calling function's return type to be tResult.
tBool operator!=(const tErrorCode &lhs, const tErrorCode &rhs)
Compare two POD error code types for inequality.
tBool operator==(const tErrorCode &lhs, const tErrorCode &rhs)
Compare two POD error code types for equality.
tBool IsEqual(const tError< ErrorCode > &i_oErrorVal) const noexcept
Check whether an error code is equal to the contained one.
The IString interface provides methods for getting and setting strings through abstract interfaces.
Definition string_intf.h:28
Defines access methods for a Stream Meta Type - see also Stream Type and Stream Meta Type for more in...
virtual adtf::util::tVersion GetVersion() const =0
Get version of a Stream Type.
virtual tResult GetMetaTypeName(base::ant::IString &&strTypeName) const =0
Gets the unique meta type name.
~IStreamMetaType()=default
not destructable
virtual tResult IsCompatible(const IStreamType &oTypeToCheck, const IStreamType &oExpectedType) const =0
Compares the Stream Type oTypeToCheck based on this meta type - see Default Stream Meta Types in ADTF...
virtual tResult GetParent(ucom::ant::iobject_ptr< const IStreamMetaType > &pParent) const =0
This GetParent function is deprecated.
virtual tResult GetDefaultConfig(ucom::ant::iobject_ptr< const base::ant::IProperties > &pProperties) const =0
Get the default configuration values for 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 - see also Stream Type and Stream Meta Type...
virtual adtf::util::tVersion GetVersion() const =0
Get version of this instance of the StreamMetaType.
virtual tResult GetMetaTypeName(base::ant::IString &&strTypeName) const =0
Get the meta type name of this instance.
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.
~IStreamType()=default
not destructable
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.
virtual tResult GetConfig(ucom::ant::iobject_ptr< base::ant::IProperties > &pProperties)=0
Get all properties of a Stream Type (read/write)
type traits concept test template to check wether a type T is a type can be used for Stream Meta Type...
static two test(...)
negative test function to test if type T has a string literal MetaTypeName defined.
static one test(decltype(&C::MetaTypeName))
test function to test if type T has a string literal MetaTypeName defined.
Base class for every interface type within the uCOM.
Definition object_intf.h:33
Base object pointer to realize binary compatible reference counting in interface methods.
tResult is_equal(const ant::IProperties &oLeftProperties, const ant::IProperties &oRightProperties)
Check if two property sets are equal.
VALUETYPE get_property(const IConfiguration &oConfiguration, const char *strNameOfValue, VALUETYPE oDefaultValue)
Get the property content converted to the VALUETYPE.
tResult set_property(IConfiguration &oConfiguration, const char *strNameOfValue, VALUETYPE oValue)
Set the property.
Namespace for all functionality of the ADTF Streaming SDK provided since v3.0.
tResult set_property(IStreamType &oStreamType, const char *strNameOfValue, VALUETYPE oValue)
Sets the property of the given oStreamType to the value oValue.
VALUETYPE get_property(const IStreamType &oStreamType, const char *strNameOfValue, VALUETYPE oDefaultValue)
Gets the property of the given oStreamType.
tResult is_compatible(const ant::IStreamType &oCheckedType, const ant::IStreamType &oExpectedType)
Checks whether oCheckedType is compatible with oExpectedType.
Namespace for all functionality of the ADTF Streaming SDK provided since v3.18.
tResult is_equal(const ant::IStreamType &oLeftType, const ant::IStreamType &oRightType)
Check if two stream types are equal.
Namespace for the ADTF Streaming SDK.
ant::IObject IObject
Alias always bringing the latest version of ant::IObject into scope.
Namespace for entire ADTF SDK.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
#define adtf_string_intf(__string__)
The adtf_string_intf Macro helps to easily create a rvalue reference of a adtf::util::cString.