Class LoanedStateInterface

Nested Relationships

Nested Types

Class Documentation

class LoanedStateInterface

Public Types

using Deleter = std::function<void(void)>

Public Functions

inline explicit LoanedStateInterface(const StateInterface &state_interface)
inline LoanedStateInterface(const StateInterface &state_interface, Deleter &&deleter)
inline explicit LoanedStateInterface(StateInterface::ConstSharedPtr state_interface)
inline LoanedStateInterface(StateInterface::ConstSharedPtr state_interface, Deleter &&deleter)
LoanedStateInterface(const LoanedStateInterface &other) = delete
LoanedStateInterface(LoanedStateInterface &&other) = default
inline virtual ~LoanedStateInterface()
inline const std::string &get_name() const
inline const std::string &get_interface_name() const
inline const std::string &get_prefix_name() const
inline double get_value() const
template<typename T = double>
inline std::optional<T> get_optional(unsigned int max_tries = 10) const

Get the value of the state interface.

Note

The method is thread-safe and non-blocking.

Note

When different threads access the internal handle at same instance, and if they are unable to lock the handle to access the value, the handle returns std::nullopt. If the operation is successful, the value is returned.

Note

The method will try to get the value max_tries times before returning std::nullopt. The method will yield the thread between tries. If the value is retrieved successfully, the method returns the value immediately.

Template Parameters:

T – The type of the value to be retrieved.

Parameters:

max_tries – The maximum number of tries to get the value.

Returns:

The value of the state interface if it accessed successfully, std::nullopt otherwise.

inline HandleDataType get_data_type() const

Get the data type of the state interface.

Returns:

The data type of the state interface.

inline bool is_castable_to_double() const

Check if the state interface can be casted to double.

Returns:

True if the state interface can be casted to double, false otherwise.

Protected Attributes

const StateInterface &state_interface_
Deleter deleter_