ADTF  3.18.2
streamtype_intf.h
Go to the documentation of this file.
1 
7 #pragma once
8 
9 #include <adtfucom3/adtf_ucom3.h>
10 #include <adtfbase/string_intf.h>
11 #include <adtfbase/property_intf.h>
12 #include <adtfbase/properties.h>
13 #include <adtfucom3/adtf_ucom3.h>
14 
15 #include <string>
16 
17 namespace adtf
18 {
19 namespace streaming
20 {
21 namespace ant
22 {
23 class IStreamType;
24 
39 {
40 protected:
42  ~IStreamMetaType() = default;
43 public:
44 
45 public:
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 {
104 protected:
106  ~IStreamType() = default;
107 
108 public:
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 
153 namespace spider
154 {
155 
163 inline 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 }
195 namespace ant
196 {
197 
206 template<typename T>
207 bool 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 
223 template<typename T>
224 bool operator!=(const IStreamType& oStreamType, T oValue)
225 {
226  return !(oStreamType == oValue);
227 }
228 
237 inline bool operator==(const IStreamType& oStreamTypeLeft, const IStreamType& oStreamTypeRight)
238 {
239  return IS_OK(spider::is_equal(oStreamTypeLeft, oStreamTypeRight));
240 }
241 
250 inline bool operator!=(const IStreamType& oStreamTypeLeft, const IStreamType& oStreamTypeRight)
251 {
252  return !(oStreamTypeLeft == oStreamTypeRight);
253 }
254 
263 template<typename VALUETYPE>
264 tResult 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 
278 inline 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 
293 template<typename VALUETYPE>
294 VALUETYPE 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 }
313 template<typename VALUETYPE>
314 VALUETYPE get_property(const IStreamType& oStreamType, const char* strNameOfValue)
315 {
316  return get_property<VALUETYPE>(oStreamType, strNameOfValue, VALUETYPE());
317 }
318 
319 } //namespace ant
320 
321 namespace flash
322 {
323 
332  const ant::IStreamType& oExpectedType);
333 
343 
353 
362  const ant::IStreamType& oExpectedType);
363 
369 template <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 
389 public:
393  enum { value = sizeof(test<T>(nullptr)) == sizeof(char) };
394 };
395 
396 }
397 
398 namespace ant
399 {
400 
410 template<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 
431 template<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 
441 using ant::IStreamMetaType;
442 using ant::IStreamType;
443 using ant::get_property;
444 using ant::set_property;
446 using flash::is_stream_meta_type;
447 using spider::is_equal;
448 
449 } //namespac streaming
450 } // namespace adtf
Copyright © Audi Electronics Venture GmbH.
#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 IsEqual(const tError< ErrorCode > &i_oErrorVal) const
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:31
Base object pointer to realize binary compatible reference counting in interface methods.
Object pointer implementation used for reference counting on objects of type IObject.
Definition: object_ptr.h:163
string_base< cStackString > cString
cString implementation for a stack string which works on stack if string is lower than A_UTILS_DEFAUL...
Definition: string.h:2778
bool operator!=(const ucom::ant::iobject_ptr< const IStreamType > &pStreamType, const T &oValue)
The equality operator returns true only if the given pStreamType is an instance of the stream_meta_ty...
tResult set_property(IStreamType &oStreamType, const char *strNameOfValue, const char *poValue)
Sets the property of the given oStreamType to the cString value poValue.
bool operator==(const ucom::ant::iobject_ptr< const IStreamType > &pStreamType, const T &oValue)
The equality operator returns true only if the given pStreamType is an instance of the stream_meta_ty...
VALUETYPE get_property(const IStreamType &oStreamType, const char *strNameOfValue)
Gets the property of the given oStreamType.
tResult is_compatible(const ucom::ant::iobject_ptr< const ant::IStreamType > &pCheckedType, const ant::IStreamType &oExpectedType)
Checks whether pCheckedType is compatible with oExpectedType.
tResult is_equal(const ant::IStreamType &oLeftType, const ant::IStreamType &oRightType)
Check if two stream types are equal.
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.
Definition: string_intf.h:371