Commit 0307a0db authored by Yutong Zhao's avatar Yutong Zhao
Browse files

Context constructor now uses const System&, guaranteeing that System won't be modified.

parent 19757775
......@@ -47,10 +47,10 @@ namespace OpenMM {
class AmoebaAngleForceImpl : public ForceImpl {
public:
AmoebaAngleForceImpl(AmoebaAngleForce& owner);
AmoebaAngleForceImpl(const AmoebaAngleForce& owner);
~AmoebaAngleForceImpl();
void initialize(ContextImpl& context);
AmoebaAngleForce& getOwner() {
const AmoebaAngleForce& getOwner() const {
return owner;
}
void updateContextState(ContextImpl& context) {
......@@ -63,7 +63,7 @@ public:
std::vector<std::string> getKernelNames();
void updateParametersInContext(ContextImpl& context);
private:
AmoebaAngleForce& owner;
const AmoebaAngleForce& owner;
Kernel kernel;
};
......
......@@ -48,10 +48,10 @@ namespace OpenMM {
class AmoebaBondForceImpl : public ForceImpl {
public:
AmoebaBondForceImpl(AmoebaBondForce& owner);
AmoebaBondForceImpl(const AmoebaBondForce& owner);
~AmoebaBondForceImpl();
void initialize(ContextImpl& context);
AmoebaBondForce& getOwner() {
const AmoebaBondForce& getOwner() const {
return owner;
}
void updateContextState(ContextImpl& context) {
......@@ -66,7 +66,7 @@ public:
std::vector< std::pair<int, int> > getBondedParticles() const;
void updateParametersInContext(ContextImpl& context);
private:
AmoebaBondForce& owner;
const AmoebaBondForce& owner;
Kernel kernel;
};
......
......@@ -45,9 +45,9 @@ namespace OpenMM {
class AmoebaGeneralizedKirkwoodForceImpl : public ForceImpl {
public:
AmoebaGeneralizedKirkwoodForceImpl(AmoebaGeneralizedKirkwoodForce& owner);
AmoebaGeneralizedKirkwoodForceImpl(const AmoebaGeneralizedKirkwoodForce& owner);
void initialize(ContextImpl& context);
AmoebaGeneralizedKirkwoodForce& getOwner() {
const AmoebaGeneralizedKirkwoodForce& getOwner() const {
return owner;
}
void updateContextState(ContextImpl& context) {
......@@ -63,7 +63,7 @@ public:
}
void updateParametersInContext(ContextImpl& context);
private:
AmoebaGeneralizedKirkwoodForce& owner;
const AmoebaGeneralizedKirkwoodForce& owner;
Kernel kernel;
};
......
......@@ -47,10 +47,10 @@ namespace OpenMM {
class AmoebaInPlaneAngleForceImpl : public ForceImpl {
public:
AmoebaInPlaneAngleForceImpl(AmoebaInPlaneAngleForce& owner);
AmoebaInPlaneAngleForceImpl(const AmoebaInPlaneAngleForce& owner);
~AmoebaInPlaneAngleForceImpl();
void initialize(ContextImpl& context);
AmoebaInPlaneAngleForce& getOwner() {
const AmoebaInPlaneAngleForce& getOwner() const {
return owner;
}
void updateContextState(ContextImpl& context) {
......@@ -63,7 +63,7 @@ public:
std::vector<std::string> getKernelNames();
void updateParametersInContext(ContextImpl& context);
private:
AmoebaInPlaneAngleForce& owner;
const AmoebaInPlaneAngleForce& owner;
Kernel kernel;
};
......
......@@ -47,10 +47,10 @@ namespace OpenMM {
class OPENMM_EXPORT_AMOEBA AmoebaMultipoleForceImpl : public ForceImpl {
public:
AmoebaMultipoleForceImpl(AmoebaMultipoleForce& owner);
AmoebaMultipoleForceImpl(const AmoebaMultipoleForce& owner);
~AmoebaMultipoleForceImpl();
void initialize(ContextImpl& context);
AmoebaMultipoleForce& getOwner() {
const AmoebaMultipoleForce& getOwner() const {
return owner;
}
void updateContextState(ContextImpl& context) {
......@@ -90,7 +90,7 @@ public:
private:
AmoebaMultipoleForce& owner;
const AmoebaMultipoleForce& owner;
Kernel kernel;
static int CovalentDegrees[AmoebaMultipoleForce::CovalentEnd];
......
......@@ -47,10 +47,10 @@ namespace OpenMM {
class AmoebaOutOfPlaneBendForceImpl : public ForceImpl {
public:
AmoebaOutOfPlaneBendForceImpl(AmoebaOutOfPlaneBendForce& owner);
AmoebaOutOfPlaneBendForceImpl(const AmoebaOutOfPlaneBendForce& owner);
~AmoebaOutOfPlaneBendForceImpl();
void initialize(ContextImpl& context);
AmoebaOutOfPlaneBendForce& getOwner() {
const AmoebaOutOfPlaneBendForce& getOwner() const {
return owner;
}
void updateContextState(ContextImpl& context) {
......@@ -63,7 +63,7 @@ public:
std::vector<std::string> getKernelNames();
void updateParametersInContext(ContextImpl& context);
private:
AmoebaOutOfPlaneBendForce& owner;
const AmoebaOutOfPlaneBendForce& owner;
Kernel kernel;
};
......
......@@ -47,10 +47,10 @@ namespace OpenMM {
class AmoebaPiTorsionForceImpl : public ForceImpl {
public:
AmoebaPiTorsionForceImpl(AmoebaPiTorsionForce& owner);
AmoebaPiTorsionForceImpl(const AmoebaPiTorsionForce& owner);
~AmoebaPiTorsionForceImpl();
void initialize(ContextImpl& context);
AmoebaPiTorsionForce& getOwner() {
const AmoebaPiTorsionForce& getOwner() const {
return owner;
}
void updateContextState(ContextImpl& context) {
......@@ -63,7 +63,7 @@ public:
std::vector<std::string> getKernelNames();
void updateParametersInContext(ContextImpl& context);
private:
AmoebaPiTorsionForce& owner;
const AmoebaPiTorsionForce& owner;
Kernel kernel;
};
......
......@@ -47,10 +47,10 @@ namespace OpenMM {
class AmoebaStretchBendForceImpl : public ForceImpl {
public:
AmoebaStretchBendForceImpl(AmoebaStretchBendForce& owner);
AmoebaStretchBendForceImpl(const AmoebaStretchBendForce& owner);
~AmoebaStretchBendForceImpl();
void initialize(ContextImpl& context);
AmoebaStretchBendForce& getOwner() {
const AmoebaStretchBendForce& getOwner() const {
return owner;
}
void updateContextState(ContextImpl& context) {
......@@ -63,7 +63,7 @@ public:
std::vector<std::string> getKernelNames();
void updateParametersInContext(ContextImpl& context);
private:
AmoebaStretchBendForce& owner;
const AmoebaStretchBendForce& owner;
Kernel kernel;
};
......
......@@ -46,10 +46,10 @@ namespace OpenMM {
class AmoebaTorsionTorsionForceImpl : public ForceImpl {
public:
AmoebaTorsionTorsionForceImpl(AmoebaTorsionTorsionForce& owner);
AmoebaTorsionTorsionForceImpl(const AmoebaTorsionTorsionForce& owner);
~AmoebaTorsionTorsionForceImpl();
void initialize(ContextImpl& context);
AmoebaTorsionTorsionForce& getOwner() {
const AmoebaTorsionTorsionForce& getOwner() const {
return owner;
}
void updateContextState(ContextImpl& context) {
......@@ -64,7 +64,7 @@ public:
OPENMM_EXPORT_AMOEBA static void reorderGrid( const TorsionTorsionGrid& grid, TorsionTorsionGrid& reorderedGrid );
private:
AmoebaTorsionTorsionForce& owner;
const AmoebaTorsionTorsionForce& owner;
Kernel kernel;
};
......
......@@ -49,10 +49,10 @@ class System;
class OPENMM_EXPORT_AMOEBA AmoebaVdwForceImpl : public ForceImpl {
public:
AmoebaVdwForceImpl(AmoebaVdwForce& owner);
AmoebaVdwForceImpl(const AmoebaVdwForce& owner);
~AmoebaVdwForceImpl();
void initialize(ContextImpl& context);
AmoebaVdwForce& getOwner() {
const AmoebaVdwForce& getOwner() const {
return owner;
}
void updateContextState(ContextImpl& context) {
......@@ -70,7 +70,7 @@ public:
static double calcDispersionCorrection(const System& system, const AmoebaVdwForce& force);
void updateParametersInContext(ContextImpl& context);
private:
AmoebaVdwForce& owner;
const AmoebaVdwForce& owner;
Kernel kernel;
};
......
......@@ -47,10 +47,10 @@ namespace OpenMM {
class OPENMM_EXPORT_AMOEBA AmoebaWcaDispersionForceImpl : public ForceImpl {
public:
AmoebaWcaDispersionForceImpl(AmoebaWcaDispersionForce& owner);
AmoebaWcaDispersionForceImpl(const AmoebaWcaDispersionForce& owner);
~AmoebaWcaDispersionForceImpl();
void initialize(ContextImpl& context);
AmoebaWcaDispersionForce& getOwner() {
const AmoebaWcaDispersionForce& getOwner() const {
return owner;
}
void updateContextState(ContextImpl& context) {
......@@ -82,7 +82,7 @@ public:
void updateParametersInContext(ContextImpl& context);
private:
AmoebaWcaDispersionForce& owner;
const AmoebaWcaDispersionForce& owner;
Kernel kernel;
};
......
......@@ -95,7 +95,7 @@ void AmoebaAngleForce::setAmoebaGlobalAngleSextic(double sexticK ) {
_globalSexticK = sexticK;
}
ForceImpl* AmoebaAngleForce::createImpl() {
ForceImpl* AmoebaAngleForce::createImpl() const {
return new AmoebaAngleForceImpl(*this);
}
......
......@@ -39,7 +39,7 @@ using std::pair;
using std::vector;
using std::set;
AmoebaAngleForceImpl::AmoebaAngleForceImpl(AmoebaAngleForce& owner) : owner(owner) {
AmoebaAngleForceImpl::AmoebaAngleForceImpl(const AmoebaAngleForce& owner) : owner(owner) {
}
AmoebaAngleForceImpl::~AmoebaAngleForceImpl() {
......
......@@ -75,7 +75,7 @@ double AmoebaBondForce::getAmoebaGlobalBondQuartic( void ) const {
return _globalQuarticK;
}
ForceImpl* AmoebaBondForce::createImpl() {
ForceImpl* AmoebaBondForce::createImpl() const {
return new AmoebaBondForceImpl(*this);
}
......
......@@ -40,7 +40,7 @@ using std::pair;
using std::vector;
using std::set;
AmoebaBondForceImpl::AmoebaBondForceImpl(AmoebaBondForce& owner) : owner(owner) {
AmoebaBondForceImpl::AmoebaBondForceImpl(const AmoebaBondForce& owner) : owner(owner) {
}
AmoebaBondForceImpl::~AmoebaBondForceImpl() {
......
......@@ -90,7 +90,7 @@ void AmoebaGeneralizedKirkwoodForce::setSurfaceAreaFactor(double inputSurfaceAre
surfaceAreaFactor = inputSurfaceAreaFactor;
}
ForceImpl* AmoebaGeneralizedKirkwoodForce::createImpl() {
ForceImpl* AmoebaGeneralizedKirkwoodForce::createImpl() const {
return new AmoebaGeneralizedKirkwoodForceImpl(*this);
}
......
......@@ -36,12 +36,12 @@
using namespace OpenMM;
using std::vector;
AmoebaGeneralizedKirkwoodForceImpl::AmoebaGeneralizedKirkwoodForceImpl(AmoebaGeneralizedKirkwoodForce& owner) : owner(owner) {
AmoebaGeneralizedKirkwoodForceImpl::AmoebaGeneralizedKirkwoodForceImpl(const AmoebaGeneralizedKirkwoodForce& owner) : owner(owner) {
}
void AmoebaGeneralizedKirkwoodForceImpl::initialize(ContextImpl& context) {
System& system = context.getSystem();
const System& system = context.getSystem();
if (owner.getNumParticles() != system.getNumParticles())
throw OpenMMException("AmoebaGeneralizedKirkwoodForce must have exactly as many particles as the System it belongs to.");
......
......@@ -97,7 +97,7 @@ double AmoebaInPlaneAngleForce::getAmoebaGlobalInPlaneAngleSextic( void ) const
return _globalSexticK;
}
ForceImpl* AmoebaInPlaneAngleForce::createImpl() {
ForceImpl* AmoebaInPlaneAngleForce::createImpl() const {
return new AmoebaInPlaneAngleForceImpl(*this);
}
......
......@@ -39,7 +39,7 @@ using std::pair;
using std::vector;
using std::set;
AmoebaInPlaneAngleForceImpl::AmoebaInPlaneAngleForceImpl(AmoebaInPlaneAngleForce& owner) : owner(owner) {
AmoebaInPlaneAngleForceImpl::AmoebaInPlaneAngleForceImpl(const AmoebaInPlaneAngleForce& owner) : owner(owner) {
}
AmoebaInPlaneAngleForceImpl::~AmoebaInPlaneAngleForceImpl() {
......
......@@ -234,7 +234,7 @@ void AmoebaMultipoleForce::getSystemMultipoleMoments(Context& context, std::vect
dynamic_cast<AmoebaMultipoleForceImpl&>(getImplInContext(context)).getSystemMultipoleMoments(getContextImpl(context), outputMultipoleMonents);
}
ForceImpl* AmoebaMultipoleForce::createImpl() {
ForceImpl* AmoebaMultipoleForce::createImpl() const {
return new AmoebaMultipoleForceImpl(*this);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment