31#ifndef DW_FRAMEWORK_MANAGEDPORT_HPP_
32#define DW_FRAMEWORK_MANAGEDPORT_HPP_
38#include <dw/core/language/Optional.hpp>
39#include <dw/core/container/RingBuffer.hpp>
40#include <dw/core/language/Function.hpp>
83 virtual bool isBound() const noexcept = 0;
130 bool syncEnabled =
false;
166 void setCallbackBeforeSend(
dw::core::Function<dwStatus()> callback);
187 void sendAdvTimestamp();
200 dw::core::Function<dwStatus()> m_callbackBeforeSend;
201 uint32_t m_sendSeqNum;
217 uint32_t maxBuffers = 1U;
223 dwTime_t waitTime = 0;
237 bool enableReuse =
false;
242 bool syncEnabled =
false;
247 uint32_t dataOffset = 0U;
294 bool isBufferAvailable() const noexcept;
304 void setCallbackAfterRecv(
dw::core::Function<dwStatus()> callback);
315 void sendAdvTimestamp();
321 void releaseToChannel(
void* data);
325 bool recvSingle(dwTime_t waitTime);
326 bool stashConsumed();
328 void handleReuseDrop();
330 void releaseSingle();
331 bool postProcessLockstepReplayData(
GenericData packet);
332 dwTime_t getWaitTime();
339 bool m_shouldDropFirstBuffer;
340 dw::core::Function<dwStatus()> m_callbackAfterRecv;
355 T* ptr = metadataPacket->data.template getData<T>();
359 throw ExceptionWithStatus(DW_INVALID_ARGUMENT,
"getBufferTyped: type mismatch");
373 "Channel packet type not declared. Ensure channel packet type "
374 "handling is declared with DWFRAMEWORK_DECLARE_PACKET_TYPE_RELATION");
422 return detail::getBufferTyped<T>(getBufferGeneric());
433 "Channel packet type not declared. Ensure channel packet type "
434 "handling is declared with DWFRAMEWORK_DECLARE_PACKET_TYPE_RELATION");
437 struct PacketDeleter;
460 return iterable(*
this);
470 return detail::getBufferTyped<T>(getBufferGeneric());
481 return isBufferAvailable() ? getBuffer() :
nullptr;
489 auto* ptr = detail::getBufferTyped<T>(packet);
497 void operator()(T* p)
500 port->releaseToChannel(releasePtr);
502 ManagedPortInput* port;
508 explicit iterable(ManagedPortInput<T>& port)
517 class iterator :
public ManagedPortInputBase::RingBuffer::iterator
519 using Base = ManagedPortInputBase::RingBuffer::iterator;
538 return detail::getBufferTyped<TT>(buffer);
546 iterator<T> begin() {
return iterator<T>(m_port.m_buffers.begin(), m_port); }
549 iterator<T> end() {
return iterator<T>(m_port.m_buffers.end(), m_port); }
552 iterator<const T> begin()
const {
return iterator<const T>(m_port.m_buffers.begin(), m_port); }
555 iterator<const T> end()
const {
return iterator<const T>(m_port.m_buffers.end(), m_port); }
558 ManagedPortInput<T>& m_port;
void * getPointer() const
ManagedPortBase & operator=(ManagedPortBase &&other)=delete
virtual bool isBound() const noexcept=0
virtual ~ManagedPortBase()=default
ManagedPortBase(const ManagedPortBase &other)=delete
virtual void bindChannel(ChannelObject *channel)=0
ChannelObject * getChannel()
ChannelObject * m_channel
ManagedPortBase(ManagedPortBase &&other)=delete
ManagedPortBase & operator=(const ManagedPortBase &other)=delete
void bindLockstepSyncClient(dw::framework::lockstep::ILockstepSyncClient *syncClient)
dw::framework::lockstep::ILockstepSyncClient * m_lockstepSyncClient
void setCycleCount(uint32_t cycleCount)
void setPeriod(uint32_t period)
ConstructProperties constructProperties
BoundProperties boundProperties
bool isBufferAvailable() const noexcept
ManagedPortOutput(ConstructProperties props)
ManagedPortOutput(SpecimenT &ref)
ManagedPortOutput(ConstructProperties props, SpecimenT &ref)
static GenericDataReference make_specimen(typename parameter_traits< T >::SpecimenT *specimen)
MetadataPayload * extractMetadata(GenericData packet)
constexpr ChannelPacketTypeID DWFRAMEWORK_PACKET_ID_DEFAULT
typename ManagedPortInput< T >::UniquePacketPtr UniquePacketPtr