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