Class thl::Parameter#
-
class Parameter#
Object-oriented wrapper for parameter access with type conversion support.
Parameter holds a ParameterRecord* and a State* — it is a lightweight view over the underlying record. Metadata accessors (def(), range(), key(), id()) forward directly to the immutable m_def on the record.
Type checking methods (
is_double(),is_float(), etc.) are real-time safeto<T>()for numeric types (double, float, int, bool) is real-time safeto<std::string>()requiresallow_blocking=trueas it may allocate memory
- Real-Time Safety
See also
State for the root state container
See also
StateGroup for hierarchical parameter organization
Public Functions
-
template<typename T>
T to(bool allow_blocking = false) const# Converts the parameter value to the specified type.
Provides type conversion with automatic casting between numeric types.
Note
REAL-TIME SAFE for numeric types (double, float, int, bool)
Warning
String type requires
allow_blocking=trueas it may allocate memory- Template Parameters:
T – Target type (double, float, int, bool, or std::string)
- Parameters:
allow_blocking – If true, allows blocking operations (required for string type). When false and T is std::string, throws BlockingException.
- Throws:
BlockingException – if T is std::string and allow_blocking is false
- Returns:
The parameter value converted to type T
-
ParameterType get_type() const#
Gets the type of the parameter.
Note
REAL-TIME SAFE
- Returns:
ParameterType enum indicating the stored type
-
bool is_double() const#
-
bool is_float() const#
-
bool is_int() const#
-
bool is_bool() const#
-
bool is_string() const#
-
void notify(ParameterListener *source = nullptr) const#
Notifies all listeners about this parameter.
Triggers parameter change callbacks for registered listeners. If source is provided, source->m_strategy controls which listeners receive the notification.
Warning
NOT real-time safe - invokes listener callbacks
- Parameters:
source – Source listener for strategy-based filtering (optional)
-
std::string_view key() const#
Gets the full path key for this parameter.
Note
REAL-TIME SAFE
- Returns:
String view into the map node’s key (stable for parameter lifetime)
-
const ParameterDefinition &def() const#
Gets the immutable parameter definition.
Note
REAL-TIME SAFE — immutable after construction
- Returns:
Reference to the const ParameterDefinition
-
const Range &range() const#
Gets the parameter range.
Note
REAL-TIME SAFE — immutable after construction
- Returns:
Reference to the Range within the definition
-
uint32_t id() const#
Gets the parameter ID (UINT32_MAX if not assigned).
Note
REAL-TIME SAFE — immutable after construction
-
template<typename T>
ParameterHandle<T> get_handle() const# Returns a typed ParameterHandle for direct atomic load/store.
- Template Parameters:
T – Numeric type matching the parameter’s native type
- Throws:
std::invalid_argument – if T doesn’t match the parameter’s native type
- Returns:
ParameterHandle<T> pointing to the underlying ParameterRecord