ADTF
Loading...
Searching...
No Matches
test_writer.h
Go to the documentation of this file.
1
7#pragma once
8#include <adtf_utils.h>
14#include <memory>
15#include <set>
16#include <mutex>
17
18namespace adtf
19{
20
21namespace filter
22{
23
24namespace testing
25{
26
27namespace giant
28{
29
40{
41public:
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
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 }
156
162
168
175 void SetRequestCallbacks(std::function<void(uint32_t, const base::IProperties*)> fnRequest,
176 std::function<void(uint32_t)> fnCancel);
177
178protected:
184
185private:
186 class cImplementation;
187 std::unique_ptr<cImplementation> m_pImplementation;
188};
189
190} // namespace giant
191
192namespace penguin
193{
194
209{
210public:
219 const char* strPinName,
222
224
231
240 bool IsSubstreamRequested(uint32_t ui32SubStreamId) const;
247 std::set<uint32_t> GetCurrentRequests() const;
248
249private:
250 std::set<uint32_t> m_setRequestedSubstreams;
251 mutable std::mutex m_mxLock;
252};
253
254} // namespace penguin
255
258
259} // namespace testing
260} // namespace filter
261} // namespace adtf
#define THROW_IF_FAILED(s)
throws if the expression returns a failed tResult
Definition result.h:88
Definition property_intf.h:213
Definition rawmemory_base.h:412
Definition stream_type_helper.h:31
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.
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(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(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 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
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 ChangeType(const filter::flash::cStreamTypeHelper &oType)
Emulates a stream type change during writing. Usually this happens if the content for the samples cha...
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.
~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
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 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 WriteSample(const ucom::ant::iobject_ptr< const streaming::ant::ISample > &pSample)
Writes the given sample into the writing stream.
void ChangeType(const filter::flash::cStreamTypeHelper &oType)
Emulates a stream type change during writing. Usually this happens if the content for the samples cha...
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.
std::set< uint32_t > GetCurrentRequests() const
Retrieve a copy of the current requested substream ids.
bool IsSubstreamRequested(uint32_t ui32SubStreamId) const
Determines if the given ui32SubStreamId was requested.
Base object pointer to realize binary compatible reference counting in interface methods.
Definition object_ptr_intf.h:112
Definition lockedobject_intf.h:207
Definition object_ptr.h:384
Namespace for all testing functionality of the ADTF Filter SDK provided since v3.6.
Definition output_recorder.h:30
Namespace for all testing functionality of the ADTF Filter SDK provided since v3.15.
Definition test_writer.h:193
Namespace for all testing functionality of the ADTF Filter SDK.
Definition create_default_triggers.h:17
Namespace for the ADTF Filter SDK.
Definition configurable_runner.h:18
tResult alloc_sample(ucom::ant::iobject_ptr< ucom::ant::IObject > &pSample)
object_ptr< T > ucom_object_ptr_cast(object_ptr< T > oCasted)
Alias always bringing the latest version of ant::ucom_object_ptr_cast() into scope.
Definition object_ptr_utilities.h:104
Namespace for all functionality provided by ADTF and its SDKs.
Definition adtf_client_connector.h:14
A timestamp with nanosecond precision.
Definition chrono.h:23
Use this Stream Meta Type only if no property should be set and you do not share and record these dat...
Definition streammetatypeanonymous.h:22