FrontPanel API 5.3.6
Loading...
Searching...
No Matches
OpalKelly::Buffer Class Reference

Fixed size buffer used for passing data to/from script functions. More...

Public Member Functions

 Buffer ()
 Default constructor creates an empty buffer.
 
 Buffer (size_t size)
 Allocates the specified amount of memory for the buffer.
 
 Buffer (void *ptr, size_t size)
 
 Buffer (const Buffer &buf)
 
Bufferoperator= (const Buffer &buf)
 
bool IsEmpty () const
 Return true if the buffer is empty.
 
size_t GetSize () const
 Return the fixed size of the buffer, possibly 0 if it is empty.
 
unsigned char * GetData () const
 

Detailed Description

Buffers are reference counted, meaning that while they can be assigned to each other, the assignment is shallow and all copies of the same buffer share the same data.

A buffer can either allocate and own its own memory or use some existing memory preallocated by the caller.

Constructor & Destructor Documentation

◆ Buffer() [1/2]

OpalKelly::Buffer::Buffer ( void * ptr,
size_t size )

Creates a buffer using the specified chunk of memory.

The buffer will not free ptr and it should remain valid for the entire life-time of the buffer (including any of its copies).

◆ Buffer() [2/2]

OpalKelly::Buffer::Buffer ( const Buffer & buf)

Create a shallow copy of the buffer.

Any modifications done to this buffer will also affect the original one.

Member Function Documentation

◆ GetData()

unsigned char * OpalKelly::Buffer::GetData ( ) const

Get direct access to the buffer contents.

Returns NULL if and only if the buffer is empty.

◆ operator=()

Buffer & OpalKelly::Buffer::operator= ( const Buffer & buf)

Assign another buffer to this one.

As with the copy constructor, this copy is shallow.


Copyright (c) 2005-2024 Opal Kelly Incorporated