10 #include <type_traits>
45 Reset(oSampleData.m_pCurrentSample);
51 std::swap(m_pCurrentSample, oSampleData.m_pCurrentSample);
52 std::swap(m_pBuffer, oSampleData.m_pBuffer);
72 return m_pCurrentSample->GetTime();
88 return reinterpret_cast<const T*
>(m_pBuffer->GetPtr());
118 return (m_pCurrentSample && m_pBuffer && m_pBuffer->GetSize() >=
sizeof(T));
125 operator bool()
const
154 m_pCurrentSample = pSample;
166 m_pCurrentSample.
Reset();
192 static_assert(std::is_trivially_copyable<T>::value,
193 "You can only use plain types or structs without pointers or complex members.");
208 Reset(oSampleData.m_pCurrentSample);
214 std::swap(m_pCurrentSample, oSampleData.m_pCurrentSample);
215 std::swap(m_pBuffer, oSampleData.m_pBuffer);
226 Reset(ucom::ucom_object_ptr_cast<const ant::ISample>(pSample));
239 if (m_pCurrentSample)
241 return m_pCurrentSample->GetTime();
256 if (m_pCurrentSample)
275 return reinterpret_cast<const T*
>(m_pBuffer->GetPtr());
290 return m_pBuffer->GetSize();
330 static T oDefaultValue{};
331 return oDefaultValue;
350 return (m_pCurrentSample && m_pBuffer && m_pBuffer->GetSize() >=
sizeof(T));
359 operator const T&()
const
374 m_pCurrentSample = pSample;
386 m_pCurrentSample.
Reset();
400 if (m_pCurrentSample)
426 template<
typename T,
typename Enable=
void>
432 T m_oExtractedValue = {};
443 Reset(oSampleData.m_pCurrentSample);
448 m_pCurrentSample(std::move(oSampleData.m_pCurrentSample)),
449 m_pBuffer(std::move(oSampleData.m_pBuffer)),
450 m_oExtractedValue(std::move(oSampleData.m_oExtractedValue))
462 Reset(ucom::ucom_object_ptr_cast<const ant::ISample>(pSample));
475 if (m_pCurrentSample)
477 return m_pCurrentSample->GetTime();
492 if (m_pCurrentSample)
511 return &m_oExtractedValue;
526 return m_pBuffer->GetSize();
562 return m_oExtractedValue;
566 static T oDefaultValue {};
567 return oDefaultValue;
586 return (m_pCurrentSample && m_pBuffer && m_pBuffer->GetSize() >= 0);
596 operator const T&()
const
611 m_pCurrentSample = pSample;
625 m_oExtractedValue = T{};
626 m_pCurrentSample.
Reset();
640 if (m_pCurrentSample)
700 using penguin::sample_data;
tInt64 tTimeStamp
type definition for a time value.
#define RETURN_IF_FAILED(s)
Return if expression is failed, which requires the calling function's return type to be tResult.
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
A common result class usable as return value throughout.
adtf::util::cStringUtil::tHashKey32 tHashKey
Type for the HashKey of the Value.
Template class implementation for the ant::IRawMemory interface (see Supported types for adtf_memory<...
Sample Data getter for an easy use of samples with samplebuffer set to the type T.
tResult Reset()
Resets the sample the sample data reference to.
sample_data(sample_data &&oSampleData)
move CTOR
sample_data(const sample_data &oSampleData)
CTOR.
const T GetData() const
Retrieves the pointer to the datas memory as type T*.
tTimeStamp GetTime() const
retrieves the time of the data.
const T * GetDataPtr() const
Retrieves the pointer to the datas memory.
tResult Reset(const ucom::ant::iobject_ptr< const ISample > &pSample)
Resets the sample the sample data reference to with a new reference to a sample.
bool IsValid() const
Validate if sample and sample buffer is set.
sample_data(const ucom::iobject_ptr< const ISample > &pSample)
copy CTOR
Easy data access for input samples.
tResult Reset()
Resets the sample the sample data reference to.
sample_data(const ucom::iobject_ptr< const ant::ISample > &pSample)
copy CTOR
sample_data(sample_data &&oSampleData)
move CTOR
sample_data(const sample_data &oSampleData)
CTOR.
const T & operator*() const
Retrieves a reference to the data.
const T * operator->() const
Retrieves the pointer to the datas memory.
const T * operator->()
Retrieves the pointer to the datas memory.
adtf_util::cVariant GetSampleInfo(const ISampleInfo::tHashKey &oHash, const adtf::util::cVariant oDefault=adtf::util::cVariant()) const
Retrieves a variant value for the hash key oHash out of the samples sample information .
adtf::base::flash::tNanoSeconds GetTimeNs() const
retrieves the timestamp of the data.
tTimeStamp GetTime() const
retrieves the timestamp of the data.
const T * GetDataPtr() const
Retrieves the pointer to the datas memory.
bool IsValid() const
Validate if sample and sample buffer is set.
const T & GetData() const
Retrieves a reference to the data.
tResult Reset(const ucom::ant::iobject_ptr< const ant::ISample > &pSample)
Resets the sample the sample data reference to with a new reference to a sample.
size_t GetDataSize() const
sample_data(const ucom::iobject_ptr< const ant::ISample > &pSample)
copy CTOR
sample_data(sample_data &&oSampleData)
move CTOR
sample_data(const sample_data &oSampleData)
CTOR.
sample_data(const ucom::iobject_ptr< const flash::ISample > &pSample)
copy CTOR
Easy data access for input samples of non trivial type @T (see Supported types for adtf_memory<T> for...
tResult Reset()
Resets the sample the sample data reference to.
sample_data(const ucom::iobject_ptr< const ant::ISample > &pSample)
copy CTOR
sample_data(sample_data &&oSampleData)
move CTOR
sample_data(const sample_data &oSampleData)
CTOR.
const T & operator*() const
Retrieves a reference to the data.
const T * operator->() const
Retrieves the pointer to the datas memory.
const T * operator->()
Retrieves the pointer to the datas memory.
adtf_util::cVariant GetSampleInfo(const ISampleInfo::tHashKey &oHash, const adtf::util::cVariant oDefault=adtf::util::cVariant()) const
Retrieves a variant value for the hash key oHash out of the samples sample information .
adtf::base::flash::tNanoSeconds GetTimeNs() const
retrieves the timestamp of the data.
tTimeStamp GetTime() const
retrieves the timestamp of the data.
const T * GetDataPtr() const
Retrieves the pointer to the datas memory.
bool IsValid() const
Validate if sample and sample buffer is set.
const T & GetData() const
Retrieves a reference to the data.
tResult Reset(const ucom::ant::iobject_ptr< const ant::ISample > &pSample)
Resets the sample the sample data reference to with a new reference to a sample.
size_t GetDataSize() const
Base object pointer to realize binary compatible reference counting in interface methods.
Implementation for a shared lock guard.
Object pointer implementation used for reference counting on objects of type IObject.
void Reset()
Reset this object_ptr.
adtf::util::cVariant get_sample_info(const ISampleInfo &oSampleInfo, const ISampleInfo::tHashKey &oHash, const adtf::util::cVariant oDefault)
Retrieves a variant value for the hash key oHash out of the sample information oSampleInfo .
base::flash::tNanoSeconds get_sample_time(const ucom::ant::iobject_ptr< const ant::ISample > &pSample)
Returns the sample time stamp with nanosecond precision.
Namespace for entire ADTF SDK.
Copyright © Audi Electronics Venture GmbH.
A timestamp with nanosecond precision.