ADTF
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
streamtype.h
Go to the documentation of this file.
1
7#pragma once
8#include "streamtype_intf.h"
9
11#include <adtfbase/adtf_base.h>
12
13#include <type_traits>
14
15namespace adtf
16{
17namespace streaming
18{
19namespace ant
20{
27class 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;
34 using cString = ::adtf_util::cString;
36
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() override;
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 ********************************************************************************************************************************************************/
106namespace detail
107{
108
109template <typename T>
110class 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
118public:
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
123template <typename T, typename Enable = void>
125
126template<typename T>
127struct 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
134template <typename T>
135struct 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
143template <typename T>
144class 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
153public:
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
158template <typename T, typename Enable = void>
160
161template<typename T>
162struct 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
176template <typename T>
177struct 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
232template <typename MetaTypeStruct>
234{
235 public:
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
281class 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;
308 InitPropertiesFromStreamTypeDefintion(*m_pProperties.Get(), *m_pStreamMetaType.Get());
309 }
310
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;
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
365namespace flash
366{
367
374template <typename StreamMetaType>
376{
377 public:
382 stream_type(): ant::cStreamType(StreamMetaType())
383 {
384 }
385};
386
387} //namespace flash
388
390using ant::cStreamMetaType;
391
393using ant::cStreamType;
394
396using ant::stream_meta_type;
397
399using flash::stream_type;
400
401} //namespace streaming
402} //namespace adtf
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
#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...
virtual ~cStreamMetaType() override
DTOR.
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.
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(const MetaType &)
Convenience CTOR will create an Instance of given Stream Meta Type oTypeDefintion and sets the defaul...
Definition streamtype.h:303
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)
cStreamType & operator=(cStreamType &&oType)=delete
hide move operator
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
cStreamType & operator=(const cStreamType &oType)=delete
hide copy operator
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
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.
Use this template if you want to implement an ucom::ant::IObject based Interface and/or subclass an e...
Definition object.h:397
Namespace for internal functionality.
Namespace for all functionality of the ADTF Streaming SDK provided since v3.0.
Namespace for all functionality of the ADTF Streaming SDK provided since v3.5.
Namespace for the ADTF Streaming SDK.
Namespace for the ADTF uCOM3 SDK.
ant::iobject_ptr< T > iobject_ptr
Alias always bringing the latest version of ant::iobject_ptr into scope.
object_ptr< Implementation > make_object_ptr(Args &&... args)
Alias always bringing the latest version of ant::make_object_ptr() into scope.
Namespace for entire ADTF SDK.
Copyright © Audi Electronics Venture GmbH.