#include <coherence/io/DelegatingWriteBuffer.hpp>
Inherits AbstractWriteBuffer.
Basically, it allows a process that is writing to a WriteBuffer to ask for a "protected" sub-portion of that WriteBuffer to hand to a second process, such that the second process can not affect (or even read from) the WriteBuffer outside of the portion that the first process explicitly designated as viewable and modifiable.
This implementation is explicitly not thread-safe.
Public Types | |||||||||||||||||||
typedef spec::Handle | Handle | ||||||||||||||||||
DelegatingWriteBuffer Handle definition. | |||||||||||||||||||
typedef spec::View | View | ||||||||||||||||||
DelegatingWriteBuffer View definition. | |||||||||||||||||||
typedef spec::Holder | Holder | ||||||||||||||||||
DelegatingWriteBuffer Holder definition. | |||||||||||||||||||
typedef this_spec::Handle | Handle | ||||||||||||||||||
AbstractWriteBuffer Handle definition. | |||||||||||||||||||
typedef this_spec::View | View | ||||||||||||||||||
AbstractWriteBuffer View definition. | |||||||||||||||||||
typedef this_spec::Holder | Holder | ||||||||||||||||||
AbstractWriteBuffer Holder definition. | |||||||||||||||||||
Public Member Functions | |||||||||||||||||||
virtual size32_t | length () const | ||||||||||||||||||
Determine the length of the data that is in the buffer. This is the actual number of octets of data that have been written to the buffer, not the capacity of the buffer.
| |||||||||||||||||||
virtual size32_t | getCapacity () const | ||||||||||||||||||
Determine the number of octets that the buffer can hold without resizing itself.
In other words, a WriteBuffer has Note that if the maximum size returned by getMaximumCapacity() is greater than the current size returned by this method, then the WriteBuffer will automatically resize itself to allocate more space when the amount of data written to it passes the current size.
| |||||||||||||||||||
virtual size32_t | getMaximumCapacity () const | ||||||||||||||||||
Determine the maximum number of octets that the buffer can hold. If the maximum size is greater than the current size, then the buffer is expected to resize itself as necessary up to the maximum size in order to contain the data given to it.
| |||||||||||||||||||
virtual void | write (size32_t ofDest, octet_t b) | ||||||||||||||||||
Store the specified octet at the specified offset within the buffer. For purposes of side-effects and potential exceptions, this method is functionally equivalent to the following code:
| |||||||||||||||||||
virtual void | write (size32_t ofDest, Array< octet_t >::View vabSrc, size32_t ofSrc, size32_t cbSrc) | ||||||||||||||||||
Store the specified number of octets from the specified location within the passed octet array at the specified offset within this buffer.
As a result of this method, the buffer length as reported by the
As a result of this method, the buffer capacity as reported by the
| |||||||||||||||||||
virtual void | write (size32_t ofDest, ReadBuffer::View vBufSrc, size32_t ofSrc, size32_t cbSrc) | ||||||||||||||||||
Store the specified portion of the contents of the specified ReadBuffer at the specified offset within this buffer. For purposes of side-effects and potential exceptions, this method is functionally equivalent to the following code:
| |||||||||||||||||||
virtual void | retain (size32_t of, size32_t cb) | ||||||||||||||||||
Starting with the octet at offset of , retain cb octets in this WriteBuffer, such that the octet at offset of is shifted to offset 0, the octet at offset of + 1 is shifted to offset 1, and so on up to the octet at offset of + cb - 1 , which is shifted to offset cb - 1 .
After this method, the length of the buffer as indicated by the length() method will be equal to
Legal values for the offset of the first octet to retain
If The effect on the capacity of the buffer is implementation- specific; some implementations are expected to retain the same capacity while others are expected to shrink accordingly.
| |||||||||||||||||||
virtual void | clear () | ||||||||||||||||||
Set the length of the buffer as indicated by the length() method to zero.
The effect on the capacity of the buffer is implementation-specific; some implementations are expected to retain the same capacity while others are expected to shrink accordingly. | |||||||||||||||||||
virtual ReadBuffer::View | getUnsafeReadBuffer () const | ||||||||||||||||||
Get a ReadBuffer object to read data from this buffer. This method is not guaranteed to return a snapshot of this buffer's data, nor is it guaranteed to return a live view of this buffer, which means that subsequent changes to this WriteBuffer may or may not affect the contents and / or the length of the returned ReadBuffer. To get a snapshot, use the getReadBuffer() method.
| |||||||||||||||||||
virtual Array < octet_t >::View | toOctetArray () const | ||||||||||||||||||
Returns an octet array that holds the complete contents of this WriteBuffer. This method is functionally equivalent to the following code:
| |||||||||||||||||||
Protected Member Functions | |||||||||||||||||||
DelegatingWriteBuffer (WriteBuffer::Handle hBuf, size32_t of, size32_t cb) | |||||||||||||||||||
Construct a DelegatingWriteBuffer that will delegate to the containing WriteBuffer. | |||||||||||||||||||
DelegatingWriteBuffer (const DelegatingWriteBuffer &that) | |||||||||||||||||||
Copy constructor. | |||||||||||||||||||
virtual BufferOutput::Handle | instantiateBufferOutput () | ||||||||||||||||||
Factory method: Instantiate a BufferOutput object to write data to the WriteBuffer.
| |||||||||||||||||||
virtual void | checkBounds (size32_t of, size32_t cb) const | ||||||||||||||||||
Test an offset and length of data to write to see if it can be written to this buffer. | |||||||||||||||||||
virtual void | updateLength (size32_t cb) | ||||||||||||||||||
Update the length if the passed length is greater than the current buffer length. | |||||||||||||||||||
Protected Attributes | |||||||||||||||||||
FinalHandle < WriteBuffer > | f_hBuf | ||||||||||||||||||
The WriteBuffer to delegate to; the "containing" WriteBuffer. | |||||||||||||||||||
size32_t | m_ofStart | ||||||||||||||||||
Offset into the containing WriteBuffer where this WriteBuffer starts. | |||||||||||||||||||
size32_t | m_cb | ||||||||||||||||||
Length in octets of this WriteBuffer. | |||||||||||||||||||
size32_t | m_cbMax | ||||||||||||||||||
Maximum number of octets in this WriteBuffer. | |||||||||||||||||||
Classes | |||||||||||||||||||
class | DelegatingBufferOutput | ||||||||||||||||||
A BufferOutput implementation that delegates to a BufferOutput implementation, except that its offset range is shifted and limited. More... |
DelegatingWriteBuffer | ( | WriteBuffer::Handle | hBuf, | |
size32_t | of, | |||
size32_t | cb | |||
) | [protected] |
Construct a DelegatingWriteBuffer that will delegate to the containing WriteBuffer.
hBuf | the containing WriteBuffer | |
of | the offset within the containing WriteBuffer that this WriteBuffer is starting at | |
cb | the maximum capacity for this WriteBuffer |
virtual void checkBounds | ( | size32_t | of, | |
size32_t | cb | |||
) | const [protected, virtual] |
Test an offset and length of data to write to see if it can be written to this buffer.
of | offset to write data at | |
cb | length in octets of data |
virtual void updateLength | ( | size32_t | cb | ) | [protected, virtual] |
Update the length if the passed length is greater than the current buffer length.
cb | the possible new length |