Repository navigation
[ISSUE 378] Move Recorder allocation to setup() and delegate via OperationManager. - #945
CodersRepo wants to merge 2 commits into
Conversation
Renames init() to setup() on Recorder implementations so memory allocation follows the same lifecycle pattern as Layout and Connections.
There was a problem hiding this comment.
Pull request overview
This PR updates the recorder lifecycle in the simulator startup path by renaming Recorder::init() to Recorder::setup() and invoking recorder setup via OperationManager from Model::setupSim(), aligning recorders with the existing “constructor registers operations / setup allocates resources” pattern.
Changes:
- Renamed recorder initialization hook from
init()tosetup()across theRecorderinterface and implementations (XML/HDF5). - Registered
Operations::setupforXmlRecorderandHdf5Recorder, and updatedModel::setupSim()to executeOperations::setupviaOperationManager. - Updated unit tests to call
setup()instead ofinit().
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| Testing/UnitTesting/XmlRecorderTests.cpp | Renames test and updates calls from init() to setup(). |
| Testing/UnitTesting/Hdf5RecorderTests.cpp | Updates calls from init() to setup() and related test comments. |
| Simulator/Recorders/XmlRecorder.h | Updates recorder lifecycle method declaration and documentation to setup(). |
| Simulator/Recorders/XmlRecorder.cpp | Registers Operations::setup and renames implementation from init() to setup(). |
| Simulator/Recorders/Recorder.h | Renames the core recorder lifecycle API from init() to setup(). |
| Simulator/Recorders/Hdf5Recorder.h | Updates lifecycle method declaration and documentation to setup(). |
| Simulator/Recorders/Hdf5Recorder.cpp | Registers Operations::setup and renames implementation from init() to setup(). |
| Simulator/Core/OperationManager.cpp | Adds string mapping for Operations::setup. |
| Simulator/Core/Model.cpp | Executes Operations::setup during model setup instead of calling recorder_->init() directly. |
stiber
left a comment
There was a problem hiding this comment.
Regardless of the decision, we need to make one and then, if choice 1 is decided, incorporate that change into Model. If 2 or 3 is decided, we can work out what must be done, document that with notes, and create a new issue for changing all setup methods.
| case Operations::setup: | ||
| return "setup"; |
There was a problem hiding this comment.
Am I wrong, or does no class register a "setup" operation with the OperationManager yet? I see three possibilities here:
- Stick with
Model::setupSim()and remove "setup" fromOperationManager. - Just stay with "setup" in
OperationManagerand transition to each class registering a setup method. - (I got interrupted and lost my train of thought.)
Note that, if different classes' setup methods need to be call in particular order, even if it is a partial order, then OperationManager is not the correct approach, as it doesn't guarantee that methods are called in any particular order.
|
It appears that this PR has been left incomplete. It only seems to rename things, but not actually register the |
Renames init() to setup() on Recorder implementations so memory allocation follows the same lifecycle pattern as Layout and Connections.
Closes #378
Description
enamed Recorder::init() to setup() so Recorders follow the same lifecycle as Layout and Connections: constructors only register operations, and file/output allocation happens in setup().
XmlRecorder and Hdf5Recorder now register Operations::setup with OperationManager, and Model::setupSim() calls that instead of recorder_->init() directly. Unit tests were updated to match.
Checklist (Mandatory for new features)
Testing (Mandatory for all changes)
test-medium-connected.xmlPassedtest-large-long.xmlPassed