WIP: debugging, added const version of parameter getter

This commit is contained in:
Matthias Koefferlein
2026-08-17 18:54:52 +02:00
parent 07e057e182
commit e22aeea494
3 changed files with 39 additions and 1 deletions
+7
View File
@@ -168,6 +168,13 @@ Class<db::ParameterStates> decl_PCellParameterStates ("db", "PCellParameterState
"\n"
"This will return a \\PCellParameterState object that can be used to manipulate the "
"parameter state."
) +
gsi::method ("parameter", static_cast<const db::ParameterState & (db::ParameterStates::*) (const std::string &name) const> (&db::ParameterStates::parameter), gsi::arg ("name"),
"@brief Gets the parameter by name (const version)\n"
"\n"
"This will return a \\PCellParameterState object which cannot be manipulated, but read.\n"
"\n"
"The const flavor has been introduced in version 0.30.11."
),
"@brief Provides access to the parameter states inside a 'callback' implementation of a PCell\n"
"\n"
+4 -1
View File
@@ -392,6 +392,9 @@ PCellParametersPageBase::State
PCellParametersPageBase::get_state ()
{
State s;
if (! mp_page_widget) {
return s;
}
s.valid = true;
s.v_scroll_position = mp_parameters_area->verticalScrollBar ()->value ();
@@ -409,7 +412,7 @@ PCellParametersPageBase::get_state ()
void
PCellParametersPageBase::set_state (const State &s)
{
if (s.valid) {
if (s.valid && mp_page_widget) {
mp_parameters_area->verticalScrollBar ()->setValue (s.v_scroll_position);
mp_parameters_area->horizontalScrollBar ()->setValue (s.h_scroll_position);
+28
View File
@@ -1082,6 +1082,34 @@ class DBPCellParameterStates_TestClass < TestBase
end
def test_2
pss = RBA::PCellParameterStates::new
assert_equal(pss.has_parameter?("a"), false)
pa = pss.parameter("a")
assert_equal(pss.has_parameter?("a"), true)
# manipulating the value is reflected in the states collection
pa.value = 17
assert_equal(pss.parameter("a").value, 17)
pss_const = pss._to_const_object
assert_equal(pss_const._is_const_object?, true)
assert_equal(pss_const.has_parameter?("a"), true)
pa = pss_const.parameter("a")
assert_equal(pa.value, 17)
begin
# can't manipulate the const value
pa.value = 18
assert_equal(true, false)
rescue => ex
# goes here
end
end
end
load("test_epilogue.rb")