Generic hardware access library
HAL::AddressTableItem Class Reference

Contains data of an AddressTable item. More...

#include <AddressTableItem.hh>

List of all members.

Public Member Functions

 AddressTableItem (std::string key, std::string description, GeneralHardwareAddress &address, uint32_t mask, bool writableFlag, bool readableFlag)
 The constructor of the class is trivial and its arguments are mostly selfexplaining.
 AddressTableItem (const AddressTableItem &)
 Copy constructor to make deep copies of AddressTables.
virtual ~AddressTableItem ()
 Here the GeneralHardwareAddress is deleted.
uint32_t getMask () const
std::string getDescription () const
std::string getKey () const
GeneralHardwareAddressgetGeneralHardwareAddress () const
 The returned reference is not constant since in the case of VME64x the configuration algorithm must configure the HardwareAddress with the AM and the dataWidth chosen to access the items of the mapped function window.
bool isWritable () const
bool isReadable () const
void checkWritable () const throw (IllegalOperationException)
 This function throws an exceptioni if this item is not writable.
void checkReadable () const throw (IllegalOperationException)
 This function throws an exceptioni if this item is not readable.
bool isBit () const
 Check if an item is a single bit.
void checkBit () const throw (IllegalOperationException)
virtual void print (std::ostream &os=std::cout) const
 Performs what you think it does...
uint32_t applyFromMask (uint32_t data, bool MaskBoundaryCheck=false) const throw ( MaskBoundaryException )
 Retrieve a value from a bitfield and convert it to a number.
uint32_t applyToMask (uint32_t data, bool MaskBoundaryCheck=true) const throw ( MaskBoundaryException)
 Shifts data to the bitpositions defined by the item's mask.

Protected Member Functions

uint32_t countBits (uint32_t word) const
 Counts the number of bits set to '1'.

Private Member Functions

void operator= (const AddressTableItem &ai)
 forbid assignment

Private Attributes

GeneralHardwareAddresshardwareAddress
std::string key
std::string description
uint32_t mask
bool writableFlag
bool readableFlag
bool bitFlag

Detailed Description

Contains data of an AddressTable item.

This class is a container for all data belonging to an item. It is technology independent since everything which is technology dependent is hidden in the GeneralHardwareAddress (the user will pass either a PCIHardwareAddress or a VMEHardwareAddress to the constructor. See the documentation of those.)

See also:
AddressTableInterface, GeneralHardwareAddress
PCIHardwareAddress, VMEHardwareAddress
Author:
: Christoph Schwick
Revision:
1.1
Date:
2007/03/05 18:02:09

Definition at line 33 of file AddressTableItem.hh.


Constructor & Destructor Documentation

HAL::AddressTableItem::AddressTableItem ( std::string  key,
std::string  description,
HAL::GeneralHardwareAddress hardwareAddress,
uint32_t  mask,
bool  writableFlag,
bool  readableFlag 
)

The constructor of the class is trivial and its arguments are mostly selfexplaining.

Parameters:
keyis the name of the item. This string is used in the rest of the software to reference the item. This is more userfriendly than trying to remeber the addresses.
descriptionis a short one line description of the item which in a gui could appear as a tooltip.
addresscontains the address and the access modifier for the item. Here hardware and platform dependent stuff is stored.
maskdetermines where the bits associated to the item can be found in the 32-bit data word. The relevant bits are marked with a '1'.
writableFlagis set if the item can be written.
readableFlagis set if the item can be read.

Definition at line 5 of file AddressTableItem.cc.

Copy constructor to make deep copies of AddressTables.

The AddressTableItem contains a reference to a GeneralHardwareAddress. This is needed since the GeneralHardwareAddress is used polymorphic. On the other hand this means the default copy constructor is not adequate for this class. (Remember: this class owns the GeneralHardwareAddress and therfore deletes it in the destructor. Therfore it must be cloned in the copy constructor.)

Definition at line 25 of file AddressTableItem.cc.

Here the GeneralHardwareAddress is deleted.

(It is on the heap.)

Definition at line 35 of file AddressTableItem.cc.


Member Function Documentation

uint32_t HAL::AddressTableItem::applyFromMask ( uint32_t  data,
bool  MaskBoundaryCheck = false 
) const throw ( MaskBoundaryException )

Retrieve a value from a bitfield and convert it to a number.

Every item is associated to some bitfield in a dataword. This function is shifting a data value for a given item, which is assumed to be at the position indicated by the item-mask, in a way that the least significant bit becomes bit 0 ( and the data value of the bitfield becomes "human-readable").

Parameters:
datais the value for the item which should be shifted.
MaskBoundaryCheckis an optional parameter which allows to switch off a check that only bits within the mask are set. If checking is switched on and the routine finds data bits set outside of the mask it will throw a MaskBoundaryException. The check is switched of by defaults because it will be ofter the case that bits might be set outside the mask since they belong to other items.

Definition at line 156 of file AddressTableItem.cc.

uint32_t HAL::AddressTableItem::applyToMask ( uint32_t  data,
bool  MaskBoundaryCheck = true 
) const throw ( MaskBoundaryException)

Shifts data to the bitpositions defined by the item's mask.

Every item is usually associated to some bitfield in a dataword. This function is shifting a value for a given item into the bitfield indicated by the mask of the item.

Parameters:
datais the value for the item which should be shifted.
MaskBoundaryCheckis an optional parameter which allows to switch off a check that the data value fits into the bitfields of the mask. If checking is switched on and the user provides a value which would set bits outside of the items mask, a MaskBoundaryException is thrown. By default checking is switched on since this usually means that the user of the method provided a wrong data value for the item.

Definition at line 124 of file AddressTableItem.cc.

Definition at line 88 of file AddressTableItem.cc.

This function throws an exceptioni if this item is not readable.

Definition at line 64 of file AddressTableItem.cc.

This function throws an exceptioni if this item is not writable.

Definition at line 76 of file AddressTableItem.cc.

uint32_t HAL::AddressTableItem::countBits ( uint32_t  word) const [protected]

Counts the number of bits set to '1'.

Definition at line 114 of file AddressTableItem.cc.

Definition at line 52 of file AddressTableItem.cc.

The returned reference is not constant since in the case of VME64x the configuration algorithm must configure the HardwareAddress with the AM and the dataWidth chosen to access the items of the mapped function window.

In the case of standard VME and PCI there is no danger since the API of the HardwareAddresses for these two cases guarantees that no method can change the internal state. (All methdos are const.)

Definition at line 40 of file AddressTableItem.cc.

std::string HAL::AddressTableItem::getKey ( ) const

Definition at line 48 of file AddressTableItem.cc.

uint32_t HAL::AddressTableItem::getMask ( ) const

Definition at line 44 of file AddressTableItem.cc.

Check if an item is a single bit.

This is the only service of the class.

Returns:
true if the item is a single bit (i.e. in its mask only one bit is set.

Definition at line 100 of file AddressTableItem.cc.

Definition at line 56 of file AddressTableItem.cc.

Definition at line 60 of file AddressTableItem.cc.

void HAL::AddressTableItem::operator= ( const AddressTableItem ai) [inline, private]

forbid assignment

Definition at line 175 of file AddressTableItem.hh.

void HAL::AddressTableItem::print ( std::ostream &  os = std::cout) const [virtual]

Performs what you think it does...

Definition at line 104 of file AddressTableItem.cc.


Member Data Documentation

Definition at line 182 of file AddressTableItem.hh.

std::string HAL::AddressTableItem::description [private]

Definition at line 178 of file AddressTableItem.hh.

std::string HAL::AddressTableItem::key [private]

Definition at line 177 of file AddressTableItem.hh.

uint32_t HAL::AddressTableItem::mask [private]

Definition at line 179 of file AddressTableItem.hh.

Definition at line 181 of file AddressTableItem.hh.

Definition at line 180 of file AddressTableItem.hh.


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