CVMEptr

Name

CVMEptr -- 

Synopsis


#include <CVMEptr.h>
            
 class CVMEptr<T> {

  CVMEptr<T>(UInt_t space, UInt_t base, UInt_t length, UInt_t crate = 0);
  CVMEptr<T>(Space space, UInt_t base, UInt_t length, UInt_t crate = 0);
  CVMEptr<T>(const CVMEptr& aCVMEptr);
  CVMEptr<T>();

  Address_t getgenptr(UInt_t nOffset);
  Address_t getcurrptr();
  T& operator*();
  T* operator->();
  T& operator[](UInt_t nOffset);
  CVMEptr<T> operator+(UInt_t nOffset);
  CVMEptr<T> operator-(UInt_t nOffset);
  CVMEptr<T>& operator+=(UInt_t nOffset);
  CVMEptr<T>& operator-=(UInt_t nOffset);
  CVMEptr<T>& operator++();
  CVMEptr<T>& operator--();
  CVMEptr<T> operator++(Int_t );
  CVMEptr<T> operator--(Int_t );
}

Description

Implements an unreference counted pointer to VME space. For the unreference counted pointer, to destroy one object invalidates all other copies of the object. In general you should prefer the CVME class which has the same functionality but is safer to use.

Public member functions

CVMEptr<T>(UInt_t space, UInt_t base, UInt_t length, UInt_t crate = 0);

Constructs a CVMEptr object for type T. The pointer points to a block of VME address space. Attempts to reference outside of this block will, in general, throw exceptions. The address block is defined as:

UInt_t space

Selects which address space the block is selected to live in. See "Types and public data" below for more information about the legal value of the space parameter as it is just the integer equivalent of the Space type elements.

UInt_t base

Defines the base address of the address block that can be referenced by the pointer.

UInt_t length

Defines the length of the address space block. This length is the size of the region in bytes regardless of the type T of the pointer.

UInt_t crate

Defines the VME crate number in which this address space lives. If omitted, this will default to 0 which is perfectly good for single crate systems.

CVMEptr<T>(Space space, UInt_t base, UInt_t length, UInt_t crate = 0);

Creates a pointer as in the previous construtor, however the space parameter is specified using the Space enumerated type which is described more completely in the "Types and public data" section below.

CVMEptr<T>(const CVMEptr& aCVMEptr);

Constructs a new pointer that is a functional duplicate of the aCVMEptr parameter. This pointer uses the same underlying address map as aCVMEptr. Therefore, if either of the pointers is destroyed, the other will fail.

CVMEptr<T>();

Creates a 'pointer' that does not point to anything. This pointer can be made valid by assigning to it from another CVMEptr object.

Address_t getgenptr(UInt_t nOffset);

Returns a 'generic pointer' to the VME bus that is nOffset bytes from the location the pointer is currently pointing to. The pointer returned is an ordeinary void*, and can be cast to anything. Using this pointer throws away all range checking so attempts to reference outside of the block of memory that the original pointer points at will yield undefined results.

Address_t getcurrptr();

This is the same as a call to getgenptr(0).

T& operator*();

Dereferences the pointer, returning a reference to the T it points to. This allows the pointer to be dereferenced on either side of an assignment (as an lvalue or an rvalue).

T* operator->();

If T is a structured type (union, struct or object with public data), this allows the pointer to dereference to a field within T.

T& operator[](UInt_t nOffset);

Indexes to element number nOffset relative to the current position of the pointer and returns a reference to that T. Since a reference is used, the result of indexing can be used either as an lvalue or an rvalue with respect to the assignment operator.

CVMEptr<T> operator+(UInt_t nOffset);

Returns a new pointer that is advanced by the nOffset T's from the current pointer (scaled addition).

CVMEptr<T> operator-(UInt_t nOffset);

Returns a new pointer that is nOffset T's prior to the current pointer (scaled subtraction).

CVMEptr<T>& operator+=(UInt_t nOffset);

Advances the current pointer by nOffset T's from its current position.

CVMEptr<T>& operator-=(UInt_t nOffset);

Backs the current pointer up by nOffset T's from its current position.

CVMEptr<T>& operator++();

Advances the pointer by one T, and returns the value of the pointer after this increment (post-increment).

CVMEptr<T>& operator--();

Moves the pointer back by one T and returns the pointer after this operation (post-decrement).

CVMEptr<T> operator++(Int_t );

Advances the pointer by one T but returns the value of the pointer prior to this operation (pre-increment).

CVMEptr<T> operator--(Int_t );

Same as the previous operation but does a pre-decrement.

Types and public data

The Space enumerated type is used to select the VME address space. Note that integer equivalents may also be used. Valid values for the Space type are:

a16 = 0

The A16 address space is used. The bottom 16 bits of addresses are significant.

a24 = 1

The A24 address space is used. The bottom 24 bits of address space are importnant.

a32 = 3

The 32 bit address space is sused. All 32 bits of address are significant.

geo =4

Geograhpical addressing is used.

Exceptions

CMapError exceptions are thrown when the mapping failes. CRangeError is thrown when the pointer references or is moved out of the address range that constructed it.