ADTF  3.18.2
streamitem_intf.h
Go to the documentation of this file.
1 
7 #pragma once
8 
9 #include "sample_intf.h"
10 #include "streamtype_intf.h"
11 
12 namespace adtf
13 {
14 namespace streaming
15 {
16 namespace ant
17 {
18 
23 {
24  protected:
26  ~IStreamItem() = default;
27 
28  public:
30  enum class tType : uint32_t
31  {
32  Undefined = 0,
34  StreamType = 1,
36  Sample = 2,
37  };
38 
44  virtual tType GetType() const = 0;
45 
53 
62 
71 
82 
93 };
94 
98 class cStreamItem: public IStreamItem
99 {
100  private:
101  tType m_eType;
104 
105  public:
107  cStreamItem(): m_eType(tType::Undefined)
108  {
109  }
112  cStreamItem(const IStreamItem& oItem):
113  m_eType(oItem.GetType())
114  {
115  switch (m_eType)
116  {
117  case tType::StreamType:
118  {
119  oItem.GetStreamType(m_pStreamType);
120  break;
121  }
122  case tType::Sample:
123  {
124  oItem.GetSample(m_pSample);
125  break;
126  }
127  default:
128  {
129  break;
130  }
131  }
132  }
133 
137  m_eType(tType::Sample),
138  m_pSample(pSample)
139  {
140  }
141 
145  m_eType(tType::StreamType),
146  m_pStreamType(pStreamType)
147  {
148  }
149 
151  cStreamItem(const cStreamItem&) = default;
153  cStreamItem(cStreamItem&&) = default;
154 
156  cStreamItem& operator=(const cStreamItem&) = default;
159 
160  tType GetType() const
161  {
162  return m_eType;
163  }
164 
166  {
167  switch (m_eType)
168  {
169  case tType::StreamType:
170  {
171  return pObject.Reset(m_pStreamType);
172  }
173  case tType::Sample:
174  {
175  return pObject.Reset(m_pSample);
176  }
177  default:
178  {
179  RETURN_ERROR(ERR_INVALID_TYPE);
180  }
181  }
182  }
183 
185  {
186  if (m_eType != tType::Sample)
187  {
188  RETURN_ERROR(ERR_INVALID_TYPE);
189  }
190 
191  return pSample.Reset(m_pSample);
192  }
193 
195  {
196  if (m_eType != tType::StreamType)
197  {
198  RETURN_ERROR(ERR_INVALID_TYPE);
199  }
200 
201  return pStreamType.Reset(m_pStreamType);
202  }
203 
205  {
206  m_pSample = pSample;
207  m_eType = tType::Sample;
208  m_pStreamType.Reset();
210  }
211 
213  {
214  m_pStreamType = pStreamType;
215  m_eType = tType::StreamType;
216  m_pSample.Reset();
218  }
219 
226  tResult CopyTo(IStreamItem& oDest) const
227  {
228  switch (m_eType)
229  {
230  case tType::StreamType:
231  {
232  return oDest.SetStreamType(m_pStreamType);
233  }
234  case tType::Sample:
235  {
236  return oDest.SetSample(m_pSample);
237  }
238  default:
239  {
240  RETURN_ERROR(ERR_INVALID_TYPE);
241  }
242  }
243  }
244 };
245 
246 
247 } //namespace ant
248 
250 using ant::IStreamItem;
251 using ant::cStreamItem;
252 
253 
254 } //namespace streaming
255 } //namespace adtf
#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.
The IStreamItem interface is the base type for all object which are passed through a stream.
virtual tResult SetStreamType(const ucom::ant::iobject_ptr< const IStreamType > &pStreamType)=0
Sets a StreamType to the StreamItem container and set tType::StreamType.
virtual tType GetType() const =0
Retrieves the type of the sample item.
virtual tResult GetStreamType(ucom::ant::iobject_ptr< const IStreamType > &pStreamType) const =0
Retrieves the StreamType of the StreamItem if GetType is tType::StreamType.
~IStreamItem()=default
not destructable
virtual tResult GetObject(ucom::ant::iobject_ptr< const ucom::ant::IObject > &pObject) const =0
Retrieves the object of the StreamItem.
virtual tResult SetSample(const ucom::ant::iobject_ptr< const ISample > &pSample)=0
Sets a Sample to the StreamItem container and set tType::Sample.
tType
serval types are defined
@ StreamType
item is a IStreamType. Mind: All StreamType changes will be queue too !!
@ Sample
item is a queue item contains a ISample
virtual tResult GetSample(ucom::ant::iobject_ptr< const ISample > &pSample) const =0
Retrieves the sample of the StreamItem if GetType is tType::Sample.
Default implementation of an StreamItem as container of the Sample Stream s Queue.
tResult SetSample(const ucom::ant::iobject_ptr< const ISample > &pSample)
Sets a Sample to the StreamItem container and set tType::Sample.
tResult GetSample(ucom::ant::iobject_ptr< const ISample > &pSample) const
Retrieves the sample of the StreamItem if GetType is tType::Sample.
cStreamItem & operator=(cStreamItem &&)=default
move operator
tResult GetStreamType(ucom::ant::iobject_ptr< const IStreamType > &pStreamType) const
Retrieves the StreamType of the StreamItem if GetType is tType::StreamType.
cStreamItem(const cStreamItem &)=default
copy CTOR
cStreamItem & operator=(const cStreamItem &)=default
copy operator
tType GetType() const
Retrieves the type of the sample item.
tResult CopyTo(IStreamItem &oDest) const
Copy its content to the oDest container.
tResult GetObject(ucom::ant::iobject_ptr< const ucom::ant::IObject > &pObject) const
Retrieves the object of the StreamItem.
cStreamItem(const ucom::ant::iobject_ptr< const ISample > &pSample)
initializer CTOR
cStreamItem(const IStreamItem &oItem)
copy CTOR from interface
tResult SetStreamType(const ucom::ant::iobject_ptr< const IStreamType > &pStreamType)
Sets a StreamType to the StreamItem container and set tType::StreamType.
cStreamItem(cStreamItem &&)=default
move CTOR
cStreamItem(const ucom::ant::iobject_ptr< const IStreamType > &pStreamType)
initializer CTOR
virtual tResult Reset(const iobject_ptr< T > &i_oOther)=0
Reset this object_ptr<> with the content of another iobject_ptr<>
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
void Reset()
Reset this object_ptr.
Definition: object_ptr.h:361
Namespace for entire ADTF SDK.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.