ROSE  0.11.96.11
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 37 of file AddressSegment.h.

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

Static Public Member Functions

static AddressSegment nullInstance (Address size, unsigned accessBits=0, const std::string &name="")
 Create a segment that points to no data. More...
 
static AddressSegment anonymousInstance (Address size, unsigned accessBits=0, const std::string &name="")
 Create a segment with no backing store. More...
 
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. More...
 
static AddressSegment staticInstance (const Value *buffer, Address size, unsigned accessBits=0, const std::string &name="")
 Create a segment that points to a static buffer. More...
 

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 70 of file AddressSegment.h.

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

Here is the caller graph for this function:

◆ 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 76 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 82 of file AddressSegment.h.

Member Function Documentation

◆ 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 96 of file AddressSegment.h.

◆ 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 104 of file AddressSegment.h.

◆ 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 113 of file AddressSegment.h.

◆ 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 116 of file AddressSegment.h.

◆ 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 141 of file AddressSegment.h.

Referenced by Sawyer::Container::AddressMap< A, T >::AddressMap(), Sawyer::Container::AddressMap< A, T >::checkConsistency(), Sawyer::Container::AddressSegment< A, boost::uint8_t >::staticInstance(), and Sawyer::Container::AddressMap< A, T >::write().

Here is the caller graph for this function:

◆ 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 142 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 150 of file AddressSegment.h.

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

Here is the caller graph for this function:

◆ 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 151 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 160 of file AddressSegment.h.

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

Here is the caller graph for this function:

◆ 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 161 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 170 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 181 of file AddressSegment.h.


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