Template Class LoggedValue

Class Documentation

template<typename T>
class LoggedValue

The LoggedValue class is a container of a variable that automatically register/unregister to a Channel when created/destroyed.

Setting and getting values is thread-safe.

Public Functions

inline LoggedValue()
inline ~LoggedValue()
LoggedValue(LoggedValue const &other) = delete
LoggedValue &operator=(LoggedValue const &other) = delete
LoggedValue(LoggedValue &&other) = default
LoggedValue &operator=(LoggedValue &&other) = default
inline void set(const T &value, bool auto_enable = true)

set the value of the variable.

Parameters:
  • value – new value

  • auto_enable – if true and the current instance is disabled, call setEnabled(true)

inline T get()

get the stored value.

inline MutablePtr<T> getLockedPtr()
inline MutablePtr<T> getMutablePtr()

This method allows the user to access the object by reference (read/write access), in a thread-safe way.

Usage:

if(auto ref = value->getMutablePtr()) { auto current_value = *ref; };

inline ConstPtr<T> getConstPtr()

This method allows the user to access the object as const reference (read-only) in a thread-safe way.

Usage:

if(auto ref = value->getMutablePtr()) { auto current_value = *ref; };

inline void setEnabled(bool enabled)

Disabling a LoggedValue means that we will not record it in the snapshot.

inline bool isEnabled() const

Protected Functions

inline LoggedValue(const std::shared_ptr<LogChannel> &channel, const std::string &name, T initial_value)

Protected Attributes

friend LogChannel