mirror of
https://github.com/nasa/fprime.git
synced 2025-12-12 07:43:50 -06:00
* Update fpp version Add more warnings to FppTest * Update fpp version Add warnings to build * Enable warnings in unit tests Fix warnings * Clean up test code * Update fpp version Remove workarounds in unit test builds * Update fpp version Fix warnings * Revise DpManager tests Remove conversion warnings * Revise DpWriter tests Remove conversion warnings * Refactor Hash Provide a size type to remove dependencies on NATIVE_INT_TYPE, which is going away. * Revise top-level CMakeLists.txt * Fix warnings in Ref * Fix warnings in Ref, RPI * Revise warning flags * Revise code to eliminate warnings * Revise code to fix warnings * Revise code to fix warnings * Revise code to fix warnings * Revise Serializable.cpp * Revise Serializable.cpp * Revise warning flags * Fix warnings in test code * Fix warnings * Fix warnings * Fix warnings and static analysis errors * Fix warnings * Fix warnings * Fix warnings * Fix warnings * Fix warnings * Turn off -Wshadow for unit tests * Revise comments * Fix warnings * Fix warnings * Fix warnings * Fix warnings * Fix warnings * Fix warnings * Fix warnings * Fix warnings * Fix warnings * Enable -Wshadow for main ut builds * Revise compile options * Remove commented-out code * Update STest Eliminate warnings * Fix warning * Fix warnings * Fix warning * Fix warning * Fix warning * Revise comments * Revise static cast expression * Cast return type to void * Remove unneeded cast * Fix warnings that appear on the F Prime dev machine * Fix more warnings * Enable more warnings * Update fpp version * Remove commented-out compiler flags * Enable warning flag in CmdDispatcher * Disable -Wconversion in gtest * Revise compiler warning flags * Revise compiler options * Revise compiler flags * Revise compiler flags * Revise compiler flags * Revise compiler flags * Revise Buffer * Fix comments * Fix warning flags * Fix compiler warning flags * Fix compiler warnings * Fix compiler warning flags * Fix compiler warnings * Fix compiler warning flags * Fix compiler warning flags * Fix compiler warning flags * Fix compiler warning flags * Fix compiler warning flags * Fix compiler warning flags * Fix compiler warning flags * Fix compiler warning flags * Revise compiler warning flags * Restore deleted test * Fixing UT_TARGET collision --------- Co-authored-by: Robert L Bocchino <bocchino@fprime-fsw-0.jpl.nasa.gov> Co-authored-by: Michael D Starch <Michael.D.Starch@jpl.nasa.gov> Co-authored-by: M Starch <LeStarch@googlemail.com>
53 lines
1.5 KiB
C++
53 lines
1.5 KiB
C++
// ======================================================================
|
|
// \title OnChangeChannel.hpp
|
|
// \author Rob Bocchino
|
|
// \brief A model of an on-change channel for testing
|
|
//
|
|
// \copyright
|
|
// Copyright (C) 2023 California Institute of Technology.
|
|
// ALL RIGHTS RESERVED. United States Government Sponsorship
|
|
// acknowledged. Any commercial use must be negotiated with the Office
|
|
// of Technology Transfer at the California Institute of Technology.
|
|
// ======================================================================
|
|
|
|
#ifndef TestUtils_OnChangeChannel_HPP
|
|
#define TestUtils_OnChangeChannel_HPP
|
|
|
|
#include <FpConfig.hpp>
|
|
#include <cstring>
|
|
|
|
#include "TestUtils/Option.hpp"
|
|
|
|
namespace TestUtils {
|
|
|
|
//! The status of an on-change telemetry channel
|
|
enum class OnChangeStatus { CHANGED, NOT_CHANGED };
|
|
|
|
//! A model of an on-change telemetry channel
|
|
template <typename T>
|
|
class OnChangeChannel {
|
|
public:
|
|
//! Constructor
|
|
explicit OnChangeChannel(T a_value) : value(a_value) {}
|
|
//! Update the previous value
|
|
OnChangeStatus updatePrev() {
|
|
const auto status = ((!this->prev.hasValue()) || (this->value != this->prev.get()))
|
|
? OnChangeStatus::CHANGED
|
|
: OnChangeStatus::NOT_CHANGED;
|
|
this->prev.set(this->value);
|
|
return status;
|
|
}
|
|
|
|
public:
|
|
//! The current value
|
|
T value;
|
|
|
|
private:
|
|
//! The previous value
|
|
Option<T> prev;
|
|
};
|
|
|
|
} // namespace TestUtils
|
|
|
|
#endif
|