From 6aaebd63d4c5552ce29a4d5eb977c22037d81f66 Mon Sep 17 00:00:00 2001 From: "M. Eric Irrgang" Date: Thu, 1 Nov 2018 13:40:41 +0300 Subject: [PATCH] Fully define symbols in restraintpotential.h External client code (i.e. an MD plugin) is expected to link against libgmxapi, but not against libgromacs directly. This change allows client code to implement gmx::IRestraintPotential using only GROMACS installed headers, without relying on libgromacs to define methods in gmx::PotentialPointData or gmx::IRestraintPotential. Fixes #2725 Change-Id: I530c8b74d490645de25c722036be5387a4fc0a61 --- src/gromacs/restraint/restraintpotential.cpp | 17 ----------------- src/gromacs/restraint/restraintpotential.h | 25 +++++++++++++++++-------- 2 files changed, 17 insertions(+), 25 deletions(-) diff --git a/src/gromacs/restraint/restraintpotential.cpp b/src/gromacs/restraint/restraintpotential.cpp index c6b0f75d54..396d9fb268 100644 --- a/src/gromacs/restraint/restraintpotential.cpp +++ b/src/gromacs/restraint/restraintpotential.cpp @@ -40,21 +40,4 @@ namespace gmx { -PotentialPointData::PotentialPointData() : - PotentialPointData {Vector(0., 0., 0.), real(0.0)} -{} - -PotentialPointData::PotentialPointData(const Vector &f, const real e) : - force(f), - energy(e) -{} - -void IRestraintPotential::update(gmx::Vector gmx_unused v, - gmx::Vector gmx_unused v0, - double gmx_unused t) -{} - -void IRestraintPotential::bindSession(gmxapi::SessionResources* /* resources */) -{} - } // end namespace gmx diff --git a/src/gromacs/restraint/restraintpotential.h b/src/gromacs/restraint/restraintpotential.h index c5fe35de4d..466ca61ce6 100644 --- a/src/gromacs/restraint/restraintpotential.h +++ b/src/gromacs/restraint/restraintpotential.h @@ -41,8 +41,9 @@ * \inpublicapi * \brief Apply restraints during MD integration. * - * The classes here are available through the public API, but only gmx::RestraintPotential - * is necessary to implement a restraint plugin. + * The classes here are available through the public API. To write a restraint + * plugin, implement gmx::IRestraintPotential with a calculation method that + * produces a PotentialPointData for each site to which MD forces will be applied. */ /*! \file * \brief Declare generic interface for restraint implementations. @@ -105,7 +106,9 @@ class PotentialPointData /*! * \brief Initialize a new data structure. */ - PotentialPointData(); + PotentialPointData() : + PotentialPointData {Vector(0., 0., 0.), real(0.0)} + {} /*! * \brief Initialize from an argument list @@ -115,10 +118,11 @@ class PotentialPointData * * Note that if force was calculated as a scalar, it needs to be multiplied by a unit * vector in the direction to which it should be applied. - * If this calculation is in a subclass of gmx::RestraintPotential, - * you should be able to use the make_force_vec() helper function (not yet implemented). */ - PotentialPointData(const Vector &f, real e); + PotentialPointData(const Vector &f, const real e) : + force(f), + energy(e) + {} /*! * \brief Force vector calculated for first position. @@ -211,7 +215,12 @@ class IRestraintPotential */ virtual void update(gmx::Vector v, gmx::Vector v0, - double t); + double t) + { + (void)v; + (void)v0; + (void)t; + }; /*! @@ -231,7 +240,7 @@ class IRestraintPotential * \internal * \todo This should be more general than the RestraintPotential interface. */ - virtual void bindSession(gmxapi::SessionResources* resources); + virtual void bindSession(gmxapi::SessionResources* resources) { (void)resources; }; }; } // end namespace gmx -- 2.11.4.GIT