ADTF  3.18.2
streamtype.h
Go to the documentation of this file.
1 
7 #pragma once
8 #include "streamtype_intf.h"
9 
10 #include <adtfucom3/adtf_ucom3.h>
11 #include <adtfbase/adtf_base.h>
12 
13 #include <type_traits>
14 
15 namespace adtf
16 {
17 namespace streaming
18 {
19 namespace ant
20 {
27 class cStreamMetaType : public adtf::ucom::catwo::object<IStreamMetaType>
28 {
29  public:
31  using cProperties = ::adtf::base::cProperties;
32  using IString = ::adtf::base::IString;
33  using tVersion = ::adtf_util::tVersion;
37  protected:
45  tVersion m_sVersion;
46 
47  public: // implements IStreamMetaType
49  tResult GetMetaTypeName(IString&& strTypeName) const override;
51  adtf::util::tVersion GetVersion() const override;
57 
74  tResult IsCompatible(const IStreamType& oTypeToCheck, const IStreamType& oTypeExpected) const override;
75 
76  public:
84  virtual ~cStreamMetaType() = default;
85 
86  private:
87  cStreamMetaType(const cStreamMetaType& oFromStream) = delete;
88  cStreamMetaType(cStreamMetaType&& oSource) = delete;
89  cStreamMetaType& operator=(const cStreamMetaType& oStreamType) = delete;
90  cStreamMetaType& operator=(cStreamMetaType&& oStreamType) = delete;
91 
92  protected:
98  tResult SetMetaTypeName(const char* strTypeName);
99 
100 
101 };
102 
103 /*********************************************************************************************************************************************************
104  * internal namespace
105  ********************************************************************************************************************************************************/
106 namespace detail
107 {
108 
109 template <typename T>
110 class has_set_properties: private T
111 {
112  typedef char one;
113  typedef long two;
114 
115  template <typename C> static one test(decltype(static_cast<void(*)(const adtf::ucom::ant::iobject_ptr<adtf::base::ant::IProperties>&)>(&has_set_properties<C>::SetProperties)));
116  template <typename C> static two test(...);
117 
118 public:
119  enum { value = sizeof(test<T>(static_cast<void(*)(const adtf::ucom::ant::iobject_ptr<adtf::base::ant::IProperties>&)>(nullptr))) == sizeof(char) };
120 };
121 
122 
123 template <typename T, typename Enable = void>
125 
126 template<typename T>
127 struct stream_meta_type_properties_helper<T, std::enable_if_t<!has_set_properties<T>::value>>
128 {
129  static void set_default_properties(const adtf::ucom::iobject_ptr<adtf::base::IProperties>& /*pProperties*/)
130  {
131  }
132 };
133 
134 template <typename T>
135 struct stream_meta_type_properties_helper<T, std::enable_if_t<has_set_properties<T>::value>>
136 {
137  static void set_default_properties(const adtf::ucom::iobject_ptr<adtf::base::IProperties>& pProperties)
138  {
139  T::SetProperties(pProperties);
140  }
141 };
142 
143 template <typename T>
144 class has_is_compatible: private T
145 {
146  typedef char one;
147  typedef long two;
148 
149  template <typename C> static one test(decltype(static_cast<tResult(*)(const adtf::streaming::ant::IStreamType&,
151  template <typename C> static two test(...);
152 
153 public:
154  enum { value = sizeof(test<T>(static_cast<tResult(*)(const adtf::streaming::ant::IStreamType&,
155  const adtf::streaming::ant::IStreamType&)>(nullptr))) == sizeof(char) };
156 };
157 
158 template <typename T, typename Enable = void>
160 
161 template<typename T>
162 struct stream_meta_type_is_compatible_helper<T, std::enable_if_t<!has_is_compatible<T>::value>>
163 {
164  static constexpr bool HasIsCompatible()
165  {
166  return false;
167  }
168 
169  static tResult IsCompatible(const adtf::streaming::IStreamType& /*oSourceType*/,
170  const adtf::streaming::IStreamType& /*oDestinationType*/)
171  {
172  RETURN_ERROR(ERR_INVALID_FUNCTION);
173  }
174 };
175 
176 template <typename T>
177 struct stream_meta_type_is_compatible_helper<T, std::enable_if_t<has_is_compatible<T>::value>>
178 {
179  static constexpr bool HasIsCompatible()
180  {
181  return true;
182  }
183 
184  static tResult IsCompatible(const adtf::streaming::IStreamType& oSourceType,
185  const adtf::streaming::IStreamType& oDestinationType)
186  {
187  return T::IsCompatible(oSourceType, oDestinationType);
188  }
189 };
190 
191 }
192 /*********************************************************************************************************************************************************
193  * internal namespace end
194  ********************************************************************************************************************************************************/
195 
232 template <typename MetaTypeStruct>
234 {
235  public:
243  {
244  SetMetaTypeName(MetaTypeStruct::MetaTypeName);
246  }
247 
257  tResult IsCompatible(const IStreamType& oCheckedType,
258  const IStreamType& oExpectedType) const override
259  {
261  {
263  }
264  else
265  {
266  return cStreamMetaType::IsCompatible(oCheckedType, oExpectedType);
267  }
268  }
269 };
270 
281 class cStreamType : public ucom::catwo::object<IStreamType>
282 {
283  private:
288 
289  //TODO Remove
290  tTimeStamp m_pTimeStamp = -1;
291  public:
296 
302  template <typename MetaType>
303  cStreamType(const MetaType&)
304  {
305  using namespace adtf::ucom;
306  m_pProperties = make_object_ptr<adtf::base::cProperties>();
307  m_pStreamMetaType = make_object_ptr<stream_meta_type<MetaType>>();
308  InitPropertiesFromStreamTypeDefintion(*m_pProperties.Get(), *m_pStreamMetaType.Get());
309  }
310 
315  cStreamType(const IStreamType& pType);
316 
320  virtual ~cStreamType();
321 
322  protected:
324  cStreamType(const cStreamType& oType) = delete;
326  cStreamType& operator=(const cStreamType& oType)= delete;
328  cStreamType(cStreamType&& oType) = delete;
330  cStreamType& operator=(cStreamType&& oType) = delete;
331 
332  public: // implements IStreamType
333  tTimeStamp GetTime() const
334  {
335  return m_pTimeStamp;
336  }
337 
338  tResult SetTime(tTimeStamp oTimeStamp)
339  {
340  m_pTimeStamp = oTimeStamp;
342  }
343 
345  tResult GetMetaTypeName(base::ant::IString&& strTypeName) const override;
347  adtf::util::tVersion GetVersion() const override;
354 
355  private:
356  tResult InitPropertiesFromStreamTypeDefintion(base::ant::IProperties& oWhereToSet,
357  const IStreamMetaType& oStreamTypeDefintion);
358 
359 };
360 
361 } //namespace ant
362 
363 
364 
365 namespace flash
366 {
367 
374 template <typename StreamMetaType>
376 {
377  public:
383  {
384  }
385 };
386 
387 } //namespace flash
388 
390 using ant::cStreamMetaType;
391 
393 using ant::cStreamType;
394 
397 
399 using flash::stream_type;
400 
401 } //namespace streaming
402 } //namespace adtf
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
#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.
Defintion of a property set container interface.
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...
Defines access methods for the interface of a Stream Type - see also Stream Type and Stream Meta Type...
Implements the default adtf::streaming::ant::IStreamMetaType interface.
Definition: streamtype.h:28
tResult GetParent(adtf::ucom::ant::iobject_ptr< const IStreamMetaType > &pParent) const override
This GetParent function is deprecated.
tResult IsCompatible(const IStreamType &oTypeToCheck, const IStreamType &oTypeExpected) const override
Compares the oTypeExpected Stream Type with the oTypeToCheck - see Default Stream Meta Types in ADTF ...
tResult SetMetaTypeName(const char *strTypeName)
Sets the unique type name.
virtual ~cStreamMetaType()=default
DTOR.
tResult GetDefaultConfig(adtf::ucom::ant::iobject_ptr< const adtf::base::IProperties > &pProperties) const override
Get the default configuration values for a Stream Type.
adtf::ucom::object_ptr< IStreamMetaType > m_pParentMetaType
parent if any
Definition: streamtype.h:43
tResult GetMetaTypeName(IString &&strTypeName) const override
Gets the unique meta type name.
adtf::util::tVersion GetVersion() const override
Get version of a Stream Type.
adtf::ucom::object_ptr< adtf::base::IProperties > m_pDefaultProperties
Default properties.
Definition: streamtype.h:41
cString m_strMetaTypeName
MetaTypeName of the StreamMetaType (like "adtf/default")
Definition: streamtype.h:39
Default StreamType implementation.
Definition: streamtype.h:282
cStreamType(cStreamType &&oType)=delete
hide move CTOR
cStreamType & operator=(const cStreamType &oType)=delete
hide copy operator
cStreamType(const MetaType &)
Convenience CTOR will create an Instance of given Stream Meta Type oTypeDefintion and sets the defaul...
Definition: streamtype.h:303
cStreamType & operator=(cStreamType &&oType)=delete
hide move operator
tResult GetConfig(adtf::ucom::iobject_ptr< const base::ant::IProperties > &pProperties) const override
Get all properties of a Stream Type (read/write)
tResult GetMetaTypeName(base::ant::IString &&strTypeName) const override
Get the meta type name of this instance.
cStreamType(const IStreamType &pType)
Copy CTOR will create fully deep copy of given pType.
cStreamType(const cStreamType &oType)=delete
hide copy CTOR
tResult GetConfig(adtf::ucom::iobject_ptr< base::ant::IProperties > &pProperties) override
Get all properties of a Stream Type (read/write)
adtf::ucom::object_ptr< const IStreamMetaType > m_pStreamMetaType
The StreamMetaType Definiton.
Definition: streamtype.h:287
adtf::util::tVersion GetVersion() const override
Get version of this instance of the StreamMetaType.
tResult GetMetaType(adtf::ucom::iobject_ptr< const IStreamMetaType > &pMetaType) const override
Get the Stream Meta Type definition of the Stream Type.
adtf::ucom::object_ptr< base::ant::IProperties > m_pProperties
Properties of this instance.
Definition: streamtype.h:285
Generator template stream_meta_type to create a StreamMetaType Class for the Type T.
Definition: streamtype.h:234
tResult IsCompatible(const IStreamType &oCheckedType, const IStreamType &oExpectedType) const override
The IsCompatible implementation of this generator class will decide at compile time wether to use the...
Definition: streamtype.h:257
Generator template to implement a ant::IStreamType based on a Stream Meta Type - see Stream Type and ...
Definition: streamtype.h:376
stream_type()
Constructor that initializes the Stream Type with the given StreamMetaType class type.
Definition: streamtype.h:382
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
Use this template if you want to implement an ucom::ant::IObject based Interface and/or subclass an e...
Definition: object.h:379
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
Namespace for the ADTF uCOM3 SDK.
Namespace for entire ADTF SDK.
datamodel::StreamMetaType StreamMetaType
Reuse of datamodel streammetatype class - ddl::dd::datamodel::StreamMetaType.
Definition: dd.h:58
@ stream_meta_type
the type is an stream meta type (StreamMetaType)
Copyright © Audi Electronics Venture GmbH.