M5UnitUnified 0.0.2 git rev:a353e8c
Loading...
Searching...
No Matches
m5::unit::PeriodicMeasurementAdapter< Derived, MD > Class Template Referenceabstract

Interface class for periodic measurement (CRTP) More...

#include <M5UnitComponent.hpp>

Public Member Functions

Periodic measurement
template<typename... Args>
bool startPeriodicMeasurement (Args &&... args)
 Start periodic measurement.
 
template<typename... Args>
bool stopPeriodicMeasurement (Args &&... args)
 Stop periodic measurement.
 
Data
size_t available () const
 Gets the number of stored data.
 
bool empty () const
 Is empty stored data?
 
bool full () const
 Is stored data full?
 
MD oldest () const
 Retrieve oldest stored data.
 
MD latest () const
 Retrieve latest stored data.
 
void discard ()
 Discard the oldest data accumulated.
 
void flush ()
 Discard all data.
 

Protected Member Functions

Pure virtual functions
Note
Must implement in derived class
virtual size_t available_periodic_measurement_data () const =0
 
virtual bool empty_periodic_measurement_data () const =0
 
virtual bool full_periodic_measurement_data () const =0
 
virtual void discard_periodic_measurement_data ()=0
 
virtual void flush_periodic_measurement_data ()=0
 

Detailed Description

template<class Derived, typename MD>
class m5::unit::PeriodicMeasurementAdapter< Derived, MD >

Interface class for periodic measurement (CRTP)

Common interface for accumulated periodic measurement data

Provide a common interface for periodic measurements for each unit

Template Parameters
DerivedDerived class
MDType of the measurement data group
Warning
MUST IMPLEMENT some functions (NOT VERTUAL)
  • MD Derived::oldest_periodic_data() const;
  • MD Derived::latestt_periodic_data() const;
  • bool Derived::start_periodic_measurement(any arguments);
  • bool Derived::stop_periodic_measurement():
MUST ADD std::unique_ptr<m5::container::CircularBuffer<MD>> _data{} in Derived class
This class is an interface class and should not have any data
Note
See also M5_UNIT_COMPONENT_PERIODIC_MEASUREMENT_ADAPTER_HPP_BUILDER

Member Function Documentation

◆ startPeriodicMeasurement()

template<class Derived , typename MD >
template<typename... Args>
bool m5::unit::PeriodicMeasurementAdapter< Derived, MD >::startPeriodicMeasurement ( Args &&... args)
inline

Start periodic measurement.

Template Parameters
ArgsOptional arguments
Returns
True if successful
Note
Call Derived::start_periodic_measurement

◆ stopPeriodicMeasurement()

template<class Derived , typename MD >
template<typename... Args>
bool m5::unit::PeriodicMeasurementAdapter< Derived, MD >::stopPeriodicMeasurement ( Args &&... args)
inline

Stop periodic measurement.

Template Parameters
ArgsOptional arguments
Returns
True if successful
Note
Call Derived::stop_periodic_measurement