Preparation for environments in other libraries - #1036
Conversation
|
Do we expect other (Storm) libraries to extend the environment, or to wrap the environment? |
There was a problem hiding this comment.
🟢 Approval recommended
The template/extern-template refactor appears consistent and complete, with explicit instantiations centralized and corresponding extern template declarations added where needed.
Pull request overview
This PR prepares Storm’s core storm::Environment (and its sub-environments) for consumption in other libraries (e.g., storm-dft) by moving SubEnvironment’s template member function definitions into the header and centralizing explicit template instantiations in CoreEnvironments.cpp to avoid redundant instantiations across translation units.
Changes:
- Moved
SubEnvironmentmember function implementations intoSubEnvironment.h(out-of-class definitions) to enable cross-library template instantiations. - Added
extern template class SubEnvironment<...>;declarations in core environment headers and consolidated the corresponding explicit instantiations inCoreEnvironments.cpp. - Reordered/organized environment declarations and accessors (mostly alphabetical) for easier maintenance.
File summaries
| File | Description |
|---|---|
| src/storm/environment/SubEnvironment.h | Moves template method definitions into the header (out-of-class) to enable external template instantiation usage. |
| src/storm/environment/solver/SolverEnvironment.h | Adds extern template declarations for solver sub-environments and reorders declarations/accessors. |
| src/storm/environment/solver/SolverEnvironment.cpp | Reorders method definitions to match the reorganized header layout. |
| src/storm/environment/solver/MinMaxSolverEnvironment.h | Adds extern template for LP sub-environment and reorganizes lp() accessors/member placement. |
| src/storm/environment/modelchecker/ModelCheckerEnvironment.h | Adds extern template declarations for model-checker sub-environments. |
| src/storm/environment/Environment.h | Reorders sub-environment members/accessors and declares extern template specializations for core environment types. |
| src/storm/environment/Environment.cpp | Reorders environment accessor implementations to match header organization. |
| src/storm/environment/dd/DdEnvironment.h | Adds extern template declarations for DD manager sub-environments and reorders declarations/members. |
| src/storm/environment/CoreEnvironments.cpp | Centralizes explicit instantiations for SubEnvironment<...> specializations used across core and other libraries. |
Review details
- Files reviewed: 9/9 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Preparation to use
storm::Environmentin other libraries such asstorm-dft.It required to move the function implementation of
SubEnvironmentfrom the cpp to the header file. Otherwise the instantiations of the formSubEnvironment<XEnvironment>are not possible.To avoid re-instantiation for each include, we define all instantiations in
CoreEnvironments.cpp. The relevant header files also useextern template class SubEnvironment<XEnvironment>;.Note that the member functions are declared inside the
SubEnvironmentclass but defined out-of-line afterwards. This is needed becauseextern template classotherwise still implicitly inlines and instantiates member functions. I did not check the impact on the compilation though.Also sorted environments alphabetically for easier maintenance.