ROSE 0.11.145.192
Public Types | Public Member Functions | Protected Member Functions | List of all members
Sawyer::Container::StaticBuffer< A, T > Class Template Reference

Description

template<class A, class T>
class Sawyer::Container::StaticBuffer< A, T >

Points to static data.

This buffer object points to storage which is not owned by this object and which is therefore not deleted when this object is deleted.

Definition at line 32 of file StaticBuffer.h.

#include <Sawyer/StaticBuffer.h>

Inheritance diagram for Sawyer::Container::StaticBuffer< A, T >:
Inheritance graph
[legend]
Collaboration diagram for Sawyer::Container::StaticBuffer< A, T >:
Collaboration graph
[legend]

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< BufferPtr
 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

bool isReadOnly () const
 True if the buffer is read-only.
 
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 Valuedata () 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.
 
SharedObjectoperator= (const SharedObject &)
 Assignment.
 

Static Public Member Functions

static Buffer< A, T >::Ptr instance (Value *values, Address size)
 Construct from caller-supplied data.
 
static Buffer< A, T >::Ptr instance (const Value *values, Address size)
 Construct from caller-supplied data.
 

Protected Member Functions

 StaticBuffer (Value *values, Address size)
 
 StaticBuffer (const Value *values, Address size)
 
- Protected Member Functions inherited from Sawyer::Container::Buffer< A, T >
 Buffer (const std::string &name="")
 

Member Typedef Documentation

◆ Address

template<class A , class T >
typedef A Sawyer::Container::StaticBuffer< A, T >::Address

Type of addresses.

Definition at line 34 of file StaticBuffer.h.

◆ Value

template<class A , class T >
typedef T Sawyer::Container::StaticBuffer< A, T >::Value

Type of values.

Definition at line 35 of file StaticBuffer.h.

◆ Super

template<class A , class T >
typedef Buffer<A, T> Sawyer::Container::StaticBuffer< A, T >::Super

Type of base class.

Definition at line 36 of file StaticBuffer.h.

Constructor & Destructor Documentation

◆ StaticBuffer() [1/2]

template<class A , class T >
Sawyer::Container::StaticBuffer< A, T >::StaticBuffer ( Value values,
Address  size 
)
inlineprotected

Definition at line 95 of file StaticBuffer.h.

◆ StaticBuffer() [2/2]

template<class A , class T >
Sawyer::Container::StaticBuffer< A, T >::StaticBuffer ( const Value values,
Address  size 
)
inlineprotected

Definition at line 99 of file StaticBuffer.h.

Member Function Documentation

◆ instance() [1/2]

template<class A , class T >
static Buffer< A, T >::Ptr Sawyer::Container::StaticBuffer< A, T >::instance ( Value values,
Address  size 
)
inlinestatic

Construct from caller-supplied data.

The caller supplies a pointer to data and the size of that data. The new buffer object does not take ownership of the data or copy it, thus the caller-supplied data must continue to exist for as long as this buffer exists.

Definition at line 111 of file StaticBuffer.h.

References Sawyer::Container::Buffer< A, T >::size().

Referenced by Sawyer::Container::MappedBuffer< A, T >::instance().

◆ instance() [2/2]

template<class A , class T >
static Buffer< A, T >::Ptr Sawyer::Container::StaticBuffer< A, T >::instance ( const Value values,
Address  size 
)
inlinestatic

Construct from caller-supplied data.

The caller supplies a pointer to data and the size of that data. The new buffer object does not take ownership of the data or copy it, thus the caller-supplied data must continue to exist for as long as this buffer exists.

Definition at line 114 of file StaticBuffer.h.

References Sawyer::Container::Buffer< A, T >::size().

◆ isReadOnly()

template<class A , class T >
bool Sawyer::Container::StaticBuffer< A, T >::isReadOnly ( ) const
inline

True if the buffer is read-only.

A buffer created from a const value is read only.

Definition at line 122 of file StaticBuffer.h.

◆ copy()

template<class A , class T >
Buffer< A, T >::Ptr Sawyer::Container::StaticBuffer< A, T >::copy ( ) const
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 128 of file StaticBuffer.h.

References Sawyer::Container::AllocatingBuffer< A, T >::instance().

◆ available()

template<class A , class T >
Address Sawyer::Container::StaticBuffer< A, T >::available ( Address  address) const
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 140 of file StaticBuffer.h.

Referenced by Sawyer::Container::StaticBuffer< A, T >::read(), and Sawyer::Container::StaticBuffer< A, T >::write().

◆ resize()

template<class A , class T >
void Sawyer::Container::StaticBuffer< A, T >::resize ( Address  n)
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 144 of file StaticBuffer.h.

◆ read()

template<class A , class T >
Address Sawyer::Container::StaticBuffer< A, T >::read ( Value buf,
Address  address,
Address  n 
) const
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 149 of file StaticBuffer.h.

References Sawyer::Container::StaticBuffer< A, T >::available().

◆ write()

template<class A , class T >
Address Sawyer::Container::StaticBuffer< A, T >::write ( const Value buf,
Address  address,
Address  n 
)
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 156 of file StaticBuffer.h.

References Sawyer::Container::StaticBuffer< A, T >::available().

◆ data()

template<class A , class T >
const Value * Sawyer::Container::StaticBuffer< A, T >::data ( ) const
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 165 of file StaticBuffer.h.


The documentation for this class was generated from the following file: