ROSE
0.11.96.11
|
Buffer that has no data.
This can be useful to reserve areas of of a BufferMap address space without actually storing any data at them. All reads return default values and writes using such a buffer will fail (return zero).
Definition at line 26 of file NullBuffer.h.
#include <NullBuffer.h>
Public Types | |
typedef A | Address |
Type of addresses. | |
typedef T | Value |
Type of values. | |
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. More... | |
typedef A | Address |
Key type for addressing data. More... | |
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. More... | |
Address | available (Address start) const |
Distance to end of buffer. More... | |
void | resize (Address newSize) |
Change the size of the buffer. More... | |
Address | read (Value *buf, Address address, Address n) const |
Reads data from a buffer. More... | |
Address | write (const Value *, Address, Address) |
Writes data to a buffer. More... | |
const Value * | data () const |
Data for the buffer. More... | |
Public Member Functions inherited from Sawyer::Container::Buffer< A, T > | |
virtual Address | size () const |
Size of buffer. More... | |
virtual void | sync () |
Synchronize buffer with persistent storage. 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... | |
Static Public Member Functions | |
static Buffer< A, T >::Ptr | instance (Address size) |
Construct a new buffer. More... | |
Protected Member Functions | |
NullBuffer (Address size) | |
Protected Member Functions inherited from Sawyer::Container::Buffer< A, T > | |
Buffer (const std::string &name="") | |
|
inlinestatic |
Construct a new buffer.
The new buffer will act as if it contains size
values, although no values will actually be stored.
Definition at line 54 of file NullBuffer.h.
References Sawyer::Container::Buffer< A, T >::size().
Referenced by Sawyer::Container::NullBuffer< A, T >::copy().
|
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 58 of file NullBuffer.h.
References Sawyer::Container::NullBuffer< A, T >::instance().
|
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 62 of file NullBuffer.h.
Referenced by Sawyer::Container::NullBuffer< A, T >::read().
|
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 66 of file NullBuffer.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 70 of file NullBuffer.h.
References Sawyer::Container::NullBuffer< 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 79 of file NullBuffer.h.
|
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 83 of file NullBuffer.h.