ROSE
0.11.96.11
|
Base class for all buffers.
A buffer stores a sequence of elements somewhat like a vector, but imparts a read/write paradigm for accessing those elements.
#include <Buffer.h>
Public Types | |
typedef SharedPointer< Buffer > | Ptr |
Reference counting smart pointer. More... | |
typedef A | Address |
Key type for addressing data. More... | |
typedef T | Value |
Type of values stored in the buffer. | |
Public Member Functions | |
virtual Ptr | copy () const =0 |
Create a new copy of buffer data. More... | |
virtual Address | available (Address address) const =0 |
Distance to end of buffer. More... | |
virtual Address | size () const |
Size of buffer. More... | |
virtual void | resize (Address n)=0 |
Change the size of the buffer. More... | |
virtual void | sync () |
Synchronize buffer with persistent storage. More... | |
virtual Address | read (Value *buf, Address address, Address n) const =0 |
Reads data from a buffer. More... | |
virtual Address | write (const Value *buf, Address address, Address n)=0 |
Writes data to a buffer. More... | |
virtual const Value * | data () const =0 |
Data for the buffer. More... | |
const std::string & | name () const |
Property: Name. More... | |
void | name (const std::string &s) |
Property: Name. More... | |
bool | copyOnWrite () const |
Property: Copy on write. More... | |
void | copyOnWrite (bool b) |
Property: Copy on write. More... | |
Public Member Functions inherited from Sawyer::SharedObject | |
SharedObject () | |
Default constructor. More... | |
SharedObject (const SharedObject &) | |
Copy constructor. More... | |
virtual | ~SharedObject () |
Virtual destructor. More... | |
SharedObject & | operator= (const SharedObject &) |
Assignment. More... | |
Protected Member Functions | |
Buffer (const std::string &name="") | |
typedef SharedPointer<Buffer> Sawyer::Container::Buffer< A, T >::Ptr |
typedef A Sawyer::Container::Buffer< A, T >::Address |
|
pure virtual |
Create a new copy of buffer data.
Returns a new buffer containing the same data as the old buffer. Some buffer types cannot make an exact copy, in which case they should return an AllocatingBuffer that holds a snapshot of the source buffer's data as it existed at the time of this operation.
Implemented in Sawyer::Container::MappedBuffer< A, T >, Sawyer::Container::StaticBuffer< A, T >, Sawyer::Container::AllocatingBuffer< A, T >, and Sawyer::Container::NullBuffer< A, T >.
|
pure virtual |
Distance to end of buffer.
The distance in units of the Value type from the specified address (inclusive) to the last element of the buffer (inclusive). If the address is beyond the end of the buffer then a distance of zero is returned rather than a negative distance. Note that the return value will overflow to zero if the buffer spans the entire address space.
Implemented in Sawyer::Container::StaticBuffer< A, T >, Sawyer::Container::AllocatingBuffer< A, T >, Sawyer::Container::NullBuffer< A, T >, and Sawyer::Container::MappedBuffer< A, T >.
Referenced by Sawyer::Container::Buffer< size_t, char >::size().
|
inlinevirtual |
Size of buffer.
Returns the number of Value elements stored in the buffer. In other words, this is the first address beyond the end of the buffer. Note that the return value may overflow to zero if the buffer spans the entire address space.
Definition at line 76 of file Buffer.h.
Referenced by Sawyer::Container::AllocatingBuffer< A, T >::copy(), Sawyer::Container::MappedBuffer< A, T >::copy(), Sawyer::Container::NullBuffer< A, T >::instance(), Sawyer::Container::AllocatingBuffer< A, T >::instance(), Sawyer::Container::StaticBuffer< A, T >::instance(), and Sawyer::Container::MappedBuffer< A, T >::resize().
|
pure virtual |
Change the size of the buffer.
Truncates the buffer to a smaller size, or extends the buffer as necessary to make its size n
values.
Implemented in Sawyer::Container::StaticBuffer< A, T >, Sawyer::Container::AllocatingBuffer< A, T >, Sawyer::Container::NullBuffer< A, T >, and Sawyer::Container::MappedBuffer< A, T >.
|
inlinevirtual |
|
inline |
|
inline |
|
pure virtual |
Reads data from a buffer.
Reads up to n
values from this buffer beginning at the specified address and copies them to the caller-supplied argument. Returns the number of values actually copied, which may be smaller than the number requested. The output buffer is not zero-padded for short reads. Also note that the return value may overflow to zero if the entire address space is read.
As a special case, if buf
is a null pointer, then no data is copied and the return value indicates the number of values that would have been copied had buf
been non-null.
Implemented in Sawyer::Container::MappedBuffer< A, T >, Sawyer::Container::StaticBuffer< A, T >, Sawyer::Container::AllocatingBuffer< A, T >, and Sawyer::Container::NullBuffer< A, T >.
|
pure virtual |
Writes data to a buffer.
Writes up to n
values from buf
into this buffer starting at the specified address. Returns the number of values actually written, which might be smaller than n
. The return value will be less than n
if an error occurs, but note that the return value may overflow to zero if the entire address space is written.
Implemented in Sawyer::Container::MappedBuffer< A, T >, Sawyer::Container::StaticBuffer< A, T >, Sawyer::Container::AllocatingBuffer< A, T >, and Sawyer::Container::NullBuffer< A, T >.
|
pure virtual |
Data for the buffer.
Returns a pointer for the buffer data. Those subclasses that don't support this method will return the null pointer.
Implemented in Sawyer::Container::MappedBuffer< A, T >, Sawyer::Container::StaticBuffer< A, T >, Sawyer::Container::AllocatingBuffer< A, T >, and Sawyer::Container::NullBuffer< A, T >.
|
inline |
|
inline |