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
...@@ -100,7 +100,7 @@ public: ...@@ -100,7 +100,7 @@ public:
randomNumberSeed = seed; randomNumberSeed = seed;
} }
protected: protected:
ForceImpl* createImpl(); ForceImpl* createImpl() const;
private: private:
double defaultTemp, defaultFreq; double defaultTemp, defaultFreq;
int randomNumberSeed; int randomNumberSeed;
......
...@@ -149,7 +149,7 @@ public: ...@@ -149,7 +149,7 @@ public:
*/ */
void setTorsionParameters(int index, int map, int a1, int a2, int a3, int a4, int b1, int b2, int b3, int b4); void setTorsionParameters(int index, int map, int a1, int a2, int a3, int a4, int b1, int b2, int b3, int b4);
protected: protected:
ForceImpl* createImpl(); ForceImpl* createImpl() const;
private: private:
class MapInfo; class MapInfo;
class CMAPTorsionInfo; class CMAPTorsionInfo;
......
...@@ -62,7 +62,7 @@ public: ...@@ -62,7 +62,7 @@ public:
frequency = freq; frequency = freq;
} }
protected: protected:
ForceImpl* createImpl(); ForceImpl* createImpl() const;
private: private:
int frequency; int frequency;
}; };
......
...@@ -72,7 +72,7 @@ public: ...@@ -72,7 +72,7 @@ public:
* @param system the System which will be simulated * @param system the System which will be simulated
* @param integrator the Integrator which will be used to simulate the System * @param integrator the Integrator which will be used to simulate the System
*/ */
Context(System& system, Integrator& integrator); Context(const System& system, Integrator& integrator);
/** /**
* Construct a new Context in which to run a simulation, explicitly specifying what Platform should be used * Construct a new Context in which to run a simulation, explicitly specifying what Platform should be used
* to perform calculations. * to perform calculations.
...@@ -81,7 +81,7 @@ public: ...@@ -81,7 +81,7 @@ public:
* @param integrator the Integrator which will be used to simulate the System * @param integrator the Integrator which will be used to simulate the System
* @param platform the Platform to use for calculations * @param platform the Platform to use for calculations
*/ */
Context(System& system, Integrator& integrator, Platform& platform); Context(const System& system, Integrator& integrator, Platform& platform);
/** /**
* Construct a new Context in which to run a simulation, explicitly specifying what Platform should be used * Construct a new Context in which to run a simulation, explicitly specifying what Platform should be used
* to perform calculations and the values of platform-specific properties. * to perform calculations and the values of platform-specific properties.
...@@ -91,16 +91,12 @@ public: ...@@ -91,16 +91,12 @@ public:
* @param platform the Platform to use for calculations * @param platform the Platform to use for calculations
* @param properties a set of values for platform-specific properties. Keys are the property names. * @param properties a set of values for platform-specific properties. Keys are the property names.
*/ */
Context(System& system, Integrator& integrator, Platform& platform, const std::map<std::string, std::string>& properties); Context(const System& system, Integrator& integrator, Platform& platform, const std::map<std::string, std::string>& properties);
~Context(); ~Context();
/** /**
* Get System being simulated in this context. * Get System being simulated in this context.
*/ */
const System& getSystem() const; const System& getSystem() const;
/**
* Get System being simulated in this context.
*/
System& getSystem();
/** /**
* Get Integrator being used to by this context. * Get Integrator being used to by this context.
*/ */
......
...@@ -203,7 +203,7 @@ public: ...@@ -203,7 +203,7 @@ public:
*/ */
void updateParametersInContext(Context& context); void updateParametersInContext(Context& context);
protected: protected:
ForceImpl* createImpl(); ForceImpl* createImpl() const;
private: private:
class AngleInfo; class AngleInfo;
class AngleParameterInfo; class AngleParameterInfo;
......
...@@ -200,7 +200,7 @@ public: ...@@ -200,7 +200,7 @@ public:
*/ */
void updateParametersInContext(Context& context); void updateParametersInContext(Context& context);
protected: protected:
ForceImpl* createImpl(); ForceImpl* createImpl() const;
private: private:
class BondInfo; class BondInfo;
class BondParameterInfo; class BondParameterInfo;
......
...@@ -270,7 +270,7 @@ public: ...@@ -270,7 +270,7 @@ public:
*/ */
void updateParametersInContext(Context& context); void updateParametersInContext(Context& context);
protected: protected:
ForceImpl* createImpl(); ForceImpl* createImpl() const;
private: private:
class BondInfo; class BondInfo;
class BondParameterInfo; class BondParameterInfo;
......
...@@ -200,7 +200,7 @@ public: ...@@ -200,7 +200,7 @@ public:
*/ */
void updateParametersInContext(Context& context); void updateParametersInContext(Context& context);
protected: protected:
ForceImpl* createImpl(); ForceImpl* createImpl() const;
private: private:
class ParticleInfo; class ParticleInfo;
class ParticleParameterInfo; class ParticleParameterInfo;
......
...@@ -496,7 +496,7 @@ public: ...@@ -496,7 +496,7 @@ public:
*/ */
void updateParametersInContext(Context& context); void updateParametersInContext(Context& context);
protected: protected:
ForceImpl* createImpl(); ForceImpl* createImpl() const;
private: private:
class ParticleInfo; class ParticleInfo;
class PerParticleParameterInfo; class PerParticleParameterInfo;
......
...@@ -416,7 +416,7 @@ public: ...@@ -416,7 +416,7 @@ public:
*/ */
void updateParametersInContext(Context& context); void updateParametersInContext(Context& context);
protected: protected:
ForceImpl* createImpl(); ForceImpl* createImpl() const;
private: private:
class GroupInfo; class GroupInfo;
class PerPairParameterInfo; class PerPairParameterInfo;
......
...@@ -327,7 +327,7 @@ public: ...@@ -327,7 +327,7 @@ public:
*/ */
void updateParametersInContext(Context& context); void updateParametersInContext(Context& context);
protected: protected:
ForceImpl* createImpl(); ForceImpl* createImpl() const;
private: private:
class ParticleInfo; class ParticleInfo;
class PerParticleParameterInfo; class PerParticleParameterInfo;
......
...@@ -206,7 +206,7 @@ public: ...@@ -206,7 +206,7 @@ public:
*/ */
void updateParametersInContext(Context& context); void updateParametersInContext(Context& context);
protected: protected:
ForceImpl* createImpl(); ForceImpl* createImpl() const;
private: private:
class TorsionInfo; class TorsionInfo;
class TorsionParameterInfo; class TorsionParameterInfo;
......
...@@ -85,7 +85,7 @@ protected: ...@@ -85,7 +85,7 @@ protected:
* It should create a new ForceImpl object which can be used by the context for calculating forces. * It should create a new ForceImpl object which can be used by the context for calculating forces.
* The ForceImpl will be deleted automatically when the Context is deleted. * The ForceImpl will be deleted automatically when the Context is deleted.
*/ */
virtual ForceImpl* createImpl() = 0; virtual ForceImpl* createImpl() const = 0;
/** /**
* Get the ForceImpl corresponding to this Force in a Context. * Get the ForceImpl corresponding to this Force in a Context.
*/ */
......
...@@ -167,7 +167,7 @@ public: ...@@ -167,7 +167,7 @@ public:
*/ */
void updateParametersInContext(Context& context); void updateParametersInContext(Context& context);
protected: protected:
ForceImpl* createImpl(); ForceImpl* createImpl() const;
private: private:
class ParticleInfo; class ParticleInfo;
NonbondedMethod nonbondedMethod; NonbondedMethod nonbondedMethod;
......
...@@ -228,7 +228,7 @@ public: ...@@ -228,7 +228,7 @@ public:
*/ */
void setQuinticUpperBornRadiusLimit(double quinticUpperBornRadiusLimit); void setQuinticUpperBornRadiusLimit(double quinticUpperBornRadiusLimit);
protected: protected:
ForceImpl* createImpl(); ForceImpl* createImpl() const;
private: private:
class ParticleInfo; class ParticleInfo;
NonbondedMethod nonbondedMethod; NonbondedMethod nonbondedMethod;
......
...@@ -103,7 +103,7 @@ public: ...@@ -103,7 +103,7 @@ public:
*/ */
void updateParametersInContext(Context& context); void updateParametersInContext(Context& context);
protected: protected:
ForceImpl* createImpl(); ForceImpl* createImpl() const;
private: private:
class AngleInfo; class AngleInfo;
std::vector<AngleInfo> angles; std::vector<AngleInfo> angles;
......
...@@ -100,7 +100,7 @@ public: ...@@ -100,7 +100,7 @@ public:
*/ */
void updateParametersInContext(Context& context); void updateParametersInContext(Context& context);
protected: protected:
ForceImpl* createImpl(); ForceImpl* createImpl() const;
private: private:
class BondInfo; class BondInfo;
std::vector<BondInfo> bonds; std::vector<BondInfo> bonds;
......
...@@ -119,7 +119,7 @@ public: ...@@ -119,7 +119,7 @@ public:
randomNumberSeed = seed; randomNumberSeed = seed;
} }
protected: protected:
ForceImpl* createImpl(); ForceImpl* createImpl() const;
private: private:
double defaultPressure, temperature; double defaultPressure, temperature;
int frequency, randomNumberSeed; int frequency, randomNumberSeed;
......
...@@ -296,7 +296,7 @@ public: ...@@ -296,7 +296,7 @@ public:
*/ */
void updateParametersInContext(Context& context); void updateParametersInContext(Context& context);
protected: protected:
ForceImpl* createImpl(); ForceImpl* createImpl() const;
private: private:
class ParticleInfo; class ParticleInfo;
class ExceptionInfo; class ExceptionInfo;
......
...@@ -109,7 +109,7 @@ public: ...@@ -109,7 +109,7 @@ public:
*/ */
void updateParametersInContext(Context& context); void updateParametersInContext(Context& context);
protected: protected:
ForceImpl* createImpl(); ForceImpl* createImpl() const;
private: private:
class PeriodicTorsionInfo; class PeriodicTorsionInfo;
std::vector<PeriodicTorsionInfo> periodicTorsions; std::vector<PeriodicTorsionInfo> periodicTorsions;
......
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