Template Class HistoryManager

Nested Relationships

Nested Types

Class Documentation

template<class T>
class HistoryManager

History data manager.

Basic buffer history manager implementation using a deque

Template Parameters:

Type – of the buffer elements

Public Types

typedef std::deque<HistoryElement> HistoryContainer

Buffer type

Public Functions

inline HistoryManager(int maxCapacity, int elementSize)

Constructor

Parameters:
  • maxCapacity – Max total size for the buffer

  • elementSize – Max total size size for the element buffer

inline ~HistoryManager()

Destructor

HistoryManager(HistoryManager const &x) = delete

Disable copy constructor

Parameters:

x – &#8212;

void operator=(HistoryManager const &x) = delete

Disable copy assignment

Parameters:

x – &#8212;

inline const int getMaxCapacity() const

Gets the max buffer capacity

Returns:

Max buffer capacity

inline const int getElementSize() const

Gets the max buffer element capacity

Returns:

Max buffer element capacity

inline const HistoryContainer &getHistoryContainer() const

Gets the reference to the buffer container

Returns:

Buffer container

inline HistoryContainer &getHistoryContainerNC()

Gets the reference to the buffer container

Returns:

Buffer container

inline void setMaxCapacity(int maxCapacity)

Sets the max buffer capacity

Parameters:

maxCapacity – Max buffer capacity

inline void pushElement(const typename HistoryElement::DataContainer &data, const float timestamp)

Inserts a new element (copy) into the buffer

Parameters:
  • data – New Data container reference

  • timestamp – timestamp for new data

inline void pushBeatElement(HistoryManager<float> &beatDistanceHistory, float *beatDistanceAverage, int *numBeatAverage, const TArray<bool> &data, const float timestamp)

Inserts a new element (copy) into the buffer (BPM optimization)

Parameters:
  • beatDistanceHistory – Beat Distance History Container

  • beatDistanceAverage – Beat Distance Average Container pointer

  • numBeatAverage – Num of beats of the history Container pointer

  • data – Current Beat data Container

  • timestamp – Current beat timestamp

inline bool getLastElement(typename HistoryElement::DataContainer &data, const float timestamp)

Check and return the last element of the buffer

Parameters:
  • data[out] Element data output

  • timestamp – Element timestamp

Returns:

bool Element already in the last buffer position

inline void clearHistory()

Clears the history buffer

inline void getAverageHistory(T *averageSpectrum)

Calculates the average of the current buffer elements

Parameters:

averageSpectrum[out] Output average results

inline void getVarianceHistory(T *varianceSpectrum, const T *averageSpectrum)

Calculates the variance of the current buffer elements with their average results

Parameters:
  • varianceSpectrum[out] Output variance results

  • averageSpectrum[in] Buffer average results

inline void getAsTArray(TArray<T> *timestampTArray, TArray<T> *dataTArray, int dataIndex)

Returns a Tarray with the history data and timestamps

Parameters:
  • timestampTArray[out] History data timestamps

  • dataTArray[out] History data

  • dataIndex[in] History index

class HistoryElement

Buffer element type

Public Types

typedef TArray<T> DataContainer

Buffer element data type

Public Functions

inline HistoryElement(const DataContainer &rawData, float timestamp)

Constructor

Parameters:
  • rawData – Buffer element data (copy)

  • timestamp – Buffer element timestamp

inline ~HistoryElement()

Destructor

HistoryElement(HistoryElement const &x) = delete

Disable copy constructor

Parameters:

x – &#8212;

void operator=(HistoryElement const &x) = delete

Disable copy assignment

Parameters:

x – &#8212;

inline const DataContainer &get_rawData() const

Gets the reference to the buffer container

Returns:

Buffer container

inline void set_rawDataValue(const int index, const T &value)

Set the value for an specific buffer position

Parameters:
  • index – Element Position

  • value – Element value

inline const float &get_timestamp() const

Get the timestamp for this history element

Returns:

Timestamp of the container

inline void set_timestamp(const float timestamp)

Set the timestamp for this history element

Parameters:

timestamp – New timestamp of the container