ADTF  3.18.2
md_sample_data_legacy.h
Go to the documentation of this file.
1 
7 #pragma once
8 #include <adtfbase/adtf_base_type_traits.h>
10 #include "sample_codec_legacy.h"
11 
12 #include <memory>
13 #include <cstdint>
14 #include <string>
15 
16 namespace adtf
17 {
18 namespace mediadescription
19 {
20 namespace flash
21 {
22 
34 template <typename T>
36 {
37  description()
38  {
39  static_assert(base::penguin::detail::always_false<T>,
40  "There is no description specialization available for this type."
41  " Please make sure that you generate and include the corresponding header file.");
42  }
43 };
44 
48 template <typename T>
49 struct indices;
50 
63 template <typename T>
65 {
66  public:
68  {
69  static_assert(base::penguin::detail::always_false<T>,
70  "There is no md_sample_data specialization available for this type."
71  " Please make sure that you generate and include the corresponding header file.");
72  }
73 };
74 
83 template <typename T, typename UnderlyingType = T>
84 class md_array
85 {
86  public:
87  md_array(const size_t aIndices[],
88  std::shared_ptr<adtf::mediadescription::ant::cSampleDecoder> pDecoder):
89  m_pIndices(aIndices),
90  m_pDecoder(pDecoder)
91  {
92  }
93 
94  T operator[](size_t nIndex) const
95  {
96  return static_cast<T>(static_cast<UnderlyingType>(m_pDecoder->GetElementValue(m_pIndices[nIndex])));
97  }
98 
99  private:
100  const size_t* m_pIndices = nullptr;
101  std::shared_ptr<adtf::mediadescription::ant::cSampleDecoder> m_pDecoder;
102 };
103 
112 template <typename T>
114 {
115  public:
116  md_struct_array(const indices<T> aIndices[],
117  std::shared_ptr<adtf::mediadescription::ant::cSampleDecoder> decoder):
118  m_pIndices(aIndices),
119  m_pDecoder(decoder)
120  {
121  }
122 
123  md_sample_data<T> operator[](size_t nIndex) const
124  {
125  return md_sample_data<T>(m_pIndices[nIndex], m_pDecoder);
126  }
127 
128  private:
129  const indices<T>* m_pIndices = nullptr;
130  std::shared_ptr<adtf::mediadescription::ant::cSampleDecoder> m_pDecoder;
131 };
132 
133 namespace detail
134 {
135 
136 template <typename T>
138 {
140  std::shared_ptr<indices<T>> pIndices):
141  ant::cSampleDecoder(std::move(oDecoder)),
142  pIndices(std::move(pIndices))
143  {}
144 
145  std::shared_ptr<indices<T>> pIndices;
146 };
147 
148 }
149 
161 template <typename T>
163 {
164  public:
165  /*
166  * Default constructor that intializes the factory with the generated media description.
167  */
171  {
172  }
173 
175  md_sample_data_factory& operator=(md_sample_data_factory&&) = default;
176 
177 
185  md_sample_data_factory(*pStreamType.Get())
186  {
187  }
188 
196  m_oFactory(oStreamType),
197  m_pIndices(std::make_shared<indices<T>>())
198  {
199  THROW_IF_FAILED(m_oFactory.IsValid());
200  m_pIndices->Find(m_oFactory, "");
201  }
202 
209  md_sample_data_factory(const char* strStructName, const char* strDefinition):
210  m_oFactory(strStructName, strDefinition),
211  m_pIndices(std::make_shared<indices<T>>())
212  {
213  THROW_IF_FAILED(m_oFactory.IsValid());
214  m_pIndices->Find(m_oFactory, "");
215  }
216 
223  {
224  return md_sample_data<T>(*m_pIndices,
225  std::make_shared<detail::decoder_with_indices<T>>(m_oFactory.MakeDecoderFor(pSample),
226  m_pIndices));
227  }
228 
229  private:
231  std::shared_ptr<indices<T>> m_pIndices;
232 };
233 
234 }
235 
236 }
237 }
Copyright © Audi Electronics Venture GmbH.
tResult IsValid() const
Check if the factory is in a valid state.
cSampleDecoder MakeDecoderFor(const adtf::streaming::ISample &oSample, adtf_ddl::tDataRepresentation eDataRepresentation) const
Creates a decoder for the given sample.
Decoder for samples with static and/or dynamic data.
This class is used to wrap access to arrays of plain and enum types.
This factory provides instances of md_sample_data for incoming samples.
md_sample_data_factory(const adtf::streaming::IStreamType &oStreamType)
Initializes the factory with a stream type that has a media description set.
md_sample_data< T > Make(const adtf::ucom::ant::iobject_ptr< const adtf::streaming::ant::ISample > &pSample)
Returns a data access wrapper for the given sample.
md_sample_data_factory(const adtf::ucom::ant::iobject_ptr< const adtf::streaming::IStreamType > &pStreamType)
Initializes the factory with a stream type that has a media description set.
md_sample_data_factory(const char *strStructName, const char *strDefinition)
Initializes the factory with a media description.
Template to provide media description based access to Sample data.
This class is used to wrap access to arrays of struct types.
Defines access methods for the interface of a Stream Type - see also Stream Type and Stream Meta Type...
Base object pointer to realize binary compatible reference counting in interface methods.
Namespace for entire ADTF SDK.
Copyright © Audi Electronics Venture GmbH.
Template to provide struct name and definition for a generated struct.
#define THROW_IF_FAILED(s)
throws if the expression returns a failed tResult