COPASI API  4.16.103
CEvent.h
Go to the documentation of this file.
1 // Copyright (C) 2010 - 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 // Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual
7 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
8 // and The University of Manchester.
9 // All rights reserved.
10 
11 // Copyright (C) 2007 by Pedro Mendes, Virginia Tech Intellectual
12 // Properties, Inc. and EML Research, gGmbH.
13 // All rights reserved.
14 
15 /*!
16  \file CEvent.h
17  \brief Header file of class CEvent.
18  */
19 
20 #ifndef COPASI_CEvent
21 #define COPASI_CEvent
22 
23 #include <string>
24 #include <set>
25 
28 
29 class CExpression;
30 class CModel;
31 
33 {
34 public:
35  // Operations
36  /**
37  * Default constructor
38  * @param const std::string & targetKey (default: "")
39  * @param "const CCopasiContainer * pParent (default: NULL)
40  */
41  CEventAssignment(const std::string & targetKey = "",
42  const CCopasiContainer * pParent = NULL);
43 
44  /**
45  * Copy constructor
46  * @param "const CEventAssignment &" src
47  * @param "const CCopasiContainer * pParent (default: NULL)
48  */
50  const CCopasiContainer * pParent = NULL);
51 
52  /**
53  * Destructor
54  */
56 
57  /**
58  * Set the object parent
59  * @param const CCopasiContainer * pParent
60  * @return bool success
61  */
62  virtual bool setObjectParent(const CCopasiContainer * pParent);
63 
64  /**
65  * Compile the event assignment.
66  * @param std::vector< CCopasiContainer * > listOfContainer
67  * @return bool success
68  */
69  bool compile(std::vector< CCopasiContainer * > listOfContainer);
70 
71  /**
72  * Retrieve the key
73  * @return const std::string & key
74  */
75  const std::string & getKey() const;
76 
77  /**
78  * Set the key of the target
79  * @param const std::string & targetKey
80  * @return bool success;
81  */
82  bool setTargetKey(const std::string & targetKey);
83 
84  /**
85  * Retrieve the target key
86  * @return const std::string & targetKey
87  */
88  const std::string & getTargetKey() const;
89 
90  /**
91  * Retrieve a pointer to the target object.
92  * @return const CCopasiObject * targetObject
93  */
94  const CCopasiObject * getTargetObject() const;
95 
96  /**
97  * Set the expression from an infix string. The return value indicates if
98  * parsing the expression was successful.
99  * @param const std::string & expression
100  * @return bool success
101  */
102  bool setExpression(const std::string & expression);
103 
104  /**
105  * Set the expression from an expression pointer. CEventAssignment takes ownership.
106  * @param CExpression* pExpression
107  * @return bool success
108  */
109  bool setExpressionPtr(CExpression * pExpression);
110 
111  /**
112  * Retrieve the expression as a string.
113  * @return std::string expression
114  */
115  std::string getExpression() const;
116 
117  /**
118  * Retrieve the pointer to the expression.
119  * @return CExpression * pExpression
120  */
121  const CExpression * getExpressionPtr() const;
122 
123  /**
124  * Retrieve the pointer to the expression.
125  * @return CExpression * pExpression
126  */
128 
129  // Attributes
130 private:
131  /**
132  * The key
133  */
134  std::string mKey;
135 
136  /**
137  * The parent model
138  */
140 
141  /**
142  * The target object
143  */
145 
146  /**
147  * The expression to calculate the new value
148  */
150 };
151 
152 class CEvent : public CCopasiContainer, public CAnnotation
153 {
154 public:
155  enum Type
156  {
160  };
161 
162  /**
163  * Default constructor
164  * @param const std::string & name (default: "NoName")
165  * @param const CCopasiContainer * pParent (default: NULL)
166  */
167  CEvent(const std::string & name = "NoName",
168  const CCopasiContainer * pParent = NULL);
169 
170  /**
171  * Copy constructor
172  * @param "const CEvent &" src
173  * @param const CCopasiContainer * pParent (default: NULL)
174  */
175  CEvent(const CEvent & src,
176  const CCopasiContainer * pParent = NULL);
177 
178 private:
179  CEvent & operator= (const CEvent &);
180 
181 public:
182  /**
183  * Destructor
184  */
185  ~CEvent();
186 
187  /**
188  * Delete
189  */
190  void cleanup();
191 
192  /**
193  * Set the object parent
194  * @param const CCopasiContainer * pParent
195  * @return bool success
196  */
197  virtual bool setObjectParent(const CCopasiContainer * pParent);
198 
199  /**
200  * Retrieve display name. Special treatment for reaction to
201  * provide a shorter display
202  */
203  virtual std::string getObjectDisplayName(bool regular = true, bool richtext = false) const;
204 
205  /**
206  * Retrieves the key of the event
207  * @return std::string key
208  */
209  virtual const std::string & getKey() const;
210 
211  /**
212  * Check whether an object must be deleted because its prerequisites can
213  * no longer be fulfilled due to the given deleted objects
214  * @param const DataObjectSet & deletedObjects
215  * @return bool mustBeDeleted
216  */
217  virtual bool mustBeDeleted(const DataObjectSet & deletedObjects) const;
218 
219  /**
220  * Compile the event.
221  * @param std::vector< CCopasiContainer * > listOfContainer
222  * @return bool success
223  */
224  bool compile(std::vector< CCopasiContainer * > listOfContainer);
225 
226  /**
227  * Sets the SBMLId.
228  * @param const std::string & id
229  */
230  void setSBMLId(const std::string & id);
231 
232  /**
233  * Returns a reference to the SBML Id.
234  */
235  const std::string& getSBMLId() const;
236 
237  /**
238  * Set whether the calculation or the assignment shall be delayed.
239  * @param const bool & delayCalculation
240  */
241  void setDelayAssignment(const bool & delayCalculation);
242 
243  /**
244  * Retrieve whether to delay the calculation of the assignment.
245  * @return const bool & delayCalculation
246  */
247  const bool & getDelayAssignment() const;
248 
249  /**
250  * Set whether the trigger may fire at the initial time.
251  * @param const bool & fireAtInitialTime
252  */
253  void setFireAtInitialTime(const bool & fireAtInitialTime);
254 
255  /**
256  * Retrieve whether the trigger may fire at the initial time.
257  * @return const bool & fireAtInitialTime
258  */
259  const bool & getFireAtInitialTime() const;
260 
261  /**
262  * Set whether the trigger must remain true between firing and executions.
263  * @param const bool & persistentTrigger
264  */
265  void setPersistentTrigger(const bool & persistentTrigger);
266 
267  /**
268  * Retrieve whether the trigger must remain true between firing and executions.
269  * @return const bool & persistentTrigger
270  */
271  const bool & getPersistentTrigger() const;
272 
273  /**
274  * Set the expression of trigger from a string. The return value indicates if
275  * parsing the expression was successful.
276  * @param const std::string & expression
277  * @return bool success
278  */
279  bool setTriggerExpression(const std::string & expression);
280 
281  /**
282  * Set the expression of trigger from an expression.
283  * @param CExpression* pExpression
284  * @return bool success
285  */
286  bool setTriggerExpressionPtr(CExpression * pExpression);
287 
288  /**
289  * Retrieve the expression of trigger as a string.
290  * @return std::string expression
291  */
292  std::string getTriggerExpression() const;
293 
294  /**
295  * Retrieve the pointer to the expression of trigger.
296  * @return CExpression* pExpression
297  */
298  const CExpression * getTriggerExpressionPtr() const;
299 
300  /**
301  * Retrieve the pointer to the expression of trigger.
302  * @return CExpression* pExpression
303  */
305 
306  /**
307  * Set the expression of delay from a string. The return value indicates if
308  * parsing the expression was successful.
309  * @param const std::string & expression
310  * @return bool success
311  */
312  bool setDelayExpression(const std::string & expression);
313 
314  /**
315  * Set the expression of delay from an expression.
316  * @param CExpression* pExpression
317  * @return bool success
318  */
319  bool setDelayExpressionPtr(CExpression* pExpression);
320 
321  /**
322  * Retrieve the expression of the delay as a string.
323  * @return std::string expression
324  */
325  std::string getDelayExpression() const;
326 
327  /**
328  * Retrieve the pointer to the expression of the delay.
329  * @return CExpression* pExpression
330  */
332 
333  /**
334  * Retrieve the pointer to the expression of the delay.
335  * @return CExpression* pExpression
336  */
337  const CExpression* getDelayExpressionPtr() const;
338 
339  /**
340  * Set the expression of priority from a string. The return value indicates if
341  * parsing the expression was successful.
342  * @param const std::string & expression
343  * @return bool success
344  */
345  bool setPriorityExpression(const std::string & expression);
346 
347  /**
348  * Set the expression of priority from an expression.
349  * @param CExpression* pExpression
350  * @return bool success
351  */
352  bool setPriorityExpressionPtr(CExpression* pExpression);
353 
354  /**
355  * Retrieve the expression of the priority as a string.
356  * @return std::string expression
357  */
358  std::string getPriorityExpression() const;
359 
360  /**
361  * Retrieve the pointer to the expression of the priority.
362  * @return CExpression* pExpression
363  */
365 
366  /**
367  * Retrieve the pointer to the expression of the priority.
368  * @return CExpression* pExpression
369  */
370  const CExpression* getPriorityExpressionPtr() const;
371 
372  /**
373  * Retrieve the assignments
374  * @return const CCopasiVectorN< CEventAssignment > & assignments
375  */
377 
378  /**
379  * Retrieve the assignments
380  * @return CCopasiVectorN< CEventAssignment > & assignments
381  */
383 
384  /**
385  * Delete assignment with the given key. Please note this is not the target key.
386  * @param const std::string & key
387  */
388  void deleteAssignment(const std::string & key);
389 
390  /**
391  * Retrieve the type of the event
392  * @return const Type & type
393  */
394  const Type & getType() const;
395 
396  /**
397  * Set the type of the event
398  * @param const Type & type
399  */
400  void setType(const Type & type);
401 
402  /**
403  * insert operator
404  */
405  friend std::ostream & operator<<(std::ostream &os, const CEvent & d);
406 
407  // Attributes
408 private:
409  /**
410  * The parent model
411  */
413 
414  /**
415  * A vector assignments expressions which specify the changes made by the event.
416  */
418 
419  /**
420  * A Boolean flag indicating whether the calculation or the assignment should be delayed
421  * in the case that a delay is present.
422  */
424 
425  /**
426  * A Boolean flag indicating whether the trigger may fire at the initial time
427  * if the trigger expression is true;
428  */
430 
431  /**
432  * A Boolean flag indicating whether the trigger expression must remain true between
433  * firing and executing the event.
434  */
436 
437  /**
438  * Pointer to the boolean Trigger Expression of the event
439  */
441 
442  /**
443  * Pointer to the Delay Expression of the event
444  */
446 
447  /**
448  * Pointer to the Priority Expression of the event
449  */
451 
452  /**
453  * The type of the event
454  */
456 
457  /**
458  * The id of the corresponding event in an SBML file.
459  * This value is either set upon importing an SBML file,
460  * or when the object is first exported to an SBML file.
461  */
462  std::string mSBMLId;
463 
464 private:
465 
466  void initObjects();
467 };
468 
469 #endif // COPASI_CEvent
Definition: CEvent.h:152
CExpression * mpTriggerExpression
Definition: CEvent.h:440
virtual std::string getObjectDisplayName(bool regular=true, bool richtext=false) const
Definition: CEvent.cpp:464
const CCopasiVectorN< CEventAssignment > & getAssignments() const
Definition: CEvent.cpp:678
const bool & getDelayAssignment() const
Definition: CEvent.cpp:419
void setPersistentTrigger(const bool &persistentTrigger)
Definition: CEvent.cpp:434
CExpression * mpDelayExpression
Definition: CEvent.h:445
const std::string & getTargetKey() const
Definition: CEvent.cpp:162
bool setDelayExpressionPtr(CExpression *pExpression)
Definition: CEvent.cpp:558
std::string mSBMLId
Definition: CEvent.h:462
const CExpression * getExpressionPtr() const
Definition: CEvent.cpp:226
bool mPersistentTrigger
Definition: CEvent.h:435
bool setExpression(const std::string &expression)
Definition: CEvent.cpp:167
Type
Definition: CEvent.h:155
void deleteAssignment(const std::string &key)
Definition: CEvent.cpp:688
CModel * mpModel
Definition: CEvent.h:139
std::string getTriggerExpression() const
Definition: CEvent.cpp:524
bool setPriorityExpressionPtr(CExpression *pExpression)
Definition: CEvent.cpp:625
bool setTargetKey(const std::string &targetKey)
Definition: CEvent.cpp:151
Type mType
Definition: CEvent.h:455
CExpression * mpExpression
Definition: CEvent.h:149
CModel * mpModel
Definition: CEvent.h:412
CEvent(const std::string &name="NoName", const CCopasiContainer *pParent=NULL)
Definition: CEvent.cpp:238
CExpression * getDelayExpressionPtr()
Definition: CEvent.cpp:606
~CEvent()
Definition: CEvent.cpp:278
const Type & getType() const
Definition: CEvent.cpp:699
const bool & getPersistentTrigger() const
Definition: CEvent.cpp:439
bool mFireAtInitialTime
Definition: CEvent.h:429
CCopasiVectorN< CEventAssignment > mAssignments
Definition: CEvent.h:417
virtual bool setObjectParent(const CCopasiContainer *pParent)
Definition: CEvent.cpp:444
const CCopasiObject * mpTarget
Definition: CEvent.h:144
bool setTriggerExpression(const std::string &expression)
Definition: CEvent.cpp:474
bool setExpressionPtr(CExpression *pExpression)
Definition: CEvent.cpp:181
const std::string & getKey() const
Definition: CEvent.cpp:141
void setDelayAssignment(const bool &delayCalculation)
Definition: CEvent.cpp:408
virtual bool mustBeDeleted(const DataObjectSet &deletedObjects) const
Definition: CEvent.cpp:293
CEvent & operator=(const CEvent &)
bool setPriorityExpression(const std::string &expression)
Definition: CEvent.cpp:611
std::string getDelayExpression() const
Definition: CEvent.cpp:591
void initObjects()
Definition: CEvent.cpp:380
void cleanup()
const CExpression * getTriggerExpressionPtr() const
Definition: CEvent.cpp:534
friend std::ostream & operator<<(std::ostream &os, const CEvent &d)
Definition: CEvent.cpp:388
bool compile(std::vector< CCopasiContainer * > listOfContainer)
Definition: CEvent.cpp:94
CExpression * mpPriorityExpression
Definition: CEvent.h:450
bool setDelayExpression(const std::string &expression)
Definition: CEvent.cpp:544
void setFireAtInitialTime(const bool &fireAtInitialTime)
Definition: CEvent.cpp:424
std::string mKey
Definition: CEvent.h:134
bool mDelayAssignment
Definition: CEvent.h:423
void setType(const Type &type)
Definition: CEvent.cpp:704
CEventAssignment(const std::string &targetKey="", const CCopasiContainer *pParent=NULL)
Definition: CEvent.cpp:35
const std::string & getSBMLId() const
Definition: CEvent.cpp:403
const bool & getFireAtInitialTime() const
Definition: CEvent.cpp:429
Definition: CModel.h:50
virtual bool setObjectParent(const CCopasiContainer *pParent)
Definition: CEvent.cpp:75
CExpression * getPriorityExpressionPtr()
Definition: CEvent.cpp:668
const CCopasiObject * getTargetObject() const
Definition: CEvent.cpp:146
std::set< const CCopasiObject * > DataObjectSet
std::string getPriorityExpression() const
Definition: CEvent.cpp:658
void setSBMLId(const std::string &id)
Definition: CEvent.cpp:398
virtual const std::string & getKey() const
Definition: CEvent.cpp:287
bool compile(std::vector< CCopasiContainer * > listOfContainer)
Definition: CEvent.cpp:346
std::string getExpression() const
Definition: CEvent.cpp:216
bool setTriggerExpressionPtr(CExpression *pExpression)
Definition: CEvent.cpp:491