DUDS
Distributed Update of Data from Something
duds::hardware::devices::GenericDevice< SVT, SQT, TVT, TQT > Class Template Referenceabstract

Represents something with one or more sensors that are sampled through the same hardware. More...

#include <Device.hpp>

Inheritance diagram for duds::hardware::devices::GenericDevice< SVT, SQT, TVT, TQT >:
Collaboration diagram for duds::hardware::devices::GenericDevice< SVT, SQT, TVT, TQT >:

Classes

class  DestructCounter
 Used to assure the destructor function does not return before Sensor objects quit using member functions on this object on other threads. More...
 

Public Types

typedef clocks::GenericClock< SVT, SQT, TVT, TQT > Clock
 The clock driver type used by the instruments of this device for time stamps. More...
 
typedef std::shared_ptr< ClockClockSptr
 A shared pointer type to the clock type used by this device. More...
 
typedef std::shared_ptr< const MeasurementConstMeasurementSptr
 A shared pointer type to the const measurement type used by this device. More...
 
typedef std::shared_ptr< const SensorConstSensorSptr
 A shared pointer type to the const sensor type used by this device. More...
 
typedef duds::data::GenericMeasurement< SVT, SQT, TVT, TQT > Measurement
 The measurement type provided by the instruments of this device. More...
 
typedef std::shared_ptr< MeasurementMeasurementSptr
 A shared pointer type to the measurement type used by this device. More...
 
typedef GenericSensor< SVT, SQT, TVT, TQT > Sensor
 The sensor type used by this device. More...
 
typedef std::shared_ptr< SensorSensorSptr
 A shared pointer type to the sensor type used by this device. More...
 
typedef std::weak_ptr< SensorSensorWptr
 A weak pointer type to the sensor type used by this device. More...
 

Public Member Functions

 ~GenericDevice ()
 Modifies member Sensor objects so they no longer have a pointer back to this object, and waits for calls those objects may be making to sharedPtr() to complete. More...
 
ConstMeasurementSptr currentMeasurement (unsigned int sIdx=0) const
 Returns the measurement object for the sensor at the given device specific index. More...
 
unsigned int numSensors () const
 Returns the number of sensors provided by this device. More...
 
virtual void sample ()=0
 Samples the device and updates its sensor objects, but does not provide timestamps in the sensors' measurement objects. More...
 
virtual void sample (const ClockSptr &clock)=0
 Samples the device and updates its sensor objects, and provides a timestamp from the given clock device. More...
 
const SensorSptrsensor (unsigned int sIdx=0) const
 Returns the sensor object at the given device specific index. More...
 
std::shared_ptr< GenericDevice< SVT, SQT, TVT, TQT > > sharedPtr ()
 Returns a shared pointer to this device object; will be empty if this object's destructor is running. More...
 
- Public Member Functions inherited from duds::Something
virtual ~Something ()=0
 
std::string getName () const
 Returns the name for the current locale. More...
 
const general::LanguageTaggedStringMapnames () const
 Returns the set of names for all locales and languages. More...
 
bool operator!= (const Something &s) const
 Something objects are compared using the someId member. More...
 
bool operator< (const Something &s) const
 Something objects are compared using the someId member. More...
 
bool operator<= (const Something &s) const
 Something objects are compared using the someId member. More...
 
bool operator== (const Something &s) const
 Something objects are compared using the someId member. More...
 
bool operator> (const Something &s) const
 Something objects are compared using the someId member. More...
 
bool operator>= (const Something &s) const
 Something objects are compared using the someId member. More...
 
template<class DerivedClass >
std::shared_ptr< DerivedClass > sharedPtr () const
 Returns a shared pointer to this object for a derived class. More...
 
const boost::uuids::uuid & uuid () const
 Returns the object's unique identifier. More...
 

Protected Member Functions

 GenericDevice ()=default
 Derived classes should create Sensor objects and place them in sens either in the constructor or an initialization function. More...
 
 GenericDevice (const boost::uuids::uuid &id)
 Derived classes should create Sensor objects and place them in sens either in the constructor or an initialization function. More...
 
void setMeasurement (const ConstMeasurementSptr &store, int sIdx=0) const
 Updates the current measurement of a member sensor. More...
 
void setMeasurement (ConstMeasurementSptr &&store, int sIdx=0) const
 Updates the current measurement of a member sensor. More...
 
- Protected Member Functions inherited from duds::Something
 Something ()=default
 Simple constructor. More...
 
 Something (const boost::uuids::uuid &id)
 Creates Something with the given UUID. More...
 
void setUuid (const boost::uuids::uuid &id)
 Sets the UUID that is associated with this object. More...
 

Protected Attributes

std::vector< SensorSptrsens
 Contains Sensor objects to represent all the kinds of data this device can collect. More...
 
- Protected Attributes inherited from duds::Something
general::LanguageTaggedStringMap ltnames
 A name for this item intended for user presentation. More...
 

Private Attributes

std::atomic< unsigned int > destructWait = 0
 Used to assure the destructor function does not return before Sensor objects quit using member functions on this object on other threads. More...
 

Detailed Description

template<class SVT, class SQT, class TVT, class TQT>
class duds::hardware::devices::GenericDevice< SVT, SQT, TVT, TQT >

Represents something with one or more sensors that are sampled through the same hardware.

This is intended to support sampling sensors and finding sensors.

Template Parameters
SVTSample value type
SQTSample quality type
TVTTime value type
TQTTime quality type
Author
Jeff Jackowski

Definition at line 34 of file Device.hpp.

Member Typedef Documentation

◆ Clock

template<class SVT , class SQT , class TVT , class TQT >
typedef clocks::GenericClock<SVT, SQT, TVT, TQT> duds::hardware::devices::GenericDevice< SVT, SQT, TVT, TQT >::Clock

The clock driver type used by the instruments of this device for time stamps.

Definition at line 88 of file Device.hpp.

◆ ClockSptr

template<class SVT , class SQT , class TVT , class TQT >
typedef std::shared_ptr<Clock> duds::hardware::devices::GenericDevice< SVT, SQT, TVT, TQT >::ClockSptr

A shared pointer type to the clock type used by this device.

Definition at line 92 of file Device.hpp.

◆ ConstMeasurementSptr

template<class SVT , class SQT , class TVT , class TQT >
typedef std::shared_ptr<const Measurement> duds::hardware::devices::GenericDevice< SVT, SQT, TVT, TQT >::ConstMeasurementSptr

A shared pointer type to the const measurement type used by this device.

Definition at line 83 of file Device.hpp.

◆ ConstSensorSptr

template<class SVT , class SQT , class TVT , class TQT >
typedef std::shared_ptr<const Sensor> duds::hardware::devices::GenericDevice< SVT, SQT, TVT, TQT >::ConstSensorSptr

A shared pointer type to the const sensor type used by this device.

Definition at line 67 of file Device.hpp.

◆ Measurement

template<class SVT , class SQT , class TVT , class TQT >
typedef duds::data::GenericMeasurement<SVT, SQT, TVT, TQT> duds::hardware::devices::GenericDevice< SVT, SQT, TVT, TQT >::Measurement

The measurement type provided by the instruments of this device.

Definition at line 75 of file Device.hpp.

◆ MeasurementSptr

template<class SVT , class SQT , class TVT , class TQT >
typedef std::shared_ptr<Measurement> duds::hardware::devices::GenericDevice< SVT, SQT, TVT, TQT >::MeasurementSptr

A shared pointer type to the measurement type used by this device.

Definition at line 79 of file Device.hpp.

◆ Sensor

template<class SVT , class SQT , class TVT , class TQT >
typedef GenericSensor<SVT, SQT, TVT, TQT> duds::hardware::devices::GenericDevice< SVT, SQT, TVT, TQT >::Sensor

The sensor type used by this device.

Definition at line 59 of file Device.hpp.

◆ SensorSptr

template<class SVT , class SQT , class TVT , class TQT >
typedef std::shared_ptr<Sensor> duds::hardware::devices::GenericDevice< SVT, SQT, TVT, TQT >::SensorSptr

A shared pointer type to the sensor type used by this device.

Definition at line 63 of file Device.hpp.

◆ SensorWptr

template<class SVT , class SQT , class TVT , class TQT >
typedef std::weak_ptr<Sensor> duds::hardware::devices::GenericDevice< SVT, SQT, TVT, TQT >::SensorWptr

A weak pointer type to the sensor type used by this device.

Definition at line 71 of file Device.hpp.

Constructor & Destructor Documentation

◆ GenericDevice() [1/2]

template<class SVT , class SQT , class TVT , class TQT >
duds::hardware::devices::GenericDevice< SVT, SQT, TVT, TQT >::GenericDevice ( )
protecteddefault

Derived classes should create Sensor objects and place them in sens either in the constructor or an initialization function.

◆ GenericDevice() [2/2]

template<class SVT , class SQT , class TVT , class TQT >
duds::hardware::devices::GenericDevice< SVT, SQT, TVT, TQT >::GenericDevice ( const boost::uuids::uuid &  id)
inlineprotected

Derived classes should create Sensor objects and place them in sens either in the constructor or an initialization function.

Parameters
idThe UUID for this device.

Definition at line 126 of file Device.hpp.

◆ ~GenericDevice()

template<class SVT , class SQT , class TVT , class TQT >
duds::hardware::devices::GenericDevice< SVT, SQT, TVT, TQT >::~GenericDevice ( )
inline

Modifies member Sensor objects so they no longer have a pointer back to this object, and waits for calls those objects may be making to sharedPtr() to complete.

Definition at line 133 of file Device.hpp.

Member Function Documentation

◆ currentMeasurement()

template<class SVT , class SQT , class TVT , class TQT >
ConstMeasurementSptr duds::hardware::devices::GenericDevice< SVT, SQT, TVT, TQT >::currentMeasurement ( unsigned int  sIdx = 0) const
inline

Returns the measurement object for the sensor at the given device specific index.

Parameters
sIdxThe sensor index.
Returns
The current measurement object from the sensor.
Todo:
Throw exception if index is bad.

Definition at line 193 of file Device.hpp.

◆ numSensors()

template<class SVT , class SQT , class TVT , class TQT >
unsigned int duds::hardware::devices::GenericDevice< SVT, SQT, TVT, TQT >::numSensors ( ) const
inline

Returns the number of sensors provided by this device.

Definition at line 173 of file Device.hpp.

◆ sample() [1/2]

template<class SVT , class SQT , class TVT , class TQT >
virtual void duds::hardware::devices::GenericDevice< SVT, SQT, TVT, TQT >::sample ( )
pure virtual

Samples the device and updates its sensor objects, but does not provide timestamps in the sensors' measurement objects.

Todo:
Is this needed, or should sample(const ClockSptr &) be called with an empty shared pointer?

Implemented in duds::hardware::devices::clocks::GenericClock< SVT, SQT, TVT, TQT >, duds::hardware::devices::clocks::GenericPosixClock< SVT, SQT, TVT, TQT >, duds::hardware::devices::clocks::GenericLinuxClock< SVT, SQT, TVT, TQT >, and duds::hardware::devices::clocks::GenericCppClock< CLK, SVT, SQT, TVT, TQT >.

◆ sample() [2/2]

template<class SVT , class SQT , class TVT , class TQT >
virtual void duds::hardware::devices::GenericDevice< SVT, SQT, TVT, TQT >::sample ( const ClockSptr clock)
pure virtual

Samples the device and updates its sensor objects, and provides a timestamp from the given clock device.

Parameters
clockThe clock that will provide a timestamp for the measurements taken by this device.

◆ sensor()

template<class SVT , class SQT , class TVT , class TQT >
const SensorSptr& duds::hardware::devices::GenericDevice< SVT, SQT, TVT, TQT >::sensor ( unsigned int  sIdx = 0) const
inline

Returns the sensor object at the given device specific index.

The retuned object may outlive this device.

Parameters
sIdxThe sensor index.
Returns
The sensor object.
Todo:
Throw exception if index is bad.

Definition at line 182 of file Device.hpp.

◆ setMeasurement() [1/2]

template<class SVT , class SQT , class TVT , class TQT >
void duds::hardware::devices::GenericDevice< SVT, SQT, TVT, TQT >::setMeasurement ( const ConstMeasurementSptr store,
int  sIdx = 0 
) const
inlineprotected

Updates the current measurement of a member sensor.

Parameters
storeThe new measurement object.
sIdxThe index of the sensor to update.

Definition at line 105 of file Device.hpp.

Referenced by duds::hardware::devices::clocks::GenericCppClock< CLK, SVT, SQT, TVT, TQT >::sample(), and duds::hardware::devices::clocks::GenericLinuxClock< SVT, SQT, TVT, TQT >::sample().

◆ setMeasurement() [2/2]

template<class SVT , class SQT , class TVT , class TQT >
void duds::hardware::devices::GenericDevice< SVT, SQT, TVT, TQT >::setMeasurement ( ConstMeasurementSptr &&  store,
int  sIdx = 0 
) const
inlineprotected

Updates the current measurement of a member sensor.

Parameters
storeThe new measurement object.
sIdxThe index of the sensor to update.

Definition at line 113 of file Device.hpp.

◆ sharedPtr()

template<class SVT , class SQT , class TVT , class TQT >
std::shared_ptr< GenericDevice< SVT, SQT, TVT, TQT > > duds::hardware::devices::GenericDevice< SVT, SQT, TVT, TQT >::sharedPtr ( )
inline

Returns a shared pointer to this device object; will be empty if this object's destructor is running.

Definition at line 147 of file Device.hpp.

Referenced by duds::hardware::devices::GenericSensor< SVT, SQT, TVT, TQT >::device().

Member Data Documentation

◆ destructWait

template<class SVT , class SQT , class TVT , class TQT >
std::atomic<unsigned int> duds::hardware::devices::GenericDevice< SVT, SQT, TVT, TQT >::destructWait = 0
private

Used to assure the destructor function does not return before Sensor objects quit using member functions on this object on other threads.

Definition at line 39 of file Device.hpp.

◆ sens

template<class SVT , class SQT , class TVT , class TQT >
std::vector<SensorSptr> duds::hardware::devices::GenericDevice< SVT, SQT, TVT, TQT >::sens
protected

Contains Sensor objects to represent all the kinds of data this device can collect.

Each sensor must be placed in the vector at the index equal to Sensor::index().

Definition at line 99 of file Device.hpp.

Referenced by duds::hardware::devices::clocks::GenericLinuxClock< SVT, SQT, TVT, TQT >::setSample().


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