std::unique_ptr<IMDModule> field_;
std::unique_ptr<ForceProviders> forceProviders_;
+
+ /*! \brief List of registered MDModules */
+ std::vector < std::shared_ptr < IMDModule>> modules_;
};
MDModules::MDModules() : impl_(new Impl)
"Force providers initialized multiple times");
impl_->forceProviders_ = compat::make_unique<ForceProviders>();
impl_->field_->initForceProviders(impl_->forceProviders_.get());
+ for (auto && module : impl_->modules_)
+ {
+ module->initForceProviders(impl_->forceProviders_.get());
+ }
return impl_->forceProviders_.get();
}
+void MDModules::add(std::shared_ptr<gmx::IMDModule> module)
+{
+ impl_->modules_.emplace_back(std::move(module));
+}
+
} // namespace gmx
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2016,2017,2018, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
class IKeyValueTreeTransformRules;
class IMDOutputProvider;
class KeyValueTreeObject;
+class IMDModule;
/*! \libinternal \brief
* Manages the collection of all modules used for mdrun.
*/
ForceProviders *initForceProviders();
+ /*!
+ * \brief Add a module to the container.
+ *
+ * An object may be added by a client to the bound MD Modules at run time.
+ * Both the client and the MDModules object may need to extend the life
+ * of the provided object. However, the MDModules container guarantees
+ * to extend the life of a provided object for as long as its consumers
+ * may attempt to use its the interfaces accessible through IMDModule
+ * methods.
+ *
+ * \param module implements some sort of modular functionality for MD.
+ *
+ * \note: There is not yet a way to add a IMDModule object between
+ * creation of the MDModules container and the execution of the various
+ * initialization protocols it supports.
+ *
+ * \internal
+ * Adding a module at an arbitrary point in the MDModules life breaks
+ * some assumptions in the protocol of the other member functions. If
+ * MDModules should not change after some point, we should move this
+ * to a builder class.
+ */
+ void add(std::shared_ptr<gmx::IMDModule> module);
+
private:
class Impl;