F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
OnChangeChannel.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title OnChangeChannel.hpp
3 // \author Rob Bocchino
4 // \brief A model of an on-change channel for testing
5 //
6 // \copyright
7 // Copyright (C) 2023 California Institute of Technology.
8 // ALL RIGHTS RESERVED. United States Government Sponsorship
9 // acknowledged. Any commercial use must be negotiated with the Office
10 // of Technology Transfer at the California Institute of Technology.
11 // ======================================================================
12 
13 #ifndef TestUtils_OnChangeChannel_HPP
14 #define TestUtils_OnChangeChannel_HPP
15 
16 #include <FpConfig.hpp>
17 #include <cstring>
18 
19 #include "TestUtils/Option.hpp"
20 
21 namespace TestUtils {
22 
25 
27 template <typename T>
29  public:
31  explicit OnChangeChannel(T value) : value(value) {}
34  const auto status = ((!this->prev.hasValue()) || (this->value != this->prev.get()))
37  this->prev.set(this->value);
38  return status;
39  }
40 
41  public:
43  T value;
44 
45  private:
47  Option<T> prev;
48 };
49 
50 } // namespace TestUtils
51 
52 #endif
C++-compatible configuration header for fprime configuration.
A model of an on-change telemetry channel.
T value
The current value.
OnChangeStatus updatePrev()
Update the previous value.
OnChangeChannel(T value)
Constructor.
An optional value.
Definition: Option.hpp:20
OnChangeStatus
The status of an on-change telemetry channel.