ARC SDK
Data Structures | Public Member Functions | Data Fields
Arc::DataBuffer Class Reference

Represents set of buffers. More...

#include <arc/data/DataBuffer.h>

Public Member Functions

 operator bool () const
 Returns true if DataBuffer object is initialized. More...
 
 DataBuffer (unsigned int size=1048576, int blocks=3)
 Construct a new DataBuffer object. More...
 
 DataBuffer (CheckSum *cksum, unsigned int size=1048576, int blocks=3)
 Construct a new DataBuffer object with checksum computation. More...
 
 ~DataBuffer ()
 Destructor. More...
 
bool set (CheckSum *cksum=NULL, unsigned int size=1048576, int blocks=3)
 Reinitialize buffers with different parameters. More...
 
int add (CheckSum *cksum)
 Add a checksum object which will compute checksum of buffer. More...
 
char * operator[] (int n)
 Direct access to buffer by number. More...
 
bool for_read (int &handle, unsigned int &length, bool wait)
 Request buffer for READING INTO it. More...
 
bool for_read ()
 Check if there are buffers which can be taken by for_read(). More...
 
bool is_read (int handle, unsigned int length, unsigned long long int offset)
 Informs object that data was read into buffer. More...
 
bool is_read (char *buf, unsigned int length, unsigned long long int offset)
 Informs object that data was read into buffer. More...
 
bool for_write (int &handle, unsigned int &length, unsigned long long int &offset, bool wait)
 Request buffer for WRITING FROM it. More...
 
bool for_write ()
 Check if there are buffers which can be taken by for_write(). More...
 
bool is_written (int handle)
 Informs object that data was written from buffer. More...
 
bool is_written (char *buf)
 Informs object that data was written from buffer. More...
 
bool is_notwritten (int handle)
 Informs object that data was NOT written from buffer (and releases buffer). More...
 
bool is_notwritten (char *buf)
 Informs object that data was NOT written from buffer (and releases buffer). More...
 
void eof_read (bool v)
 Informs object if there will be no more request for 'read' buffers. More...
 
void eof_write (bool v)
 Informs object if there will be no more request for 'write' buffers. More...
 
void error_read (bool v)
 Informs object if error occurred on 'read' side. More...
 
void error_write (bool v)
 Informs object if error occurred on 'write' side. More...
 
bool eof_read ()
 Returns true if object was informed about end of transfer on 'read' side. More...
 
bool eof_write ()
 Returns true if object was informed about end of transfer on 'write' side. More...
 
bool error_read ()
 Returns true if object was informed about error on 'read' side. More...
 
bool error_write ()
 Returns true if object was informed about error on 'write' side. More...
 
bool error_transfer ()
 Returns true if transfer was slower than limits set in speed object. More...
 
bool error ()
 Returns true if object was informed about error or internal error occurred. More...
 
bool wait_any ()
 Wait (max 60 sec.) till any action happens in object. More...
 
bool wait_used ()
 Wait till there are no more used buffers left in object. More...
 
bool wait_for_read ()
 Wait till no more buffers taken for "READING INTO" left in object. More...
 
bool wait_for_write ()
 Wait till no more buffers taken for "WRITING FROM" left in object. More...
 
bool checksum_valid (int index) const
 Returns true if the specified checksum was successfully computed. More...
 
bool checksum_valid () const
 Returns true if the checksum was successfully computed. More...
 
const CheckSumchecksum_object (int index) const
 Returns CheckSum object at specified index or NULL if index is not in list. More...
 
const CheckSumchecksum_object () const
 Returns first checksum object in checksum list or NULL if list is empty. More...
 
bool wait_eof_read ()
 Wait until end of transfer happens on 'read' side. Always returns true. More...
 
bool wait_read ()
 Wait until end of transfer or error happens on 'read' side. Always returns true. More...
 
bool wait_eof_write ()
 Wait until end of transfer happens on 'write' side. Always returns true. More...
 
bool wait_write ()
 Wait until end of transfer or error happens on 'write' side. Always returns true. More...
 
bool wait_eof ()
 Wait until end of transfer happens on any side. Always returns true. More...
 
unsigned long long int eof_position () const
 Returns offset following last piece of data transferred. More...
 
unsigned int buffer_size () const
 Returns size of buffer in object. More...
 

Data Fields

DataSpeed speed
 This object controls transfer speed. More...
 

Detailed Description

Represents set of buffers.

This class is used during data transfer using DataPoint classes.

Constructor & Destructor Documentation

◆ DataBuffer() [1/2]

Arc::DataBuffer::DataBuffer ( unsigned int  size = 1048576,
int  blocks = 3 
)

Construct a new DataBuffer object.

Parameters
sizesize of every buffer in bytes.
blocksnumber of buffers.

◆ DataBuffer() [2/2]

Arc::DataBuffer::DataBuffer ( CheckSum cksum,
unsigned int  size = 1048576,
int  blocks = 3 
)

Construct a new DataBuffer object with checksum computation.

Parameters
sizesize of every buffer in bytes.
blocksnumber of buffers.
cksumobject which will compute checksum. Should not be destroyed until DataBuffer itself.

◆ ~DataBuffer()

Arc::DataBuffer::~DataBuffer ( )

Destructor.

Member Function Documentation

◆ add()

int Arc::DataBuffer::add ( CheckSum cksum)

Add a checksum object which will compute checksum of buffer.

Parameters
cksumobject which will compute checksum. Should not be destroyed until DataBuffer itself.
Returns
integer position in the list of checksum objects.

◆ buffer_size()

unsigned int Arc::DataBuffer::buffer_size ( ) const

Returns size of buffer in object.

If not initialized then this number represents size of default buffer.

◆ checksum_object() [1/2]

const CheckSum* Arc::DataBuffer::checksum_object ( int  index) const

Returns CheckSum object at specified index or NULL if index is not in list.

Parameters
indexof the checksum in question.

◆ checksum_object() [2/2]

const CheckSum* Arc::DataBuffer::checksum_object ( ) const

Returns first checksum object in checksum list or NULL if list is empty.

◆ checksum_valid() [1/2]

bool Arc::DataBuffer::checksum_valid ( int  index) const

Returns true if the specified checksum was successfully computed.

Parameters
indexof the checksum in question.
Returns
false if index is not in list

◆ checksum_valid() [2/2]

bool Arc::DataBuffer::checksum_valid ( ) const

Returns true if the checksum was successfully computed.

◆ eof_position()

unsigned long long int Arc::DataBuffer::eof_position ( ) const
inline

Returns offset following last piece of data transferred.

◆ eof_read() [1/2]

void Arc::DataBuffer::eof_read ( bool  v)

Informs object if there will be no more request for 'read' buffers.

Parameters
vtrue if no more requests.

◆ eof_read() [2/2]

bool Arc::DataBuffer::eof_read ( )

Returns true if object was informed about end of transfer on 'read' side.

◆ eof_write() [1/2]

void Arc::DataBuffer::eof_write ( bool  v)

Informs object if there will be no more request for 'write' buffers.

Parameters
vtrue if no more requests.

◆ eof_write() [2/2]

bool Arc::DataBuffer::eof_write ( )

Returns true if object was informed about end of transfer on 'write' side.

◆ error()

bool Arc::DataBuffer::error ( )

Returns true if object was informed about error or internal error occurred.

◆ error_read() [1/2]

void Arc::DataBuffer::error_read ( bool  v)

Informs object if error occurred on 'read' side.

Parameters
vtrue if error

◆ error_read() [2/2]

bool Arc::DataBuffer::error_read ( )

Returns true if object was informed about error on 'read' side.

◆ error_transfer()

bool Arc::DataBuffer::error_transfer ( )

Returns true if transfer was slower than limits set in speed object.

◆ error_write() [1/2]

void Arc::DataBuffer::error_write ( bool  v)

Informs object if error occurred on 'write' side.

Parameters
vtrue if error

◆ error_write() [2/2]

bool Arc::DataBuffer::error_write ( )

Returns true if object was informed about error on 'write' side.

◆ for_read() [1/2]

bool Arc::DataBuffer::for_read ( int &  handle,
unsigned int &  length,
bool  wait 
)

Request buffer for READING INTO it.

Should be called when data is being read from a source. The calling code should write data into the returned buffer and then call is_read().

Parameters
handlefilled with buffer's number.
lengthfilled with size of buffer
waitif true and there are no free buffers, method will wait for one.
Returns
true on success For python bindings pattern of this method is (bool, handle, length) for_read(wait). Here buffer for reading to be provided by external code and provided to DataBuffer object through is_read() method. Content of buffer must not exceed provided length.
Python interface deviation
Method is unavailable in Python interface

◆ for_read() [2/2]

bool Arc::DataBuffer::for_read ( )

Check if there are buffers which can be taken by for_read().

This function checks only for buffers and does not take eof and error conditions into account.

Returns
true if buffers are available

◆ for_write() [1/2]

bool Arc::DataBuffer::for_write ( int &  handle,
unsigned int &  length,
unsigned long long int &  offset,
bool  wait 
)

Request buffer for WRITING FROM it.

Should be called when data is being written to a destination. The calling code should write the data contained in the returned buffer and then call is_written().

Parameters
handlereturns buffer's number.
lengthreturns size of buffer
offsetreturns buffer offset
waitif true and there are no available buffers, method will wait for one.
Returns
true on success For python bindings pattern of this method is (bool, handle, length, offset, buffer) for_write(wait). Here buffer is string with content of buffer provided by DataBuffer object.
Python interface deviation
Method is unavailable in Python interface

◆ for_write() [2/2]

bool Arc::DataBuffer::for_write ( )

Check if there are buffers which can be taken by for_write().

This function checks only for buffers and does not take eof and error conditions into account.

Returns
true if buffers are available

◆ is_notwritten() [1/2]

bool Arc::DataBuffer::is_notwritten ( int  handle)

Informs object that data was NOT written from buffer (and releases buffer).

Parameters
handlebuffer's number.
Returns
true if buffer was successfully informed

◆ is_notwritten() [2/2]

bool Arc::DataBuffer::is_notwritten ( char *  buf)

Informs object that data was NOT written from buffer (and releases buffer).

Parameters
buf- address of buffer
Returns
true if buffer was successfully informed
Python interface deviation
Method is unavailable in Python interface

◆ is_read() [1/2]

bool Arc::DataBuffer::is_read ( int  handle,
unsigned int  length,
unsigned long long int  offset 
)

Informs object that data was read into buffer.

Parameters
handlebuffer's number.
lengthamount of data.
offsetoffset in stream, file, etc.
Returns
true if buffer was successfully informed For python bindings pattern of that method is bool is_read(handle,buffer,offset). Here buffer is string containing content of buffer to be passed to DataBuffer object.
Python interface deviation
Method is unavailable in Python interface

◆ is_read() [2/2]

bool Arc::DataBuffer::is_read ( char *  buf,
unsigned int  length,
unsigned long long int  offset 
)

Informs object that data was read into buffer.

Parameters
bufaddress of buffer
lengthamount of data.
offsetoffset in stream, file, etc.
Returns
true if buffer was successfully informed
Python interface deviation
Method is unavailable in Python interface

◆ is_written() [1/2]

bool Arc::DataBuffer::is_written ( int  handle)

Informs object that data was written from buffer.

Parameters
handlebuffer's number.
Returns
true if buffer was successfully informed

◆ is_written() [2/2]

bool Arc::DataBuffer::is_written ( char *  buf)

Informs object that data was written from buffer.

Parameters
buf- address of buffer
Returns
true if buffer was successfully informed
Python interface deviation
Method is unavailable in Python interface

◆ operator bool()

Arc::DataBuffer::operator bool ( ) const
inline

Returns true if DataBuffer object is initialized.

◆ operator[]()

char* Arc::DataBuffer::operator[] ( int  n)

Direct access to buffer by number.

Parameters
nbuffer number
Returns
buffer content
Python interface deviation
Method is unavailable in Python interface

◆ set()

bool Arc::DataBuffer::set ( CheckSum cksum = NULL,
unsigned int  size = 1048576,
int  blocks = 3 
)

Reinitialize buffers with different parameters.

Parameters
sizesize of every buffer in bytes.
blocksnumber of buffers.
cksumobject which will compute checksum. Should not be destroyed until DataBuffer itself.
Returns
true if buffers were successfully initialized

◆ wait_any()

bool Arc::DataBuffer::wait_any ( )

Wait (max 60 sec.) till any action happens in object.

Returns
true if action is eof on any side

◆ wait_eof()

bool Arc::DataBuffer::wait_eof ( )

Wait until end of transfer happens on any side. Always returns true.

◆ wait_eof_read()

bool Arc::DataBuffer::wait_eof_read ( )

Wait until end of transfer happens on 'read' side. Always returns true.

◆ wait_eof_write()

bool Arc::DataBuffer::wait_eof_write ( )

Wait until end of transfer happens on 'write' side. Always returns true.

◆ wait_for_read()

bool Arc::DataBuffer::wait_for_read ( )

Wait till no more buffers taken for "READING INTO" left in object.

Returns
true if an error occurred while waiting

◆ wait_for_write()

bool Arc::DataBuffer::wait_for_write ( )

Wait till no more buffers taken for "WRITING FROM" left in object.

Returns
true if an error occurred while waiting

◆ wait_read()

bool Arc::DataBuffer::wait_read ( )

Wait until end of transfer or error happens on 'read' side. Always returns true.

◆ wait_used()

bool Arc::DataBuffer::wait_used ( )

Wait till there are no more used buffers left in object.

Returns
true if an error occurred while waiting

◆ wait_write()

bool Arc::DataBuffer::wait_write ( )

Wait until end of transfer or error happens on 'write' side. Always returns true.

Field Documentation

◆ speed

DataSpeed Arc::DataBuffer::speed

This object controls transfer speed.


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