ROSE  0.11.145.0
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 <util/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. More...
 
typedef T Value
 Type of values stored by the underlying buffer. More...
 

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...
 
AddressSegmentoperator= (const AddressSegment &other)
 Assignment. 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. More...
 
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...
 

Member Typedef Documentation

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

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

Constructor & Destructor Documentation

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< rose_addr_t, uint8_t >::anonymousInstance(), Sawyer::Container::AddressSegment< rose_addr_t, uint8_t >::fileInstance(), Sawyer::Container::AddressSegment< rose_addr_t, uint8_t >::nullInstance(), and Sawyer::Container::AddressSegment< rose_addr_t, uint8_t >::staticInstance().

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.

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

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

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

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

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

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

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

Map a file into an address space.

Definition at line 131 of file AddressSegment.h.

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

Referenced by Sawyer::Container::AddressMap< rose_addr_t, uint8_t >::checkConsistency(), and Sawyer::Container::AddressMap< rose_addr_t, uint8_t >::write().

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

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

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

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

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

Referenced by Sawyer::Container::AddressMap< rose_addr_t, uint8_t >::changeAccess().

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

template<class A = size_t, class T = boost::uint8_t>
const std::string& Sawyer::Container::AddressSegment< A, T >::name ( ) const
inline
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 179 of file AddressSegment.h.

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


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