Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
Public Member Functions | List of all members
ska::cheetah::psrdada::detail::RawBytes Class Reference

Class for wrapping a raw pointer to a buffer of shared memory. More...

#include <cheetah/psrdada/detail/RawBytes.h>

Collaboration diagram for ska::cheetah::psrdada::detail::RawBytes:
Collaboration graph

Public Member Functions

 RawBytes (char *ptr, std::size_t total, std::size_t used=0)
 Create a new RawBytes instance. More...
 
 RawBytes (RawBytes const &)=delete
 
std::size_t total_bytes () const
 Get the total number of bytes in the buffer.
 
std::size_t used_bytes () const
 Get the number of currently used bytes in the buffer.
 
void used_bytes (std::size_t)
 Set the number of currently used bytes in the buffer. More...
 
char * ptr () const
 Get a raw pointer to the start of the buffer.
 

Detailed Description

Class for wrapping a raw pointer to a buffer of shared memory.

This class is used to wrap pointers to shared memory returned by calls to the lower-level DADA API.

This class is used to wrap buffers acquired by both reading and writing clients. For writing clients, it is necessary to set the number of bytes written using the used_bytes() method after writing. This value is used when releasing the buffer.

Definition at line 45 of file RawBytes.h.

Constructor & Destructor Documentation

◆ RawBytes()

ska::cheetah::psrdada::detail::RawBytes::RawBytes ( char *  ptr,
std::size_t  total,
std::size_t  used = 0 
)

Create a new RawBytes instance.

Parameters
ptrThe pointer to the buffer to wrap
[in]totalThe total number of bytes in the buffer
[in]usedThe number of bytes currently used in the buffer

Definition at line 33 of file RawBytes.cpp.

34  : _ptr(ptr)
35  , _total_bytes(total)
36  , _used_bytes(used)
37 {
38 }
char * ptr() const
Get a raw pointer to the start of the buffer.
Definition: RawBytes.cpp:59

Member Function Documentation

◆ used_bytes()

void ska::cheetah::psrdada::detail::RawBytes::used_bytes ( std::size_t  used)

Set the number of currently used bytes in the buffer.

For writing clients, this method should be called after all writes are complete so that the number of used_bytes can be passed to reading clients.

Definition at line 54 of file RawBytes.cpp.

55 {
56  _used_bytes = used;
57 }

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