#include <DC_DataItem.h>
Inheritance diagram for DC_DataItem:
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.
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. |
|
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
Definition at line 25 of file DC_DataItem_inl.h. |
|
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
Definition at line 29 of file DC_DataItem_inl.h. |
|
Return the value of a real-valued data item.
Definition at line 33 of file DC_DataItem_inl.h. |
|
Return the value of an integer-valued data item.
Definition at line 38 of file DC_DataItem_inl.h. |
|
Set the value of an integer-valued data item.
Definition at line 48 of file DC_DataItem_inl.h. |
|
Set the value of a real-valued data item.
Definition at line 43 of file DC_DataItem_inl.h. |
|
The pointer to the variable that is encapsualetd by the data item.
This variable cannot be updated within class Definition at line 79 of file DC_DataItem.h. |
|
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. |