NTRT Simulator  Version: Master
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
tgDataManager Class Reference

#include <tgDataManager.h>

Inheritance diagram for tgDataManager:

Public Member Functions

 tgDataManager ()
 
virtual ~tgDataManager ()
 
virtual void setup ()
 
virtual void teardown ()
 
virtual void step (double dt)
 
virtual void addSenseable (tgSenseable *pSenseable)
 
virtual void addSensorInfo (tgSensorInfo *pSensorInfo)
 
virtual std::string toString () const
 

Protected Member Functions

bool invariant () const
 

Protected Attributes

std::vector< tgSensor * > m_sensors
 
std::vector< tgSensorInfo * > m_sensorInfos
 
std::vector< tgSenseable * > m_senseables
 

Detailed Description

Abstract class for objects that will manage data within NTRTsim. These tgDataManagers are created in an app, and passed in to a tgSimulation. An example of a data manager would be a data logger: it would create various tgSensor objects, and pull from them at each timestep of the simulation.

Definition at line 47 of file tgDataManager.h.

Constructor & Destructor Documentation

tgDataManager::tgDataManager ( )

The default constructor. Nothing to do in this base class, but subclasses might do something (e.g. set up a path name for a data logger.)

Nothing to do, in this abstract base class.

Definition at line 41 of file tgDataManager.cpp.

tgDataManager::~tgDataManager ( )
virtual

Destructor. Deletes the sensors and sensor infos, if not already deleted by teardown()

In the destructor, we must be sure to delete everything in both the m_sensors and m_sensorInfos lists. Teardown only deletes sensors, not sensor infos, so this is a double-check for sensors and the only real delete for sensor infos.

Definition at line 53 of file tgDataManager.cpp.

Member Function Documentation

void tgDataManager::addSenseable ( tgSenseable pSenseable)
virtual

Add a tgSenseable object to this data manager. These objects will be checked via the sensor infos, and sensors will be assigned to them if appropriate.

Parameters
[in]pSenseablea pointer to a tgSenseable object that will be added to this data manager's list of senseable objects.

This method adds sense-able objects to this data manager. It takes in a pointer to a sense-able object and pushes it to the current list of tgSenseables.

Definition at line 224 of file tgDataManager.cpp.

Here is the caller graph for this function:

void tgDataManager::addSensorInfo ( tgSensorInfo pSensorInfo)
virtual

Add a sensor info object to the current list of sensor infos.

Parameters
[in]pSensorInfoa pointer to a tgSensorInfo.

This method adds sensor info objects to this data manager. It takes in a pointer to a sensor info and pushes it to the current list of sensor infos.

Definition at line 198 of file tgDataManager.cpp.

Here is the caller graph for this function:

void tgDataManager::setup ( )
virtual

Setup creates the sensors via sensor info classes, and may do other things (ex., open a log file and put in a header.)

Create the sensors! Note that it is up to the child classes to do any other type of setup besides sensor creation. For example, a data logger will have to first call this parent function, then ask for the sensor heading from each sensor, then... etc.

Reimplemented in tgDataLogger2.

Definition at line 121 of file tgDataManager.cpp.

Here is the caller graph for this function:

void tgDataManager::step ( double  dt)
virtual

Advance the simulation.

Parameters
[in]dtthe number of seconds since the previous call; std::invalid_argument is thrown if dt is not positive
Exceptions
std::invalid_argumentif dt is not positive

The step method is where data is actually collected! This base class won't do anything, but subclasses will re-implement this method.

Reimplemented in tgDataLogger2.

Definition at line 178 of file tgDataManager.cpp.

void tgDataManager::teardown ( )
virtual

Deletes all objects inside this (undoes setup)

The teardown method has to remove all the sensors and sensor infos. Note that this method could be redefined by subclasses, for example to do some final step with a mesage-passing algorithm before the simulation ends. TO-DO: what's a good way to capture the deletion of sensors and sensorInfos that doesn't require subclasses to copy-and-paste from this teardown method?

Reimplemented in tgDataLogger2.

Definition at line 149 of file tgDataManager.cpp.

Here is the caller graph for this function:

std::string tgDataManager::toString ( ) const
virtual

Returns some basic information about this tgDataManager, like the type of data manager it is, the number of sensor infos and sensors that are held in this object's lists.

Returns
informative string about this data manager

The toString method for data managers should include a list of the number of sensors and sensor Infos it has.

Reimplemented in tgDataLogger2.

Definition at line 246 of file tgDataManager.cpp.

Here is the caller graph for this function:

Member Data Documentation

std::vector<tgSenseable*> tgDataManager::m_senseables
protected

A data manager will also have a list of tgSenseable objects (really, just tgModels most of the time) that it will collect data from.

Definition at line 137 of file tgDataManager.h.

std::vector<tgSensorInfo*> tgDataManager::m_sensorInfos
protected

Data managers also have a list of the sensor infos that have been passed in to it. These are used to create the sensors

Definition at line 131 of file tgDataManager.h.

std::vector<tgSensor*> tgDataManager::m_sensors
protected

A data manager has a list of sensors that it has created (during setup.)

Definition at line 124 of file tgDataManager.h.


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