μHAL (v2.7.9)
Part of the IPbus software repository
Public Member Functions | Private Attributes | List of all members
uhal::Buffers Class Reference

A class wrapping the send and recieve buffers that are to be filled and transported and the validated memories associated with them. More...

#include <uhal/Buffers.hpp>

Public Member Functions

 Buffers (const uint32_t &aMaxSendSize=65536)
 Constructor. More...
 
virtual ~Buffers ()
 Destructor. More...
 
const uint32_t & sendCounter ()
 Get the number of bytes that are currently in the send buffer. More...
 
const uint32_t & replyCounter ()
 Get the number of bytes that are currently expected by the reply buffer. More...
 
template<typename T >
uint8_t * send (const T *aPtr)
 Helper function to copy an object to the send buffer. More...
 
template<typename T >
uint8_t * send (const T &aRef)
 Helper function to copy an object to the send buffer. More...
 
uint8_t * send (const uint8_t *aPtr, const uint32_t &aSize)
 Helper function to copy a block of memory to the send buffer. More...
 
template<typename T >
void receive (T *aPtr)
 Helper function to add a destination object to the reply queue. More...
 
template<typename T >
void receive (T &aRef)
 Helper function to add a destination object to the reply queue. More...
 
void receive (uint8_t *aPtr, const uint32_t &aSize)
 Helper function to add a destination memory location to the reply queue. More...
 
void add (const ValHeader &aValMem)
 Helper function to associate a validated memory with this buffer so that it is guaranteed to exist when the transaction is performed. More...
 
void add (const ValWord< uint32_t > &aValMem)
 Helper function to associate a validated memory with this buffer so that it is guaranteed to exist when the transaction is performed. More...
 
void add (const ValVector< uint32_t > &aValMem)
 Helper function to associate a validated memory with this buffer so that it is guaranteed to exist when the transaction is performed. More...
 
uint8_t * getSendBuffer ()
 Get a pointer to the start of the send buffer. More...
 
std::deque< std::pair< uint8_t *, uint32_t > > & getReplyBuffer ()
 Get a reference to the reply queue. More...
 
void validate ()
 Helper function to mark all validated memories associated with this buffer as valid. More...
 
void clear ()
 Clear the counters and the reply buffers. More...
 

Private Attributes

uint32_t mSendCounter
 The number of bytes that are currently in the send buffer. More...
 
uint32_t mReplyCounter
 The number of bytes that are currently expected by the reply buffer. More...
 
std::vector< uint8_t > mSendBuffer
 The start location of the memory buffer. More...
 
std::deque< std::pair< uint8_t *, uint32_t > > mReplyBuffer
 The queue of reply destinations. More...
 
std::deque< ValHeadermValHeaders
 Deque holding validated memories so that they are guaranteed to exist when the transaction is performed. More...
 
std::deque< ValWord< uint32_t > > mUnsignedValWords
 Deque holding validated memories so that they are guaranteed to exist when the transaction is performed. More...
 
std::deque< ValVector< uint32_t > > mUnsignedValVectors
 Deque holding validated memories so that they are guaranteed to exist when the transaction is performed. More...
 

Detailed Description

A class wrapping the send and recieve buffers that are to be filled and transported and the validated memories associated with them.

Definition at line 55 of file Buffers.hpp.

Constructor & Destructor Documentation

◆ Buffers()

uhal::Buffers::Buffers ( const uint32_t &  aMaxSendSize = 65536)

Constructor.

Parameters
aMaxSendSizeThe size of the buffer (in bytes) in the target device for receiving IPbus data packets from uhal.
Warning
Used to set internal buffer size, not for checking

Definition at line 42 of file Buffers.cpp.

◆ ~Buffers()

uhal::Buffers::~Buffers ( )
virtual

Destructor.

Definition at line 50 of file Buffers.cpp.

Member Function Documentation

◆ add() [1/3]

void uhal::Buffers::add ( const ValHeader aValMem)

Helper function to associate a validated memory with this buffer so that it is guaranteed to exist when the transaction is performed.

Parameters
aValMema validated memory to be associated with this buffer

Definition at line 81 of file Buffers.cpp.

References mValHeaders.

◆ add() [2/3]

void uhal::Buffers::add ( const ValVector< uint32_t > &  aValMem)

Helper function to associate a validated memory with this buffer so that it is guaranteed to exist when the transaction is performed.

Parameters
aValMema validated memory to be associated with this buffer

Definition at line 91 of file Buffers.cpp.

References mUnsignedValVectors.

◆ add() [3/3]

void uhal::Buffers::add ( const ValWord< uint32_t > &  aValMem)

Helper function to associate a validated memory with this buffer so that it is guaranteed to exist when the transaction is performed.

Parameters
aValMema validated memory to be associated with this buffer

Definition at line 86 of file Buffers.cpp.

References mUnsignedValWords.

◆ clear()

void uhal::Buffers::clear ( )

Clear the counters and the reply buffers.

Definition at line 126 of file Buffers.cpp.

References mReplyBuffer, mReplyCounter, mSendCounter, mUnsignedValVectors, mUnsignedValWords, and mValHeaders.

◆ getReplyBuffer()

std::deque< std::pair< uint8_t *, uint32_t > > & uhal::Buffers::getReplyBuffer ( )

Get a reference to the reply queue.

Returns
a reference to the reply queue

Definition at line 101 of file Buffers.cpp.

References mReplyBuffer.

◆ getSendBuffer()

uint8_t * uhal::Buffers::getSendBuffer ( )

Get a pointer to the start of the send buffer.

Returns
a pointer to the start of the send buffer

Definition at line 96 of file Buffers.cpp.

References mSendBuffer.

◆ receive() [1/3]

template<typename T >
void uhal::Buffers::receive ( T &  aRef)

Helper function to add a destination object to the reply queue.

Parameters
aRefa reference to some persistent object which can be written to when the transaction is performed

Definition at line 72 of file Buffers.hxx.

References mReplyBuffer, and mReplyCounter.

◆ receive() [2/3]

template<typename T >
void uhal::Buffers::receive ( T *  aPtr)

Helper function to add a destination object to the reply queue.

Parameters
aPtra pointer to some persistent object which can be written to when the transaction is performed

Definition at line 64 of file Buffers.hxx.

References mReplyBuffer, and mReplyCounter.

◆ receive() [3/3]

void uhal::Buffers::receive ( uint8_t *  aPtr,
const uint32_t &  aSize 
)

Helper function to add a destination memory location to the reply queue.

Parameters
aPtra pointer to some persistent memory which can be written to when the transaction is performed
aSizethe number of bytes which can be safely written

Definition at line 75 of file Buffers.cpp.

References mReplyBuffer, and mReplyCounter.

◆ replyCounter()

const uint32_t & uhal::Buffers::replyCounter ( )

Get the number of bytes that are currently expected by the reply buffer.

Returns
the number of bytes that are currently expected by the reply buffer

Definition at line 60 of file Buffers.cpp.

References mReplyCounter.

◆ send() [1/3]

template<typename T >
uint8_t * uhal::Buffers::send ( const T &  aRef)

Helper function to copy an object to the send buffer.

Parameters
aRefa reference to an object to be copied
Returns
a pointer to the copy of the object in the send buffer

Definition at line 54 of file Buffers.hxx.

References mSendBuffer, and mSendCounter.

◆ send() [2/3]

template<typename T >
uint8_t * uhal::Buffers::send ( const T *  aPtr)

Helper function to copy an object to the send buffer.

Parameters
aPtra pointer to an object to be copied
Returns
a pointer to the copy of the object in the send buffer

Definition at line 44 of file Buffers.hxx.

References mSendBuffer, and mSendCounter.

◆ send() [3/3]

uint8_t * uhal::Buffers::send ( const uint8_t *  aPtr,
const uint32_t &  aSize 
)

Helper function to copy a block of memory to the send buffer.

Parameters
aPtra pointer to the start of the memory to be copied
aSizethe number of bytes to be copied
Returns
a pointer to the copy of the memory block in the send buffer

Definition at line 66 of file Buffers.cpp.

References mSendBuffer, and mSendCounter.

◆ sendCounter()

const uint32_t & uhal::Buffers::sendCounter ( )

Get the number of bytes that are currently in the send buffer.

Returns
the number of bytes that are currently in the send buffer

Definition at line 55 of file Buffers.cpp.

References mSendCounter.

◆ validate()

void uhal::Buffers::validate ( )

Helper function to mark all validated memories associated with this buffer as valid.

Definition at line 107 of file Buffers.cpp.

References mUnsignedValVectors, mUnsignedValWords, and mValHeaders.

Member Data Documentation

◆ mReplyBuffer

std::deque< std::pair< uint8_t* , uint32_t > > uhal::Buffers::mReplyBuffer
private

The queue of reply destinations.

Definition at line 171 of file Buffers.hpp.

Referenced by clear(), getReplyBuffer(), and receive().

◆ mReplyCounter

uint32_t uhal::Buffers::mReplyCounter
private

The number of bytes that are currently expected by the reply buffer.

Definition at line 166 of file Buffers.hpp.

Referenced by clear(), receive(), and replyCounter().

◆ mSendBuffer

std::vector<uint8_t> uhal::Buffers::mSendBuffer
private

The start location of the memory buffer.

Definition at line 169 of file Buffers.hpp.

Referenced by getSendBuffer(), and send().

◆ mSendCounter

uint32_t uhal::Buffers::mSendCounter
private

The number of bytes that are currently in the send buffer.

Definition at line 164 of file Buffers.hpp.

Referenced by clear(), send(), and sendCounter().

◆ mUnsignedValVectors

std::deque< ValVector< uint32_t > > uhal::Buffers::mUnsignedValVectors
private

Deque holding validated memories so that they are guaranteed to exist when the transaction is performed.

Definition at line 178 of file Buffers.hpp.

Referenced by add(), clear(), and validate().

◆ mUnsignedValWords

std::deque< ValWord< uint32_t > > uhal::Buffers::mUnsignedValWords
private

Deque holding validated memories so that they are guaranteed to exist when the transaction is performed.

Definition at line 176 of file Buffers.hpp.

Referenced by add(), clear(), and validate().

◆ mValHeaders

std::deque< ValHeader > uhal::Buffers::mValHeaders
private

Deque holding validated memories so that they are guaranteed to exist when the transaction is performed.

Definition at line 174 of file Buffers.hpp.

Referenced by add(), clear(), and validate().


The documentation for this class was generated from the following files: