ADTF
Loading...
Searching...
No Matches
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
68 tResult IsCompatible(const IStreamType& oTypeToCheck, const IStreamType& oTypeExpected) const override;
69
70 public:
78 virtual ~cStreamMetaType() override;
79
80 private:
81 cStreamMetaType(const cStreamMetaType& oFromStream) = delete;
82 cStreamMetaType(cStreamMetaType&& oSource) = delete;
83 cStreamMetaType& operator=(const cStreamMetaType& oStreamType) = delete;
84 cStreamMetaType& operator=(cStreamMetaType&& oStreamType) = delete;
85
86 protected:
92 tResult SetMetaTypeName(const char* strTypeName);
93
94
95};
96
97/*********************************************************************************************************************************************************
98 * internal namespace
99 ********************************************************************************************************************************************************/
101namespace detail
102{
103
104template <typename T>
105class has_set_properties: private T
106{
107 typedef char one;
108 typedef long two;
109
110 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)));
111 template <typename C> static two test(...);
112
113public:
114 enum { value = sizeof(test<T>(static_cast<void(*)(const adtf::ucom::ant::iobject_ptr<adtf::base::ant::IProperties>&)>(nullptr))) == sizeof(char) };
115};
116
117
118template <typename T, typename Enable = void>
119struct stream_meta_type_properties_helper;
120
121template<typename T>
122struct stream_meta_type_properties_helper<T, std::enable_if_t<!has_set_properties<T>::value>>
123{
124 static void set_default_properties(const adtf::ucom::iobject_ptr<adtf::base::IProperties>& /*pProperties*/)
125 {
126 }
127};
128
129template <typename T>
130struct stream_meta_type_properties_helper<T, std::enable_if_t<has_set_properties<T>::value>>
131{
132 static void set_default_properties(const adtf::ucom::iobject_ptr<adtf::base::IProperties>& pProperties)
133 {
134 T::SetProperties(pProperties);
135 }
136};
137
138template <typename T>
139class has_is_compatible: private T
140{
141 typedef char one;
142 typedef long two;
143
144 template <typename C> static one test(decltype(static_cast<tResult(*)(const adtf::streaming::ant::IStreamType&,
145 const adtf::streaming::ant::IStreamType&)>(&has_is_compatible<C>::IsCompatible)));
146 template <typename C> static two test(...);
147
148public:
149 enum { value = sizeof(test<T>(static_cast<tResult(*)(const adtf::streaming::ant::IStreamType&,
150 const adtf::streaming::ant::IStreamType&)>(nullptr))) == sizeof(char) };
151};
152
153template <typename T, typename Enable = void>
154struct stream_meta_type_is_compatible_helper;
155
156template<typename T>
157struct stream_meta_type_is_compatible_helper<T, std::enable_if_t<!has_is_compatible<T>::value>>
158{
159 static constexpr bool HasIsCompatible()
160 {
161 return false;
162 }
163
164 static tResult IsCompatible(const adtf::streaming::IStreamType& /*oSourceType*/,
165 const adtf::streaming::IStreamType& /*oDestinationType*/)
166 {
167 RETURN_ERROR(ERR_INVALID_FUNCTION);
168 }
169};
170
171template <typename T>
172struct stream_meta_type_is_compatible_helper<T, std::enable_if_t<has_is_compatible<T>::value>>
173{
174 static constexpr bool HasIsCompatible()
175 {
176 return true;
177 }
178
179 static tResult IsCompatible(const adtf::streaming::IStreamType& oSourceType,
180 const adtf::streaming::IStreamType& oDestinationType)
181 {
182 return T::IsCompatible(oSourceType, oDestinationType);
183 }
184};
185
186} // namespace detail
188/*********************************************************************************************************************************************************
189 * internal namespace end
190 ********************************************************************************************************************************************************/
191
226template <typename MetaTypeStruct>
228{
229 public:
237 {
238 SetMetaTypeName(MetaTypeStruct::MetaTypeName);
239 detail::stream_meta_type_properties_helper<MetaTypeStruct>::set_default_properties(m_pDefaultProperties);
240 }
241
251 tResult IsCompatible(const IStreamType& oCheckedType,
252 const IStreamType& oExpectedType) const override
253 {
254 if (detail::stream_meta_type_is_compatible_helper<MetaTypeStruct>::HasIsCompatible())
255 {
256 return detail::stream_meta_type_is_compatible_helper<MetaTypeStruct>::IsCompatible(oCheckedType, oExpectedType);
257 }
258 else
259 {
260 return cStreamMetaType::IsCompatible(oCheckedType, oExpectedType);
261 }
262 }
263};
264
275class cStreamType : public ucom::catwo::object<IStreamType>
276{
277 private:
282
283 //TODO Remove
284 tTimeStamp m_pTimeStamp = -1;
285 public:
290
296 template <typename MetaType>
297 cStreamType(const MetaType&)
298 {
299 using namespace adtf::ucom;
301 m_pStreamMetaType = make_object_ptr<stream_meta_type<MetaType>>();
302 InitPropertiesFromStreamTypeDefintion(*m_pProperties.Get(), *m_pStreamMetaType.Get());
303 }
304
310
314 virtual ~cStreamType();
315
316 protected:
318 cStreamType(const cStreamType& oType) = delete;
320 cStreamType& operator=(const cStreamType& oType)= delete;
322 cStreamType(cStreamType&& oType) = delete;
325
326 public: // implements IStreamType
327 tTimeStamp GetTime() const
328 {
329 return m_pTimeStamp;
330 }
331
332 tResult SetTime(tTimeStamp oTimeStamp)
333 {
334 m_pTimeStamp = oTimeStamp;
336 }
337
339 tResult GetMetaTypeName(base::ant::IString&& strTypeName) const override;
341 adtf::util::tVersion GetVersion() const override;
348
349 private:
350 tResult InitPropertiesFromStreamTypeDefintion(base::ant::IProperties& oWhereToSet,
351 const IStreamMetaType& oStreamTypeDefintion);
352
353};
354
355} //namespace ant
356
357
358
359namespace flash
360{
361
366template <typename StreamMetaType>
368{
369 public:
374 stream_type(): ant::cStreamType(StreamMetaType())
375 {
376 }
377};
378
379} //namespace flash
380
382using ant::cStreamMetaType;
383
385using ant::cStreamType;
386
388using ant::stream_meta_type;
389
391using flash::stream_type;
392
393} //namespace streaming
394} //namespace adtf
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
Definition property_intf.h:213
Definition string_intf.h:29
Definition properties_v2.h:397
Defines access methods for a Stream Meta Type.
Definition streamtype_intf.h:37
Defines access methods for the interface of a Stream Type.
Definition streamtype_intf.h:96
tResult SetMetaTypeName(const char *strTypeName)
tResult GetMetaTypeName(IString &&strTypeName) const override
Gets the unique meta 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
adtf::ucom::object_ptr< adtf::base::IProperties > m_pDefaultProperties
Default properties.
Definition streamtype.h:41
tVersion m_sVersion
version
Definition streamtype.h:45
cString m_strMetaTypeName
MetaTypeName of the StreamMetaType (like "adtf/default")
Definition streamtype.h:39
adtf::util::tVersion GetVersion() const override
Get version of a Stream Type.
tResult IsCompatible(const IStreamType &oTypeToCheck, const IStreamType &oTypeExpected) const override
Compares the oTypeExpected Stream Type with the oTypeToCheck.
tResult GetParent(adtf::ucom::ant::iobject_ptr< const IStreamMetaType > &pParent) const override
This GetParent function is deprecated.
Definition streamtype.h:276
cStreamType(const IStreamType &pType)
cStreamType(const MetaType &)
Definition streamtype.h:297
tResult GetMetaType(adtf::ucom::iobject_ptr< const IStreamMetaType > &pMetaType) const override
Get the Stream Meta Type definition of the Stream Type.
cStreamType(cStreamType &&oType)=delete
hide move CTOR
tResult GetConfig(adtf::ucom::iobject_ptr< base::ant::IProperties > &pProperties) override
Get all properties of a Stream Type (read/write)
cStreamType(const cStreamType &oType)=delete
hide copy CTOR
adtf::util::tVersion GetVersion() const override
Get version of this instance of the StreamMetaType.
cStreamType & operator=(cStreamType &&oType)=delete
hide move operator
tResult GetMetaTypeName(base::ant::IString &&strTypeName) const override
Get the meta type name of this instance.
tResult GetConfig(adtf::ucom::iobject_ptr< const base::ant::IProperties > &pProperties) const override
Get all properties of a Stream Type (read/write)
cStreamType & operator=(const cStreamType &oType)=delete
hide copy operator
tResult IsCompatible(const IStreamType &oCheckedType, const IStreamType &oExpectedType) const override
Definition streamtype.h:251
stream_meta_type()
Definition streamtype.h:236
stream_type()
Definition streamtype.h:374
Base object pointer to realize binary compatible reference counting in interface methods.
Definition object_ptr_intf.h:112
Definition object_ptr.h:384
Definition object.h:397
Namespace for all internally used functionality implemented.
Definition filtergraphport.h:28
Namespace for all functionality of the ADTF Streaming SDK provided since v3.0.
Definition bindingproxyoutport.h:16
Namespace for all functionality of the ADTF Streaming SDK provided since v3.5.
Definition filterbase.h:255
Namespace for the ADTF Streaming SDK.
Definition bindingproxyinport.h:14
Namespace for the ADTF uCOM SDK.
Definition adtf_system.h:324
ant::iobject_ptr< T > iobject_ptr
Alias always bringing the latest version of ant::iobject_ptr into scope.
Definition object_ptr_intf.h:437
object_ptr< Implementation > make_object_ptr(Args &&... args)
Alias always bringing the latest version of ant::make_object_ptr() into scope.
Definition object_ptr_utilities.h:129
Namespace for all functionality provided by ADTF and its SDKs.
Definition adtf_client_connector.h:14