ADTF  3.18.2
test_writer.h
Go to the documentation of this file.
1 
7 #pragma once
8 #include <adtf_utils.h>
9 #include <adtfucom3/adtf_ucom3.h>
12 #include <adtfstreaming3/sample.h>
14 #include <memory>
15 #include <set>
16 #include <mutex>
17 
18 namespace adtf
19 {
20 
21 namespace filter
22 {
23 
24 namespace testing
25 {
26 
27 namespace giant
28 {
29 
40 {
41 public:
50  const char* strPinName,
52 
63  const char* strPinName,
65  std::function<void(uint32_t, const base::IProperties*)> fnRequest,
66  std::function<void(uint32_t)> fnCancel);
67 
78 
87  template<typename T>
88  void Write(base::flash::tNanoSeconds tmTimeStamp, const T& xValue, bool bTrigger = false)
89  {
90  WriteSubStream<T>(0, tmTimeStamp, xValue, bTrigger);
91  }
92 
102  template<typename T>
103  void Write(const T& xValue, bool bTrigger = false)
104  {
105  Write<T>(GetCurrentStreamTime(), xValue, bTrigger);
106  }
107 
117  template<typename T>
118  void WriteSubStream(uint32_t nSubStreamId,
119  base::flash::tNanoSeconds tmTimeStamp,
120  const T& xValue,
121  bool bTrigger = false)
122  {
125  THROW_IF_FAILED(pSample->SetTime(tmTimeStamp));
126  pSample->SetSubStreamId(nSubStreamId);
127 
128  {
130  THROW_IF_FAILED(pSample->WriteLock(pSampleBuffer, 0));
131  pSampleBuffer->Write(base::adtf_memory<const T>(&xValue));
132  }
133 
134  WriteSample(ucom::ucom_object_ptr_cast<streaming::ISample>(pSample));
135  if (bTrigger)
136  {
137  ManualTrigger(tmTimeStamp);
138  }
139  }
140 
151  template<typename T>
152  void WriteSubStream(uint32_t nSubStreamId, const T& xValue, bool bTrigger = false)
153  {
154  WriteSubStream<T>(nSubStreamId, GetCurrentStreamTime(), xValue, bTrigger);
155  }
162 
168 
175  void SetRequestCallbacks(std::function<void(uint32_t, const base::IProperties*)> fnRequest,
176  std::function<void(uint32_t)> fnCancel);
177 
178 protected:
184 
185 private:
186  class cImplementation;
187  std::unique_ptr<cImplementation> m_pImplementation;
188 };
189 
190 } // namespace giant
191 
192 namespace penguin
193 {
194 
209 {
210 public:
219  const char* strPinName,
222 
224 
231 
240  bool IsSubstreamRequested(uint32_t ui32SubStreamId) const;
247  std::set<uint32_t> GetCurrentRequests() const;
248 
249 private:
250  std::set<uint32_t> m_setRequestedSubstreams;
251  mutable std::mutex m_mxLock;
252 };
253 
254 } // namespace penguin
255 
256 using giant::cTestWriter;
258 
259 } // namespace testing
260 } // namespace filter
261 } // namespace adtf
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Defintion of a property set container interface.
Template class implementation for the ant::IRawMemory interface (see Supported types for adtf_memory<...
Helper class that wraps different objects into an adtf::streaming::ant::IStreamType.
Tester helper class to emulate a writing OutPin to InPin connection for sending samples and type to a...
Definition: test_writer.h:40
void SetRequestCallbacks(std::function< void(uint32_t, const base::IProperties *)> fnRequest, std::function< void(uint32_t)> fnCancel)
Set the callbacks for the request calls on substreams.
void Write(const T &xValue, bool bTrigger=false)
Writes one sample with the sample buffer content of T into the writing stream.
Definition: test_writer.h:103
~cTestWriter()
Destroy the c Test Writer object.
void WriteSubStream(uint32_t nSubStreamId, const T &xValue, bool bTrigger=false)
Writes one sample with the sample buffer content of T into the writing stream and mark it as part of ...
Definition: test_writer.h:152
cTestWriter(const ucom::ant::iobject_ptr< ucom::ant::IObject > &pObject, const char *strPinName, const filter::flash::cStreamTypeHelper &oType=streaming::stream_meta_type_anonymous())
Construct a new Test Writer object.
void Write(base::flash::tNanoSeconds tmTimeStamp, const T &xValue, bool bTrigger=false)
Writes one sample with the sample buffer content of T into the writing stream.
Definition: test_writer.h:88
void ManualTrigger(base::flash::tNanoSeconds tmActivationTime=base::flash::tNanoSeconds{-1})
Sends a manual trigger call into the runner pipe of the.
base::flash::tNanoSeconds GetCurrentStreamTime() const
Gets the current stream time (if any clock is present within the _runtime singleton).
void ChangeType(const filter::flash::cStreamTypeHelper &oType)
Emulates a stream type change during writing.
cTestWriter(const ucom::ant::iobject_ptr< ucom::ant::IObject > &pObject, const char *strPinName, const filter::flash::cStreamTypeHelper &oType, std::function< void(uint32_t, const base::IProperties *)> fnRequest, std::function< void(uint32_t)> fnCancel)
Construct a new Test Writer object.
void WriteSample(const ucom::ant::iobject_ptr< const streaming::ant::ISample > &pSample)
Writes the given sample into the writing stream.
void WriteSubStream(uint32_t nSubStreamId, base::flash::tNanoSeconds tmTimeStamp, const T &xValue, bool bTrigger=false)
Writes one sample with the sample buffer content of T into the writing stream and mark it as part of ...
Definition: test_writer.h:118
Tester helper class to emulate a writing OutPin to InPin connection for sending samples and type to a...
Definition: test_writer.h:209
std::set< uint32_t > GetCurrentRequests() const
Retrieve a copy of the current requested substream ids.
cTestWriterWithSubStreams(const adtf::ucom::ant::iobject_ptr< adtf::ucom::ant::IObject > &pObject, const char *strPinName, const adtf::filter::flash::cStreamTypeHelper &oType=adtf::streaming::stream_meta_type_anonymous())
CTOR.
bool IsSubstreamRequested(uint32_t ui32SubStreamId) const
Determines if the given ui32SubStreamId was requested.
void ChangeType(const filter::flash::cStreamTypeHelper &oType)
Emulates a stream type change during writing.
Base object pointer to realize binary compatible reference counting in interface methods.
Implementation for a exclusive lock guard.
Object pointer implementation used for reference counting on objects of type IObject.
Definition: object_ptr.h:163
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
tResult alloc_sample(ucom::ant::iobject_ptr< ucom::ant::IObject > &pSampleObject, const char *strSampleCID)
Helper Function to get a Sample Instance through the adtf::ucom::ant::IRuntime.
Namespace for entire ADTF SDK.
Copyright © Audi Electronics Venture GmbH.
Use this Stream Meta Type only if no property should be set and you do not share and record these dat...
#define THROW_IF_FAILED(s)
throws if the expression returns a failed tResult