Public Types | Public Member Functions | Public Attributes
DataElement Class Reference

A base class for constituent elements of a generic DataWarehouse. More...

#include <DataElement.h>

Inheritance diagram for DataElement:
Inheritance graph
[legend]

List of all members.

Public Types

enum  ElementSize { EightBit, SixteenBit, ThirtyTwoBit }
 An enum representing the number of bits of the value held by the DataElement. More...
enum  ReadWrite { Read, Write }
 An enum representing whether the DataElement's value is to be written down to hardware or read from hardware. More...
typedef boost::variant< bool,
int16_t, int32_t, uint16_t,
uint32_t, float > 
ValueType
 A boost::variant that stores a data type chosen from a specific list of types.

Public Member Functions

 DataElement ()
 The default constructor for the DataElement class.
 DataElement (const std::string &type, ReadWrite readWrite, std::shared_ptr< SMT::Resource > resource=nullptr)
 The specific constructor for the DataElement class.
ReadWrite getReadWrite ()
 Get whether the value of the DataElement is to be read from (or written to) hardware.
ElementSize getSize ()
 Get the size of the value of the DataElement.
const std::type_info * getType ()
 Get the data type of the value of the DataElement.
template<typename T >
getValue () const
 Return the value held by the DataElement in the specified data type.
void setReadWrite (ReadWrite readWrite)
 Set whether the value of the DataElement is to be read from (or written to) hardware.
template<typename T >
void setValue (const T v)
 Set the value held by the DataElement in the specified data type.
virtual std::string toString ()
 Convert the DataElement into a string representation.
virtual ~DataElement ()
 The destructor for the DataElement class.

Public Attributes

ReadWrite readWrite
 Stores whether the DataElement should be read from (or written to) hardware.
std::shared_ptr< SMT::Resource > smtResource
 SMT Resource used to access this data in SMT.
ValueType value
 The value held by the DataElement.

Detailed Description

A base class for constituent elements of a generic DataWarehouse.

Definition at line 19 of file DataElement.h.


Member Typedef Documentation

typedef boost::variant<bool, int16_t, int32_t, uint16_t, uint32_t, float> DataElement::ValueType

A boost::variant that stores a data type chosen from a specific list of types.

Definition at line 25 of file DataElement.h.


Member Enumeration Documentation

An enum representing the number of bits of the value held by the DataElement.

Enumerator:
EightBit 

8 bits

SixteenBit 

16 bits

ThirtyTwoBit 

32 bits

Definition at line 30 of file DataElement.h.

An enum representing whether the DataElement's value is to be written down to hardware or read from hardware.

Enumerator:
Read 

The value is to be read from hardware

Write 

The value is to be written to hardware

Definition at line 39 of file DataElement.h.


Constructor & Destructor Documentation

The default constructor for the DataElement class.

Initializes the value to "uint32_t 0" and sets the direction to "Read"

Definition at line 15 of file DataElement.cpp.

DataElement::DataElement ( const std::string &  type,
ReadWrite  rw,
std::shared_ptr< SMT::Resource >  resource = nullptr 
)

The specific constructor for the DataElement class.

Parameters:
typeThe data type of the value held by this DataElement.
rwWhether the value of the DataElement is to be read from (or written to) hardware.
resourceSMT Resource to use to interface with SMT.
Exceptions:
std::invalid_argumentIf a type is given that doesn't match the types supported by the DataElement::ValueType

Initializes the value to "0" in whatever data type is specified

Definition at line 29 of file DataElement.cpp.

The destructor for the DataElement class.

Definition at line 70 of file DataElement.cpp.


Member Function Documentation

Get whether the value of the DataElement is to be read from (or written to) hardware.

Returns:
DataElement::ReadWrite representing whether the value of the DataElement is to be read from (or written to) hardware.

Definition at line 78 of file DataElement.cpp.

Get the size of the value of the DataElement.

Returns:
DataElement::ElementSize representing the size of the value of the DataElement.
Exceptions:
std::runtime_errorIf the size is not one of those enumerated in DataElement::ElementSize

Definition at line 106 of file DataElement.cpp.

const std::type_info * DataElement::getType ( )

Get the data type of the value of the DataElement.

Returns:
const std::type_info* representing the data type of the value of the DataElement.

Definition at line 96 of file DataElement.cpp.

template<typename T >
T DataElement::getValue ( ) const

Return the value held by the DataElement in the specified data type.

Returns:
The value held by the DataElement.
Exceptions:
std::invalid_argumentIf the data type requested does not match the underlying boost::variant type of the DataElement. Change that type using DataElement::setValue .

Definition at line 71 of file DataElement.h.

Set whether the value of the DataElement is to be read from (or written to) hardware.

Parameters:
rwRepresenting whether the value of the DataElement is to be read from (or written to) hardware.

Definition at line 87 of file DataElement.cpp.

template<typename T >
void DataElement::setValue ( const T  v)

Set the value held by the DataElement in the specified data type.

Parameters:
vThe value to be held by the DataElement in the specified data type.

When you set the value, is doesn't matter what the previous type was, this method will overwrite the type as well as the value.

Reimplemented in RobonetDataElement.

Definition at line 94 of file DataElement.h.

std::string DataElement::toString ( ) [virtual]

Convert the DataElement into a string representation.

Returns:
std::string representing the DataElement.

Reimplemented in RobonetDataElement.

Definition at line 137 of file DataElement.cpp.


Member Data Documentation

Stores whether the DataElement should be read from (or written to) hardware.

Todo:
This should be moved to private:

Definition at line 47 of file DataElement.h.

std::shared_ptr<SMT::Resource> DataElement::smtResource

SMT Resource used to access this data in SMT.

Definition at line 48 of file DataElement.h.

The value held by the DataElement.

Todo:
This should be moved to private:

Definition at line 46 of file DataElement.h.


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


robot_instance
Author(s):
autogenerated on Sat Jun 8 2019 20:43:12