ROSE 0.11.145.147
Public Types | Public Member Functions | Static Public Member Functions | List of all members
Sawyer::Container::AddressSegment< A, T > Class Template Reference

Description

template<class A = size_t, class T = boost::uint8_t>
class Sawyer::Container::AddressSegment< A, T >

A homogeneous interval of an address space.

A segment imparts access permissions and other address-map related characteristics to a buffer. The segment represents one contiguous, homogeneous interval of an address space and thus points to one buffer that implements the value-storage for that part of the address space.

A segment doesn't store information about where it's mapped in an address space since that's the responsibility of the map containing the segment. A segment points to a buffer which might not be the same size as what is entered in the map; buffers that are longer than the mapped interval of address space have data which is not accessible (at least not through that segment), and buffers that are shorter may return short data from read and write operations.

Definition at line 42 of file AddressSegment.h.

#include <Sawyer/AddressSegment.h>

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

Public Types

typedef A Address
 Address types expected to be used by the underlying buffer.
 
typedef T Value
 Type of values stored by the underlying buffer.
 

Public Member Functions

 AddressSegment ()
 Default constructor.
 
 AddressSegment (const AddressSegment &other)
 Copy constructor.
 
 AddressSegment (const typename Buffer< Address, Value >::Ptr &buffer, Address offset=0, unsigned accessBits=0, const std::string &name="")
 Construct a segment with buffer.
 
AddressSegmentoperator= (const AddressSegment &other)
 Assignment.
 
bool isAccessible (unsigned requiredAccess, unsigned prohibitedAccess) const
 Determines whether this segment is accessible.
 
Buffer< A, T >::Ptr buffer () const
 Property: buffer.
 
AddressSegmentbuffer (const typename Buffer< A, T >::Ptr &b)
 Property: buffer.
 
offset () const
 Property: buffer offset.
 
AddressSegmentoffset (A n)
 Property: buffer offset.
 
unsigned accessibility () const
 Property: access rights.
 
AddressSegmentaccessibility (unsigned bits)
 Property: access rights.
 
const std::string & name () const
 Property: name.
 
AddressSegmentname (const std::string &s)
 Property: name.
 

Static Public Member Functions

static AddressSegment nullInstance (Address size, unsigned accessBits=0, const std::string &name="")
 Create a segment that points to no data.
 
static AddressSegment anonymousInstance (Address size, unsigned accessBits=0, const std::string &name="")
 Create a segment with no backing store.
 
static AddressSegment fileInstance (const std::string &fileName, unsigned accessBits=Access::READABLE, const std::string &name="")
 Map a file into an address space.
 
static AddressSegment staticInstance (Value *buffer, Address size, unsigned accessBits=0, const std::string &name="")
 Create a segment that points to a static buffer.
 
static AddressSegment staticInstance (const Value *buffer, Address size, unsigned accessBits=0, const std::string &name="")
 Create a segment that points to a static buffer.
 

Member Typedef Documentation

◆ Address

template<class A = size_t, class T = boost::uint8_t>
typedef A Sawyer::Container::AddressSegment< A, T >::Address

Address types expected to be used by the underlying buffer.

Definition at line 49 of file AddressSegment.h.

◆ Value

template<class A = size_t, class T = boost::uint8_t>
typedef T Sawyer::Container::AddressSegment< A, T >::Value

Type of values stored by the underlying buffer.

Definition at line 50 of file AddressSegment.h.

Constructor & Destructor Documentation

◆ AddressSegment() [1/3]

template<class A = size_t, class T = boost::uint8_t>
Sawyer::Container::AddressSegment< A, T >::AddressSegment ( )
inline

Default constructor.

Constructs a segment that does not point to any buffer. This is mainly to fulfill the requirement that values in an IntervalMap are default constructable.

Definition at line 94 of file AddressSegment.h.

Referenced by Sawyer::Container::AddressSegment< A, T >::anonymousInstance(), Sawyer::Container::AddressSegment< A, T >::fileInstance(), Sawyer::Container::AddressSegment< A, T >::nullInstance(), Sawyer::Container::AddressSegment< A, T >::staticInstance(), and Sawyer::Container::AddressSegment< A, T >::staticInstance().

◆ AddressSegment() [2/3]

template<class A = size_t, class T = boost::uint8_t>
Sawyer::Container::AddressSegment< A, T >::AddressSegment ( const AddressSegment< A, T > &  other)
inline

Copy constructor.

Creates a new segment that's an exact copy of other. Both segments will point to the same underlying buffer, which is reference counted.

Definition at line 100 of file AddressSegment.h.

◆ AddressSegment() [3/3]

template<class A = size_t, class T = boost::uint8_t>
Sawyer::Container::AddressSegment< A, T >::AddressSegment ( const typename Buffer< Address, Value >::Ptr &  buffer,
Address  offset = 0,
unsigned  accessBits = 0,
const std::string &  name = "" 
)
inlineexplicit

Construct a segment with buffer.

This is the usual way that segments are created: by specifying a buffer and some access permissions.

Definition at line 106 of file AddressSegment.h.

Member Function Documentation

◆ operator=()

template<class A = size_t, class T = boost::uint8_t>
AddressSegment & Sawyer::Container::AddressSegment< A, T >::operator= ( const AddressSegment< A, T > &  other)
inline

Assignment.

Definition at line 111 of file AddressSegment.h.

◆ nullInstance()

template<class A = size_t, class T = boost::uint8_t>
static AddressSegment Sawyer::Container::AddressSegment< A, T >::nullInstance ( Address  size,
unsigned  accessBits = 0,
const std::string &  name = "" 
)
inlinestatic

Create a segment that points to no data.

Creates a segment of the specified size that points to a NullBuffer. This creates a segment which returns default constructed values when read, which fails when written. Such a segment is appropriate and efficient for mapping very large areas of an address space.

Definition at line 129 of file AddressSegment.h.

References Sawyer::Container::AddressSegment< A, T >::AddressSegment(), and Sawyer::Container::AddressSegment< A, T >::name().

◆ anonymousInstance()

template<class A = size_t, class T = boost::uint8_t>
static AddressSegment Sawyer::Container::AddressSegment< A, T >::anonymousInstance ( Address  size,
unsigned  accessBits = 0,
const std::string &  name = "" 
)
inlinestatic

Create a segment with no backing store.

Creates a segment by allocating default-constructed values. Writes to this segment will update the underlying buffer, but the buffer is only stored in memory and not attached to any type of file or permanent storage.

Definition at line 137 of file AddressSegment.h.

References Sawyer::Container::AddressSegment< A, T >::AddressSegment(), and Sawyer::Container::AddressSegment< A, T >::name().

◆ staticInstance() [1/2]

template<class A = size_t, class T = boost::uint8_t>
static AddressSegment Sawyer::Container::AddressSegment< A, T >::staticInstance ( Value buffer,
Address  size,
unsigned  accessBits = 0,
const std::string &  name = "" 
)
inlinestatic

Create a segment that points to a static buffer.

Ownership of the buffer is not transferred to the segment.

Definition at line 146 of file AddressSegment.h.

References Sawyer::Container::AddressSegment< A, T >::AddressSegment(), Sawyer::Container::AddressSegment< A, T >::buffer(), and Sawyer::Container::AddressSegment< A, T >::name().

◆ staticInstance() [2/2]

template<class A = size_t, class T = boost::uint8_t>
static AddressSegment Sawyer::Container::AddressSegment< A, T >::staticInstance ( const Value buffer,
Address  size,
unsigned  accessBits = 0,
const std::string &  name = "" 
)
inlinestatic

Create a segment that points to a static buffer.

Ownership of the buffer is not transferred to the segment.

Definition at line 149 of file AddressSegment.h.

References Sawyer::Container::AddressSegment< A, T >::AddressSegment(), Sawyer::Container::AddressSegment< A, T >::buffer(), and Sawyer::Container::AddressSegment< A, T >::name().

◆ fileInstance()

template<class A = size_t, class T = boost::uint8_t>
static AddressSegment Sawyer::Container::AddressSegment< A, T >::fileInstance ( const std::string &  fileName,
unsigned  accessBits = Access::READABLE,
const std::string &  name = "" 
)
inlinestatic

◆ buffer() [1/2]

template<class A = size_t, class T = boost::uint8_t>
Buffer< A, T >::Ptr Sawyer::Container::AddressSegment< A, T >::buffer ( ) const
inline

Property: buffer.

This is the Buffer object that represents the values stored in this interval of the address space. The first value in this segment, no matter where or if it's mapped in an address-mapping container, corresponds to the value stored at address zero of the buffer.

Definition at line 174 of file AddressSegment.h.

Referenced by Sawyer::Container::AddressSegment< A, T >::staticInstance(), and Sawyer::Container::AddressSegment< A, T >::staticInstance().

◆ buffer() [2/2]

template<class A = size_t, class T = boost::uint8_t>
AddressSegment & Sawyer::Container::AddressSegment< A, T >::buffer ( const typename Buffer< A, T >::Ptr &  b)
inline

Property: buffer.

This is the Buffer object that represents the values stored in this interval of the address space. The first value in this segment, no matter where or if it's mapped in an address-mapping container, corresponds to the value stored at address zero of the buffer.

Definition at line 175 of file AddressSegment.h.

◆ offset() [1/2]

template<class A = size_t, class T = boost::uint8_t>
A Sawyer::Container::AddressSegment< A, T >::offset ( ) const
inline

Property: buffer offset.

The offset into the buffer corresponding to the first value of this segment.

Definition at line 183 of file AddressSegment.h.

Referenced by Sawyer::Container::AddressMap< A, T >::changeAccess().

◆ offset() [2/2]

template<class A = size_t, class T = boost::uint8_t>
AddressSegment & Sawyer::Container::AddressSegment< A, T >::offset ( n)
inline

Property: buffer offset.

The offset into the buffer corresponding to the first value of this segment.

Definition at line 184 of file AddressSegment.h.

◆ accessibility() [1/2]

template<class A = size_t, class T = boost::uint8_t>
unsigned Sawyer::Container::AddressSegment< A, T >::accessibility ( ) const
inline

Property: access rights.

This property stores access rights as an unsigned integer. It makes no interpretation of what the various bits mean since the meaning is imparted by the mapping container.

Definition at line 193 of file AddressSegment.h.

Referenced by Sawyer::Container::AddressMap< A, T >::changeAccess().

◆ accessibility() [2/2]

template<class A = size_t, class T = boost::uint8_t>
AddressSegment & Sawyer::Container::AddressSegment< A, T >::accessibility ( unsigned  bits)
inline

Property: access rights.

This property stores access rights as an unsigned integer. It makes no interpretation of what the various bits mean since the meaning is imparted by the mapping container.

Definition at line 194 of file AddressSegment.h.

◆ name() [1/2]

template<class A = size_t, class T = boost::uint8_t>
const std::string & Sawyer::Container::AddressSegment< A, T >::name ( ) const
inline

◆ name() [2/2]

template<class A = size_t, class T = boost::uint8_t>
AddressSegment & Sawyer::Container::AddressSegment< A, T >::name ( const std::string &  s)
inline

Property: name.

Each segment may be given a name which can be used for debugging.

Definition at line 203 of file AddressSegment.h.

◆ isAccessible()

template<class A = size_t, class T = boost::uint8_t>
bool Sawyer::Container::AddressSegment< A, T >::isAccessible ( unsigned  requiredAccess,
unsigned  prohibitedAccess 
) const
inline

Determines whether this segment is accessible.

Returns true if all bits that are set in requiredAccess are also set in this segment, and none of the bits set in prohibitedAccess are set in this segment.

Definition at line 214 of file AddressSegment.h.


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