Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

DC_DataItem Class Reference
[Data Processing]

#include <DC_DataItem.h>

Inheritance diagram for DC_DataItem:

DC_RawDataItem DC_SettableDataItem List of all members.

Detailed Description

This class encapsulates a data item.

A data item encapsulates access to a variable. The target variable is specified as an address that is passed to the class constructor. The target variable cannot be changed after the class is instantiated. It is however declared as a protected variable so that subclasses may be implemented that allow it to be updated.

Data item components can also be used to encapsulate references to memory-mapped registers.

The variable encapsulated by a data item can be of two types: TD_Float (a real-valued data item) or TD_Integer (an integer valued data item). This class provides getter/setter methods to read and write the underlying variable as either an instance of type TD_Float or TD_Integer.

Data items are designed for efficiency. There are accordingly no run-time checks on consistency of usage of the getter and setter methods (e.g. there is no protection against a user accessing a real-valued data item with the getter method for integer-valued data items). However, when the preprocessor symbol NDEBUG is NOT defined, additional checks are inserted in the code and their violation will give rise to assertion errors.

This class deviates from the project-specific coding rule PR3.1. Use of pointers to a variable of primitive type is necessary to fulfill the function of the class.

This class is intended to be very light-weight because it is used throughout an application and may be instantiated a large number of times. For this reason, unlike most framework classes, it is a stand-alone class which does not inherit from CC_RootObject. This is a deviation from project-specific coding rule PR1.1.

Todo:
Make the constructor parameterless for consistency with the rest of the framework and add a setter method for the variable encapsulated by the data item In order to keep this class distinct from DC_SettableDataItem, the setter method should raise an assertion exception if it is called more than once.
Author:
Alessandro Pasetti, Roberto Totaro
Version:
1.0

Definition at line 60 of file DC_DataItem.h.

Public Member Functions

 DC_DataItem (TD_Float *d)
 Instantiate a data item component encapsulating a real-valued variable.

 DC_DataItem (TD_Integer *d)
 Instantiate a data item component encapsulating an integer-valued variable.

TD_Float getFloatValue () const
 Return the value of a real-valued data item.

void setValue (TD_Float newValue)
 Set the value of a real-valued data item.

TD_Integer getIntegerValue () const
 Return the value of an integer-valued data item.

void setValue (TD_Integer newValue)
 Set the value of an integer-valued data item.


Protected Attributes

void * pVar
 The pointer to the variable that is encapsualetd by the data item.

TD_DataItemType varType
 This variable is only used when assertions are enabled (i.e.


Constructor & Destructor Documentation

DC_DataItem::DC_DataItem TD_Float d  )  [inline]
 

Instantiate a data item component encapsulating a real-valued variable.

The variable whose reference is encapsulated in the data item component is passed as a constructor parameter. The parameter could also represent the address of some hardware register that is mapped to memory and that "looks like" an internal memory variable. A pseudo-code implementation for this method is as follows:<PRE> initDataItem(d, DI_FLOAT); Note that the actual initialization is performed by the method initDataItem. This method stores additional information about the type of the data item.

See also:
#initDataItem
Parameters:
d reference to the variable encapsulated by the data item

Definition at line 25 of file DC_DataItem_inl.h.

DC_DataItem::DC_DataItem TD_Integer d  )  [inline]
 

Instantiate a data item component encapsulating an integer-valued variable.

The variable whose reference is encapsulated in the data item component is passed as a constructor parameter. The parameter could also represent the address of some hardware register that is mapped to memory and that "looks like" an internal memory variable. A pseudo-code implementation for this method is as follows:<PRE> initDataItem(d, DI_FLOAT); Note that the actual initialization is performed by the method initDataItem. This method stores additional information about the type of the data item.

See also:
#initDataItem
Parameters:
d reference to the variable encapsulated by the data item

Definition at line 29 of file DC_DataItem_inl.h.


Member Function Documentation

TD_Float DC_DataItem::getFloatValue  )  const [inline]
 

Return the value of a real-valued data item.

Returns:
the value of the variable encapsulated in the data item component interpreted as a variable of type TD_Float

Definition at line 33 of file DC_DataItem_inl.h.

TD_Integer DC_DataItem::getIntegerValue  )  const [inline]
 

Return the value of an integer-valued data item.

Returns:
the value of the variable encapsulated in the data item component interpreted as a variable of type TD_Integer

Definition at line 38 of file DC_DataItem_inl.h.

void DC_DataItem::setValue TD_Integer  newValue  )  [inline]
 

Set the value of an integer-valued data item.

Parameters:
newValue the new value of the variable encapsulated in the data item

Definition at line 48 of file DC_DataItem_inl.h.

void DC_DataItem::setValue TD_Float  newValue  )  [inline]
 

Set the value of a real-valued data item.

Parameters:
newValue the new value of the variable encapsulated in the data item

Definition at line 43 of file DC_DataItem_inl.h.


Member Data Documentation

void* DC_DataItem::pVar [protected]
 

The pointer to the variable that is encapsualetd by the data item.

This variable cannot be updated within class DC_DataItem. It is however defined protected to allow subclasses to define methods that allow it to be updaetd.

Definition at line 79 of file DC_DataItem.h.

TD_DataItemType DC_DataItem::varType [protected]
 

This variable is only used when assertions are enabled (i.e.

when NDEBUG is not defined). It is used to perform run-time checks on whether the variable encapsulated by this class is accessed in a type-safe manner. The use of this variable represents a violation of project-specific coding rule PR9.2. The violation is justified by the difficulty of otherwise ensuring that the variable encapsulated by a data item is written to or read back with the correct accessor methods.

Definition at line 91 of file DC_DataItem.h.


The documentation for this class was generated from the following files:
Copyright 2003 P&P Software GmbH - All Rights Reserved