COPASI API  4.16.103
CModelParameter.h
Go to the documentation of this file.
1 // Copyright (C) 2011 - 2013 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 #ifndef COPASI_CModelParameter
7 #define COPASI_CModelParameter
8 
9 #include <set>
10 
13 
14 class CModelParameterSet;
16 class CCopasiObject;
17 class CExpression;
18 class CModel;
19 class CReaction;
20 
22 {
23  friend std::ostream &operator<<(std::ostream &os, const CModelParameter & o);
24 
25 public:
26  enum Type
27  {
35  Set,
37  };
38 
39  static const char * TypeNames[];
40 
42  {
48  };
49 
50  enum Framework
51  {
54  };
55 
56 private:
57  /**
58  * The default constructor is hidden.
59  */
61 
62 public:
63  /**
64  * Constructor
65  */
67  const CModelParameter::Type& type);
68  /**
69  * Copy constructor
70  */
72 
73 public:
74  /**
75  * Destructor
76  */
77  virtual ~CModelParameter();
78 
79  /**
80  * Set the parent, i.e., containing group, of the parameter.
81  * Note, it is the responsibility of the user to remove the parameter
82  * from the old part.
83  * @param CModelParameterGroup * pParent
84  */
85  void setParent(CModelParameterGroup * pParent);
86 
87  /**
88  * Retrieve the parent, i.e., containing group, of the parameter.
89  * @return CModelParameterGroup * pParent
90  */
92 
93  /**
94  * Retrieve the type of the parameter
95  * @return const Type & type
96  */
97  const Type & getType() const;
98 
99  /**
100  * Retrieve the unit of the parameter based on the current framework
101  * @param const Framework & framework (default: ParticleNumbers)
102  * @return const std::string unit
103  */
104  const std::string getUnit(const Framework & framework) const;
105 
106  /**
107  * Set the CN of the object represented by the parameter
108  * @param const CCopasiObjectName & cn
109  */
110  virtual void setCN(const CCopasiObjectName & cn);
111 
112  /**
113  * Retrieve the CN of the object represented by the parameter
114  * @return const CCopasiObjectName & cn
115  */
116  const CCopasiObjectName & getCN() const;
117 
118  /**
119  * Set the role the parameters object plays in the simulation.
120  * Note, REACTION is only valid for species.
121  * @param const CModelEntity::Status & simulationType
122  * @return bool success
123  */
124  bool setSimulationType(const CModelEntity::Status & simulationType);
125 
126  /**
127  * Retrieve the role the parameters object plays in the simulation
128  * @return const CModelEntity::Status & simulationType
129  */
130  const CModelEntity::Status & getSimulationType() const;
131 
132 #ifndef SWIG
133  /**
134  * Set the value of the parameter based on the current framework
135  * @param const double & value
136  * @param const Framework & framework
137  */
138  virtual void setValue(const double & value, const Framework& framework);
139 
140  /**
141  * Retrieve the value of the parameter based on the current framework
142  * @param const Framework & framework
143  * @return const double & value
144  */
145  const virtual double& getValue(const Framework & framework) const;
146 #endif
147 
148  /**
149  * Set the initial expression infix.
150  * @param const std::string & initialExpression
151  */
152  void setInitialExpression(const std::string & initialExpression);
153 
154  /**
155  * Retrieve the initial expression infix.
156  * @return std::string initialExpression
157  */
158  std::string getInitialExpression() const;
159 
160  /**
161  * Retrieve the actual initial expression.
162  * @return const CExpression* initialExpression
163  */
164  const CExpression* getInitialExpressionPtr() const;
165 
166  /**
167  * The the compare result.
168  * @param const CompareResult & compareResult
169  */
170  void setCompareResult(const CompareResult & compareResult);
171 
172  /**
173  * Retrieve the compare result.
174  * @return const CompareResult & compareResult
175  */
176  const CompareResult & getCompareResult() const;
177 
178  /**
179  * Retrieve the index of the parameter in the vector of children in the parent
180  * @return size_t index
181  */
182  size_t getIndex() const;
183 
184  /**
185  * Check whether the value is read only.
186  * @return bool isReadOnly
187  */
188  bool isReadOnly() const;
189 
190  /**
191  * Retrieve the pointer to the corresponding model object
192  * @return CCopasiObject * pObject
193  */
194  CCopasiObject * getObject() const;
195 
196  /**
197  * Retrieve a pointer to the parameter set the parameter belongs to
198  * @return CModelParameterSet * set
199  */
200  CModelParameterSet * getSet() const;
201 
202  /**
203  * Retrieve a pointer to the model the parameter is part of
204  * @return CModel * pModel
205  */
206  CModel * getModel() const;
207 
208  /**
209  * Check whether the initial expression is valid, i.e., it compiled
210  * @return bool isInitialExpressionValid
211  */
212  bool isInitialExpressionValid() const;
213 
214  /**
215  * Retrieve the name of the parameter.
216  * @return std::string name
217  */
218  virtual std::string getName() const;
219 
220  /**
221  * Compile the parameter
222  */
223  virtual void compile();
224 
225 #ifndef SWIG
226  /**
227  * Compare the parameter to an other
228  * @param const CModelParameter & other
229  * @param const CModelParameter::Framework & framework (default: ParticleNumbers)
230  * @param const bool & createMissing = false
231  */
232  const virtual CompareResult & diff(const CModelParameter& other,
233  const CModelParameter::Framework & framework = ParticleNumbers,
234  const bool & createMissing = false);
235 #endif
236 
237  /**
238  * Update the corresponding model object with the current parameter settings
239  */
240  virtual bool updateModel();
241 
242  /**
243  * Refresh the parameter from the corresponding model object
244  * @param const bool & modifyExistence
245  */
246  virtual bool refreshFromModel(const bool & modifyExistence);
247 
248  // These methods are only here so that we can use CNodeIterator to traverse the tree.
249  virtual size_t getNumChildren() const;
250  virtual const CModelParameter * getChild(const size_t & index) const;
251 
252 protected:
253  /**
254  * Determine the parameter name based on the CN of the corresponding object
255  * @param const CCopasiObjectName & cn
256  * @return std::string name
257  */
258  static std::string nameFromCN(const CCopasiObjectName & cn);
259 
260 protected:
261  /**
262  * The parent group
263  */
265 
266  /**
267  * The type
268  */
270 
271  /**
272  * The CN of the corresponding model object
273  */
275 
276  /**
277  * The role the parameter object is used in the simulation.
278  */
280 
281  /**
282  * The value of the parameter
283  */
284  double mValue;
285 
286  /**
287  * A pointer to the initial expression
288  */
290 
291  /**
292  * The result of the last compare
293  */
295 
296  /**
297  * A pointer to the corresponding model object. NULL if no object exists.
298  */
300 
301  /**
302  * The result of the last compile of the initial expression. Note an empty or
303  * missing expression is valid.
304  */
306 };
307 
309 
311 {
312 public:
313  /**
314  * Constructor
315  */
317 
318  /**
319  * Copy constructor
320  */
322 
323 public:
324  /**
325  * Destructor
326  */
327  virtual ~CModelParameterCompartment();
328 
329  /**
330  * Set the value of the parameter based on the current framework
331  * @param const double & value
332  * @param const Framework & framework
333  */
334  virtual void setValue(const C_FLOAT64 & value, const Framework & framework);
335 
336  /**
337  * Add a pointer to a species parameter to the compartment
338  */
339  void addSpecies(CModelParameterSpecies * pSpecies);
340 
341  /**
342  * Remove a pointer to a species parameter from the compartment
343  */
344  void removeSpecies(CModelParameterSpecies * pSpecies);
345 
346 private:
347  /**
348  * The set of species parameters which are contained in the compartment
349  */
350  std::set< CModelParameterSpecies * > mSpecies;
351 };
352 
354 {
356 
357 public:
358  /**
359  * Constructor
360  */
362 
363  /**
364  * Copy constructor
365  */
367 
368 public:
369  /**
370  * Destructor
371  */
372  virtual ~CModelParameterSpecies();
373 
374  /**
375  * Retrieve the name.
376  * @return std::string name
377  */
378  virtual std::string getName() const;
379 
380  /**
381  * Compile the parameter
382  */
383  virtual void compile();
384 
385  /**
386  * Set the CN of the object represented by the parameter
387  * @param const CCopasiObjectName & cn
388  */
389  virtual void setCN(const CCopasiObjectName & cn);
390 
391  /**
392  * Set the value of the parameter based on the current framework
393  * @param const double & value
394  * @param const Framework & framework
395  */
396  virtual void setValue(const C_FLOAT64 & value, const Framework & framework);
397 
398  /**
399  * Retrieve the value of the parameter based on the current framework
400  * @param const Framework & framework
401  * @return const double & value
402  */
403  virtual const C_FLOAT64 & getValue(const Framework & framework) const;
404 
405 private:
406  /**
407  * Retrieve the CN of the compartment the species is contained in.
408  * @return CCopasiObjectName compartmentCN
409  */
411 
412  /**
413  * The CN of the compartment the species is contained in.
414  */
416 
417  /**
418  * A pointer to the parameter representing the compartment the species is contained in.
419  */
421 
422  /**
423  * The concentration value of the species.
424  */
426 };
427 
429 {
430 public:
431  /**
432  * Constructor
433  */
435 
436  /**
437  * Copy constructor
438  */
440 
441  /**
442  * Destructor
443  */
445 
446  /**
447  * Compile the parameter
448  */
449  virtual void compile();
450 
451  /**
452  * Retrieve a pointer to the reaction the parameter belongs to.
453  * @return const CReaction * reaction
454  */
455  const CReaction * getReaction() const;
456 
457  /**
458  * Set the CN of the assigned global quantity. If the CN is empty
459  * the assignment is removed.
460  * @param const std::string & globalQuantityCN
461  */
462  void setGlobalQuantityCN(const std::string & globalQuantityCN);
463 
464  /**
465  * Retrieve the CN of the assigned global quantity
466  * @return const CRegisteredObjectName & globalQuantityCN
467  */
469 
470 private:
471  /**
472  * A pointer to the reaction the parameter belongs to.
473  */
475 
476  /**
477  * The CN of the assigned global quantity.
478  */
480 
481  /**
482  * A pointer to the parameter representing the assigned global quantity.
483  */
485 };
486 #endif // COPASI_CModelParameter
std::string getInitialExpression() const
static std::string nameFromCN(const CCopasiObjectName &cn)
Header file of class CModelEntity and CModelValue.
CModelParameterGroup * mpParent
CCopasiObject * mpObject
virtual std::string getName() const
const CompareResult & getCompareResult() const
virtual std::string getName() const
virtual const CModelParameter * getChild(const size_t &index) const
CModelParameterCompartment * mpCompartment
bool mIsInitialExpressionValid
void addSpecies(CModelParameterSpecies *pSpecies)
void removeSpecies(CModelParameterSpecies *pSpecies)
static const char * TypeNames[]
CModelParameterCompartment(CModelParameterGroup *pParent, const CModelParameter::Type &type=CModelParameter::Compartment)
void setCompareResult(const CompareResult &compareResult)
std::set< CModelParameterSpecies * > mSpecies
const std::string getUnit(const Framework &framework) const
const CCopasiObjectName & getCN() const
CCopasiObject * getObject() const
CExpression * mpInitialExpression
void setInitialExpression(const std::string &initialExpression)
void setParent(CModelParameterGroup *pParent)
virtual const CompareResult & diff(const CModelParameter &other, const CModelParameter::Framework &framework=ParticleNumbers, const bool &createMissing=false)
virtual void compile()
virtual void setValue(const C_FLOAT64 &value, const Framework &framework)
bool isReadOnly() const
virtual void setValue(const double &value, const Framework &framework)
virtual bool updateModel()
CModelParameterSet * getSet() const
virtual size_t getNumChildren() const
CRegisteredObjectName mGlobalQuantityCN
CModelEntity::Status mSimulationType
virtual const double & getValue(const Framework &framework) const
void setGlobalQuantityCN(const std::string &globalQuantityCN)
CModelParameterReactionParameter(CModelParameterGroup *pParent, const CModelParameter::Type &type=CModelParameter::ReactionParameter)
CCopasiObjectName getCompartmentCN() const
virtual const C_FLOAT64 & getValue(const Framework &framework) const
virtual bool refreshFromModel(const bool &modifyExistence)
friend std::ostream & operator<<(std::ostream &os, const CModelParameter &o)
const CModelEntity::Status & getSimulationType() const
CModelParameterSpecies(CModelParameterGroup *pParent, const CModelParameter::Type &type=CModelParameter::Species)
CompareResult mCompareResult
CRegisteredObjectName mCompartmentCN
const CExpression * getInitialExpressionPtr() const
#define C_FLOAT64
Definition: copasi.h:92
virtual void setCN(const CCopasiObjectName &cn)
virtual ~CModelParameter()
bool isInitialExpressionValid() const
Definition: CModel.h:50
const Type & getType() const
size_t getIndex() const
const CReaction * getReaction() const
bool setSimulationType(const CModelEntity::Status &simulationType)
virtual void setValue(const C_FLOAT64 &value, const Framework &framework)
const CRegisteredObjectName & getGlobalQuantityCN() const
CRegisteredObjectName mCN
virtual void setCN(const CCopasiObjectName &cn)
CModelParameterGroup * getParent() const
CModel * getModel() const