ROSE 0.11.145.192
|
Allocates memory as needed.
Allocates as many elements as requested and manages the storage. There is no requirement that the elements be contiguous in memory, although this implementation does it that way.
Definition at line 35 of file AllocatingBuffer.h.
#include <Sawyer/AllocatingBuffer.h>
Public Types | |
typedef A | Address |
Type of addresses used to index the stored data. | |
typedef T | Value |
Type of data that is stored. | |
typedef Buffer< A, T > | Super |
Type of base class. | |
Public Types inherited from Sawyer::Container::Buffer< A, T > | |
typedef SharedPointer< Buffer > | Ptr |
Reference counting smart pointer. | |
typedef A | Address |
Key type for addressing data. | |
typedef T | Value |
Type of values stored in the buffer. | |
Public Member Functions | |
Buffer< A, T >::Ptr | copy () const |
Create a new copy of buffer data. | |
Address | available (Address start) const |
Distance to end of buffer. | |
void | resize (Address newSize) |
Change the size of the buffer. | |
Address | read (Value *buf, Address address, Address n) const |
Reads data from a buffer. | |
Address | write (const Value *buf, Address address, Address n) |
Writes data to a buffer. | |
const Value * | data () const |
Data for the buffer. | |
Public Member Functions inherited from Sawyer::Container::Buffer< A, T > | |
virtual Address | size () const |
Size of buffer. | |
virtual void | sync () |
Synchronize buffer with persistent storage. | |
const std::string & | name () const |
Property: Name. | |
void | name (const std::string &s) |
Property: Name. | |
bool | copyOnWrite () const |
Property: Copy on write. | |
void | copyOnWrite (bool b) |
Property: Copy on write. | |
Public Member Functions inherited from Sawyer::SharedObject | |
SharedObject () | |
Default constructor. | |
SharedObject (const SharedObject &) | |
Copy constructor. | |
virtual | ~SharedObject () |
Virtual destructor. | |
SharedObject & | operator= (const SharedObject &) |
Assignment. | |
Static Public Member Functions | |
static Buffer< A, T >::Ptr | instance (Address size) |
Allocating constructor. | |
static Buffer< A, T >::Ptr | instance (const std::string &s) |
Allocating constructor. | |
Protected Member Functions | |
AllocatingBuffer (Address size=0) | |
Protected Member Functions inherited from Sawyer::Container::Buffer< A, T > | |
Buffer (const std::string &name="") | |
typedef A Sawyer::Container::AllocatingBuffer< A, T >::Address |
Type of addresses used to index the stored data.
Definition at line 37 of file AllocatingBuffer.h.
typedef T Sawyer::Container::AllocatingBuffer< A, T >::Value |
Type of data that is stored.
Definition at line 38 of file AllocatingBuffer.h.
typedef Buffer<A, T> Sawyer::Container::AllocatingBuffer< A, T >::Super |
Type of base class.
Definition at line 39 of file AllocatingBuffer.h.
|
inlineexplicitprotected |
Definition at line 69 of file AllocatingBuffer.h.
|
inlinestatic |
Allocating constructor.
Allocates a new buffer of the specified size. The values in the buffer are default-constructed, and deleted when this buffer is deleted.
Definition at line 76 of file AllocatingBuffer.h.
References Sawyer::Container::Buffer< A, T >::size().
Referenced by Sawyer::Container::AllocatingBuffer< A, T >::copy(), Sawyer::Container::MappedBuffer< A, T >::copy(), and Sawyer::Container::StaticBuffer< A, T >::copy().
|
inlinestatic |
Allocating constructor.
Allocates a new buffer that points to a copy of the specified string.
Definition at line 83 of file AllocatingBuffer.h.
|
inlinevirtual |
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.
Implements Sawyer::Container::Buffer< A, T >.
Definition at line 89 of file AllocatingBuffer.h.
References Sawyer::Container::AllocatingBuffer< A, T >::instance(), and Sawyer::Container::Buffer< A, T >::size().
|
inlinevirtual |
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.
Implements Sawyer::Container::Buffer< A, T >.
Definition at line 101 of file AllocatingBuffer.h.
Referenced by Sawyer::Container::AllocatingBuffer< A, T >::read(), and Sawyer::Container::AllocatingBuffer< A, T >::write().
|
inlinevirtual |
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.
Implements Sawyer::Container::Buffer< A, T >.
Definition at line 105 of file AllocatingBuffer.h.
|
inlinevirtual |
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.
Implements Sawyer::Container::Buffer< A, T >.
Definition at line 109 of file AllocatingBuffer.h.
References Sawyer::Container::AllocatingBuffer< A, T >::available().
|
inlinevirtual |
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.
Implements Sawyer::Container::Buffer< A, T >.
Definition at line 116 of file AllocatingBuffer.h.
References Sawyer::Container::AllocatingBuffer< A, T >::available().
|
inlinevirtual |
Data for the buffer.
Returns a pointer for the buffer data. Those subclasses that don't support this method will return the null pointer.
Implements Sawyer::Container::Buffer< A, T >.
Definition at line 123 of file AllocatingBuffer.h.