Generic hardware access library
HAL::AddressTable Class Reference

Implementation of a AddressTableInterface. More...

#include <AddressTable.hh>

Inheritance diagram for HAL::AddressTable:
HAL::AddressTableInterface HAL::PCIAddressTable HAL::VMEAddressTable

List of all members.

Public Member Functions

 AddressTable (const AddressTable &orgiginal)
 The copy constructor of the AddressTable.
virtual ~AddressTable ()
std::string getName () const
 Retrieve the name of the AddressTable.
const GeneralHardwareAddressgetGeneralHardwareAddress (std::string item) const throw ( NoSuchItemException )
 Retrieve the GeneralHardwareAddress of a particular item.
const GeneralHardwareAddressgetWritableHardwareAddress (std::string item) const throw (NoSuchItemException, IllegalOperationException)
 Retrieve a writable General Address of a particular item.
const GeneralHardwareAddressgetReadableHardwareAddress (std::string item) const throw (NoSuchItemException, IllegalOperationException)
 Retrieve a writable General Address of a particular item.
const AddressTableItemcheckItem (std::string item) const throw (NoSuchItemException)
 Check if an item exists and return a reference to it.
bool isReadable (std::string item) const throw ( NoSuchItemException )
 Test if an item in the map is readable.
bool isWritable (std::string item) const throw ( NoSuchItemException )
 Test if an item in the map is writable.
bool exists (std::string item) const
 Test if an item exists in the map.
uint32_t getMask (std::string item) const throw ( NoSuchItemException )
 Retrieve the Bitmap of the item.
std::string getDescription (std::string item) const throw ( NoSuchItemException )
 Retrieve the description of the item.
bool isBit (std::string item) const throw ( NoSuchItemException )
 Tests if an item is a flag.
__gnu_cxx::hash_map
< std::string,
AddressTableItem *, HalHash
< std::string >
>::const_iterator 
getItemListBegin () const
 Provide an iterator for the map of AddressTableItems.
__gnu_cxx::hash_map
< std::string,
AddressTableItem *, HalHash
< std::string >
>::const_iterator 
getItemListEnd () const
 Provide an iterator pointing to the end of the AddressTableItems map.
uint32_t applyToMask (std::string item, uint32_t data, bool MaskBoundaryCheck=true) const throw ( NoSuchItemException, MaskBoundaryException )
 Shifts data to the bitpositions defined by the item's mask.
uint32_t applyFromMask (std::string item, uint32_t data, bool MaskBoundaryCheck=false) const throw ( NoSuchItemException, MaskBoundaryException )
 Retrieve a value from a bitfield and convert it to a hex number.

Protected Member Functions

 AddressTable (std::string name)
 The protected constructor.

Protected Attributes

__gnu_cxx::hash_map
< std::string,
AddressTableItem *, HalHash
< std::string > > 
itemMap
std::string name

Detailed Description

Implementation of a AddressTableInterface.

This class is an implementation of the AddressTableInterface. It is NOT thought to be used directly, but it is merely the implementation of the functionality defined by the interface. It is missing any functionality to insert items into the itemlist of the map. This is supposed to be done by the classes inheritating from the AddressTable. With this design general functionality is cleanly separated from application dependend features.

Since this class merely implemets the methods from the AddressTableInterface there is hardly documentation for the functions here. PLease look up the documentation there.

Note that the constructor of the class is protected in order to prevent direct instantiation of this class

See also:
AddressTableInterface, AddressTableItem PCIAddressTable, VMEAddressTable
Author:
Christoph Schwick
Revision:
1.1
Date:
2007/03/05 18:02:09

Definition at line 49 of file AddressTable.hh.


Constructor & Destructor Documentation

The copy constructor of the AddressTable.

The copy constructor of the AddressTable has been implemented for safety: The AddressTableContainer shares addresstables among many objects by handling the references to the AddressTables in the container. If by mistake a programmer assigns the reference to a variable of type AddressTable (and not of type "reference to Adddresstable") the copy constructor of the AddressTable is called. If this one does not produce a deep copy of the AddressTableItems in the table it happens that as soon as the first AddressTable is destroyed (goes out of scope) all AddressTableItems are destroyed although they still should exist for use in the objects which share the same AddressTable.

Definition at line 8 of file AddressTable.cc.

Definition at line 18 of file AddressTable.cc.

HAL::AddressTable::AddressTable ( std::string  name) [protected]

The protected constructor.

The constructor is protected since nobody should ever instantiate an AddressTable directly. Only the technology specific Tables PCIAddressTable and VMEAddressTable are useful.

Definition at line 4 of file AddressTable.cc.


Member Function Documentation

uint32_t HAL::AddressTable::applyFromMask ( std::string  item,
uint32_t  data,
bool  MaskBoundaryCheck = false 
) const throw ( NoSuchItemException, MaskBoundaryException ) [virtual]

Retrieve a value from a bitfield and convert it to a hex 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 issue a warning on the terminal. 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.

Implements HAL::AddressTableInterface.

Definition at line 129 of file AddressTable.cc.

uint32_t HAL::AddressTable::applyToMask ( std::string  item,
uint32_t  data,
bool  MaskBoundaryCheck = true 
) const throw ( NoSuchItemException, MaskBoundaryException ) [virtual]

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 warning is printed on the terminal. By default checking is switched on since this usually means that the user of the method provided a wrong data value for the item.

Implements HAL::AddressTableInterface.

Definition at line 122 of file AddressTable.cc.

const HAL::AddressTableItem & HAL::AddressTable::checkItem ( std::string  item) const throw (NoSuchItemException) [virtual]

Check if an item exists and return a reference to it.

Exceptions:
NoSuchItemExceptionis thrown if the item does not exist.

Implements HAL::AddressTableInterface.

Definition at line 98 of file AddressTable.cc.

bool HAL::AddressTable::exists ( std::string  item) const [virtual]

Test if an item exists in the map.

Implements HAL::AddressTableInterface.

Definition at line 90 of file AddressTable.cc.

std::string HAL::AddressTable::getDescription ( std::string  item) const throw ( NoSuchItemException ) [virtual]

Retrieve the description of the item.

Implements HAL::AddressTableInterface.

Definition at line 65 of file AddressTable.cc.

const HAL::GeneralHardwareAddress & HAL::AddressTable::getGeneralHardwareAddress ( std::string  item) const throw ( NoSuchItemException ) [virtual]

Retrieve the GeneralHardwareAddress of a particular item.

If the item is not existing an "NoSuchItemException" is thrown.

Implements HAL::AddressTableInterface.

Definition at line 26 of file AddressTable.cc.

__gnu_cxx::hash_map< std::string, HAL::AddressTableItem *, HAL::HalHash< std::string > >::const_iterator HAL::AddressTable::getItemListBegin ( ) const [virtual]

Provide an iterator for the map of AddressTableItems.

This method is needed for tools which need to perform checks on all items in the table. For example a class which is configuring a VME64x module wants to check if the AMs specified in the AddressTable are consistent with the AMCAP settings in the configuration ROM. The Iterator delivered is pointing to the first element of the iterator sequence.

Implements HAL::AddressTableInterface.

Definition at line 109 of file AddressTable.cc.

__gnu_cxx::hash_map< std::string, HAL::AddressTableItem *, HAL::HalHash< std::string > >::const_iterator HAL::AddressTable::getItemListEnd ( ) const [virtual]

Provide an iterator pointing to the end of the AddressTableItems map.

This iterator is needed for loops over all items of the AddressTable.

See also:
getItemListBegin()

Implements HAL::AddressTableInterface.

Definition at line 116 of file AddressTable.cc.

uint32_t HAL::AddressTable::getMask ( std::string  item) const throw ( NoSuchItemException ) [virtual]

Retrieve the Bitmap of the item.

Implements HAL::AddressTableInterface.

Definition at line 80 of file AddressTable.cc.

std::string HAL::AddressTable::getName ( ) const [inline, virtual]

Retrieve the name of the AddressTable.

Implements HAL::AddressTableInterface.

Definition at line 72 of file AddressTable.hh.

Retrieve a writable General Address of a particular item.

If the item is not existing an "NoSuchItemException" is thrown. If the item is not readable an "IllegalOperationException" is thrown.

Implements HAL::AddressTableInterface.

Definition at line 49 of file AddressTable.cc.

Retrieve a writable General Address of a particular item.

If the item is not existing an "NoSuchItemException" is thrown. If the item is not writable an "IllegalOperationException" is thrown.

Implements HAL::AddressTableInterface.

Definition at line 32 of file AddressTable.cc.

bool HAL::AddressTable::isBit ( std::string  item) const throw ( NoSuchItemException ) [virtual]

Tests if an item is a flag.

If in the mask of an item only one bit is set it is considered a flag. This is tested here.

Implements HAL::AddressTableInterface.

Definition at line 85 of file AddressTable.cc.

bool HAL::AddressTable::isReadable ( std::string  item) const throw ( NoSuchItemException ) [virtual]

Test if an item in the map is readable.

Implements HAL::AddressTableInterface.

Definition at line 70 of file AddressTable.cc.

bool HAL::AddressTable::isWritable ( std::string  item) const throw ( NoSuchItemException ) [virtual]

Test if an item in the map is writable.

Implements HAL::AddressTableInterface.

Definition at line 75 of file AddressTable.cc.


Member Data Documentation

__gnu_cxx::hash_map<std::string, AddressTableItem*, HalHash<std::string> > HAL::AddressTable::itemMap [protected]

Definition at line 145 of file AddressTable.hh.

std::string HAL::AddressTable::name [protected]

Definition at line 146 of file AddressTable.hh.


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