parameters: add param_reset_no_notification()

- add reset() to Param<>
This commit is contained in:
Daniel Agar 2020-10-14 21:22:33 -04:00 committed by Beat Küng
parent d8448c0a76
commit 7255f5feac
3 changed files with 47 additions and 3 deletions

View File

@ -132,6 +132,12 @@ public:
void set(float val) { _val = val; }
void reset()
{
param_reset_no_notification(handle());
update();
}
bool update() { return param_get(handle(), &_val) == 0; }
param_t handle() const { return param_handle(p); }
@ -166,6 +172,12 @@ public:
void set(float val) { _val = val; }
void reset()
{
param_reset_no_notification(handle());
update();
}
bool update() { return param_get(handle(), &_val) == 0; }
param_t handle() const { return param_handle(p); }
@ -198,6 +210,12 @@ public:
void set(int32_t val) { _val = val; }
void reset()
{
param_reset_no_notification(handle());
update();
}
bool update() { return param_get(handle(), &_val) == 0; }
param_t handle() const { return param_handle(p); }
@ -232,6 +250,12 @@ public:
void set(int32_t val) { _val = val; }
void reset()
{
param_reset_no_notification(handle());
update();
}
bool update() { return param_get(handle(), &_val) == 0; }
param_t handle() const { return param_handle(p); }
@ -272,6 +296,12 @@ public:
void set(bool val) { _val = val; }
void reset()
{
param_reset_no_notification(handle());
update();
}
bool update()
{
int32_t value_int;

View File

@ -260,6 +260,17 @@ __EXPORT void param_notify_changes(void);
*/
__EXPORT int param_reset(param_t param);
/**
* Reset a parameter to its default value, but do not notify the system about the change.
*
* This function frees any storage used by struct parameters, and returns the parameter
* to its default value.
*
* @param param A handle returned by param_find or passed by param_foreach.
* @return Zero on success, nonzero on failure
*/
__EXPORT int param_reset_no_notification(param_t param);
/**
* Reset all parameters to their default values.
*

View File

@ -797,8 +797,7 @@ void param_set_used_internal(param_t param)
(1 << param_index % bits_per_allocation_unit);
}
int
param_reset(param_t param)
static int param_reset_internal(param_t param, bool notify = true)
{
param_wbuf_s *s = nullptr;
bool param_found = false;
@ -823,12 +822,16 @@ param_reset(param_t param)
param_unlock_writer();
if (s != nullptr) {
if (s != nullptr && notify) {
_param_notify_changes();
}
return (!param_found);
}
int param_reset(param_t param) { return param_reset_internal(param, true); }
int param_reset_no_notification(param_t param) { return param_reset_internal(param, false); }
static void
param_reset_all_internal(bool auto_save)
{