.. include:: Exercise Foundation: ``Sensor`` Hierarchy ========================================= .. contents:: :local: Hypothetical ------------ We are an organization that sits on a large pile of software. Sensors, *temperature* sensors actually, are fundamental in that pile, and there are many sensor implementations around. All are organized in a class hierarchy, starting at an abstract base class (an :doc:`interface `): .. literalinclude:: /trainings/material/soup/cxx/cxx-code/sensors-core/sensors/sensor.h :caption: :download:`/trainings/material/soup/cxx/cxx-code/sensors-core/sensors/sensor.h` :language: c++ Two concrete implementations of such sensors that we will use in the exercise series in this course are: * :download:`RandomSensor `. That sensor yields floating point random numbers in a configurable range. * :download:`ConstantSensor `. That one always yields the same temperature. Cool for testing. We will extend that hierarchy along with the exercises. Class Hierarchy --------------- .. plantuml:: @startuml interface Sensor { + double get_temperature() } class I2CSensor { + double get_value() } class RandomSensor { + double get_value() } class ConstantSensor { + double get_value() } Sensor <|.. I2CSensor Sensor <|.. RandomSensor Sensor <|.. ConstantSensor @enduml