An abstraction for a block of bytes, with optional responsibility for allocating/destroying that block. More...
#include <yarp/os/ManagedBytes.h>
Public Member Functions | |
ManagedBytes () | |
Constructor. More... | |
ManagedBytes (size_t len) | |
Constructor. More... | |
ManagedBytes (const Bytes &ext, bool owned=false) | |
Constructor. More... | |
ManagedBytes (ManagedBytes &&other) noexcept | |
Move constructor. More... | |
ManagedBytes & | operator= (ManagedBytes &&other) noexcept |
Move assignment operator. More... | |
ManagedBytes (const ManagedBytes &alt) | |
Copy constructor. More... | |
const ManagedBytes & | operator= (const ManagedBytes &alt) |
Assignment operator. More... | |
virtual | ~ManagedBytes () |
Destructor. More... | |
void | allocate (size_t len) |
Makes a data block of the specified length that will be deleted if this object is destroyed. More... | |
bool | allocateOnNeed (size_t neededLen, size_t allocateLen) |
void | copy () |
Makes sure data block is owned, making a copy if necessary. More... | |
size_t | length () const |
size_t | used () const |
const char * | get () const |
char * | get () |
void | clear () |
Disassociate object with any data block (deleting block if appropriate). More... | |
const Bytes & | bytes () const |
Bytes & | bytes () |
Bytes | usedBytes () |
size_t | setUsed (size_t used) |
explicitly declare how many of the bytes are in use. More... | |
size_t | resetUsed () |
bool | read (ConnectionReader &reader) override |
Read this object from a network connection. More... | |
bool | write (ConnectionWriter &writer) const override |
Write this object to a network connection. More... | |
bool | isOwner () const |
Public Member Functions inherited from yarp::os::Portable | |
virtual Type | getType () const |
Public Member Functions inherited from yarp::os::PortReader | |
virtual | ~PortReader () |
Destructor. More... | |
virtual Type | getReadType () const |
Public Member Functions inherited from yarp::os::PortWriter | |
virtual | ~PortWriter () |
Destructor. More... | |
virtual void | onCompletion () const |
This is called when the port has finished all writing operations. More... | |
virtual void | onCommencement () const |
This is called when the port is about to begin writing operations. More... | |
virtual yarp::os::Type | getWriteType () const |
Additional Inherited Members | |
Static Public Member Functions inherited from yarp::os::Portable | |
static bool | copyPortable (const PortWriter &writer, PortReader &reader) |
Copy one portable to another, via writing and reading. More... | |
An abstraction for a block of bytes, with optional responsibility for allocating/destroying that block.
Definition at line 24 of file ManagedBytes.h.
|
explicit |
|
explicit |
Constructor.
Makes a data block of the specified length that will be deleted if this object is destroyed.
len | length of data block |
Definition at line 30 of file ManagedBytes.cpp.
ManagedBytes::ManagedBytes | ( | const Bytes & | ext, |
bool | owned = false |
||
) |
Constructor.
Represent external data.
ext | address and length of data |
owned | true if data should be deleted if this object is destroyed |
Definition at line 39 of file ManagedBytes.cpp.
|
noexcept |
Move constructor.
other | the ManagedBytes to be moved |
Definition at line 70 of file ManagedBytes.cpp.
ManagedBytes::ManagedBytes | ( | const ManagedBytes & | alt | ) |
Copy constructor.
alt | the data to copy. If it is "owned" an independent copy is made. |
Definition at line 48 of file ManagedBytes.cpp.
|
virtual |
Destructor.
Definition at line 99 of file ManagedBytes.cpp.
void ManagedBytes::allocate | ( | size_t | len | ) |
Makes a data block of the specified length that will be deleted if this object is destroyed.
len | length of data block |
Definition at line 105 of file ManagedBytes.cpp.
bool ManagedBytes::allocateOnNeed | ( | size_t | neededLen, |
size_t | allocateLen | ||
) |
Definition at line 115 of file ManagedBytes.cpp.
Bytes & ManagedBytes::bytes | ( | ) |
Definition at line 182 of file ManagedBytes.cpp.
const Bytes & ManagedBytes::bytes | ( | ) | const |
Definition at line 177 of file ManagedBytes.cpp.
void ManagedBytes::clear | ( | ) |
Disassociate object with any data block (deleting block if appropriate).
Definition at line 164 of file ManagedBytes.cpp.
void ManagedBytes::copy | ( | ) |
Makes sure data block is owned, making a copy if necessary.
Definition at line 132 of file ManagedBytes.cpp.
char * ManagedBytes::get | ( | ) |
Definition at line 159 of file ManagedBytes.cpp.
const char * ManagedBytes::get | ( | ) | const |
Definition at line 154 of file ManagedBytes.cpp.
|
inline |
Definition at line 161 of file ManagedBytes.h.
size_t ManagedBytes::length | ( | ) | const |
Definition at line 144 of file ManagedBytes.cpp.
const ManagedBytes & ManagedBytes::operator= | ( | const ManagedBytes & | alt | ) |
Assignment operator.
alt | the data to copy. If it is "owned" an independent copy is made. |
Definition at line 84 of file ManagedBytes.cpp.
|
noexcept |
Move assignment operator.
other | the MangedBytes to be moved |
Definition at line 75 of file ManagedBytes.cpp.
|
overridevirtual |
Read this object from a network connection.
Override this for your particular class.
reader | an interface to the network connection for reading |
Implements yarp::os::Portable.
Definition at line 207 of file ManagedBytes.cpp.
size_t ManagedBytes::resetUsed | ( | ) |
Definition at line 199 of file ManagedBytes.cpp.
size_t ManagedBytes::setUsed | ( | size_t | used | ) |
explicitly declare how many of the bytes are in use.
used | byte count |
Definition at line 192 of file ManagedBytes.cpp.
size_t ManagedBytes::used | ( | ) | const |
Definition at line 149 of file ManagedBytes.cpp.
Bytes ManagedBytes::usedBytes | ( | ) |
Definition at line 187 of file ManagedBytes.cpp.
|
overridevirtual |
Write this object to a network connection.
Override this for your particular class. Be aware that depending on the nature of the connections a port has, and what protocol they use, and how efficient the YARP implementation is, this method may be called once, twice, or many times, as the result of a single call to Port::write
writer | an interface to the network connection for writing |
Implements yarp::os::Portable.
Definition at line 229 of file ManagedBytes.cpp.