Skip to content

refactor: Parameter context#2335

Merged
rprospero merged 5 commits intodevelop2from
parameter_context
Mar 23, 2026
Merged

refactor: Parameter context#2335
rprospero merged 5 commits intodevelop2from
parameter_context

Conversation

@rprospero
Copy link
Contributor

Allows types to define a context type. Declaring the parameter then requires that the context be passed in, if and only if there is a context.

I went with std::monostate for two reasons. First, it's the "official" type of empty data. As such, it includes such niceties as default and copy constructors. Secondly, as the official empty data type, it will take up zero bytes the moment that that is possible. It also gives the compiler the best opportunity to optimise out the context call in the parameter.

void deserialise(const SerialisedValue &node, CoreData &coreData) override;
};

class Configuration;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps move this up so its with the other fwd decs above?

throw(std::runtime_error(std::format("ParameterBase::get() failed to cast, name = {}.\n", name_)));
return cast->getData();
}
// Get the parameter's value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Get the parameter's value
// Get the parameter's context

protected:
// Reference to target data
DataClass &data_;
// Reference to target data
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Reference to target data
// Context for target data

@rprospero rprospero merged commit ead93f5 into develop2 Mar 23, 2026
9 checks passed
@rprospero rprospero deleted the parameter_context branch March 23, 2026 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants