You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Accumulators registered via system.auto_update_accumulators are currently stored in a global variable in the C++ core. To help with multi-system simulations, the auto-update accumulators container needs to become a member of the core System class.
Procedure:
get familiar with the design patterns used in the core System class: opaque pointers, composite pattern (chapter System class design in the Doxygen documentation)
create an Accumulators::AutoUpdateAccumulators class
rewrite the functions in src/core/accumulators.hpp as methods of class Accumulators::AutoUpdateAccumulators
rename the auto_update() function to an operator()() method
rename all auto_update_*() functions to *() methods
rename all auto_update_*() function calls to auto_update.*() function calls
add an extern Accumulators auto_update; in src/core/accumulators.hpp
add an Accumulators auto_update = {}; in src/core/accumulators.cpp
make the auto_update_accumulators static global a member of the Accumulators class
make all necessary adjustments until the C++ compiler is happy
the testsuite should pass
rewrite src/script_interface/accumulators/AutoUpdateAccumulators.hpp as a leaf container class
the class should publicly inherit from ObjectList<AccumulatorBase, AutoParameters<ObjectList<AccumulatorBase, System::Leaf>, System::Leaf>>
the class should manage a std::shared_ptr<::Accumulators::AutoUpdateAccumulators> m_handle; that gets initialized inside on_bind_system() via a m_params handle that was initialized inside do_construct() (use src/script_interface/electrostatics/Container.hpp as a guide)
the testsuite should pass
move the auto_update global to a member of the core System class
add a std::shared_ptr<Accumulators::AutoUpdateAccumulators> auto_update; to the core System class, right after bond_breakage
forward-declare Accumulators::AutoUpdateAccumulators at the top of src/core/system/System.hpp
remove the auto_update global variable and adapt all function calls using the -> dereference operator
in the script interface, the current system's auto_update member is copied into m_handle inside on_bind_system()
The text was updated successfully, but these errors were encountered:
The opaque pointer technique is detailed in More C++ Idioms book, chapter Pointer to Implementation. Since we are only interested in breaking a circular dependency, we use the pointer to incomplete type method. The void pointer method is far less common, and for this specific scenario it has no advantages.
Accumulators registered via
system.auto_update_accumulators
are currently stored in a global variable in the C++ core. To help with multi-system simulations, the auto-update accumulators container needs to become a member of the coreSystem
class.Procedure:
System
class: opaque pointers, composite pattern (chapter System class design in the Doxygen documentation)Accumulators::AutoUpdateAccumulators
classsrc/core/accumulators.hpp
as methods of classAccumulators::AutoUpdateAccumulators
auto_update()
function to anoperator()()
methodauto_update_*()
functions to*()
methodsauto_update_*()
function calls toauto_update.*()
function callsextern Accumulators auto_update;
insrc/core/accumulators.hpp
Accumulators auto_update = {};
insrc/core/accumulators.cpp
auto_update_accumulators
static global a member of theAccumulators
classsrc/script_interface/accumulators/AutoUpdateAccumulators.hpp
as a leaf container classObjectList<AccumulatorBase, AutoParameters<ObjectList<AccumulatorBase, System::Leaf>, System::Leaf>>
std::shared_ptr<::Accumulators::AutoUpdateAccumulators> m_handle;
that gets initialized insideon_bind_system()
via am_params
handle that was initialized insidedo_construct()
(usesrc/script_interface/electrostatics/Container.hpp
as a guide)auto_update
global to a member of the coreSystem
classstd::shared_ptr<Accumulators::AutoUpdateAccumulators> auto_update;
to the coreSystem
class, right afterbond_breakage
Accumulators::AutoUpdateAccumulators
at the top ofsrc/core/system/System.hpp
auto_update
global variable and adapt all function calls using the->
dereference operatorauto_update
member is copied intom_handle
insideon_bind_system()
The text was updated successfully, but these errors were encountered: