COPASI API  4.16.103
Public Member Functions | Private Attributes | List of all members
CEventAssignment Class Reference

#include <CEvent.h>

Inheritance diagram for CEventAssignment:
Inheritance graph
[legend]
Collaboration diagram for CEventAssignment:
Collaboration graph
[legend]

Public Member Functions

 CEventAssignment (const std::string &targetKey="", const CCopasiContainer *pParent=NULL)
 
 CEventAssignment (const CEventAssignment &src, const CCopasiContainer *pParent=NULL)
 
bool compile (std::vector< CCopasiContainer * > listOfContainer)
 
std::string getExpression () const
 
const CExpressiongetExpressionPtr () const
 
CExpressiongetExpressionPtr ()
 
const std::string & getKey () const
 
const std::string & getTargetKey () const
 
const CCopasiObjectgetTargetObject () const
 
bool setExpression (const std::string &expression)
 
bool setExpressionPtr (CExpression *pExpression)
 
virtual bool setObjectParent (const CCopasiContainer *pParent)
 
bool setTargetKey (const std::string &targetKey)
 
 ~CEventAssignment ()
 
- Public Member Functions inherited from CCopasiContainer
virtual bool add (CCopasiObject *pObject, const bool &adopt=true)
 
 CCopasiContainer (const std::string &name, const CCopasiContainer *pParent=NULL, const std::string &type="CN", const unsigned C_INT32 &flag=CCopasiObject::Container)
 
 CCopasiContainer (const CCopasiContainer &src, const CCopasiContainer *pParent=NULL)
 
virtual std::string getChildObjectUnits (const CCopasiObject *pObject) const
 
virtual const CObjectInterfacegetObject (const CCopasiObjectName &cn) const
 
virtual const objectMapgetObjects () const
 
virtual std::string getUnits () const
 
virtual const CCopasiObjectgetValueObject () const
 
virtual bool remove (CCopasiObject *pObject)
 
virtual ~CCopasiContainer ()
 
- Public Member Functions inherited from CCopasiObject
void addDirectDependency (const CCopasiObject *pObject)
 
 CCopasiObject (const CCopasiObject &src, const CCopasiContainer *pParent=NULL)
 
void clearDirectDependencies ()
 
void clearRefresh ()
 
bool dependsOn (DataObjectSet candidates, const DataObjectSet &context=DataObjectSet()) const
 
void getAllDependencies (DataObjectSet &dependencies, const DataObjectSet &context) const
 
virtual CCopasiObjectName getCN () const
 
virtual const DataObjectSetgetDirectDependencies (const DataObjectSet &context=DataObjectSet()) const
 
CCopasiContainergetObjectAncestor (const std::string &type) const
 
CCopasiDataModelgetObjectDataModel ()
 
const CCopasiDataModelgetObjectDataModel () const
 
virtual std::string getObjectDisplayName (bool regular=true, bool richtext=false) const
 
const std::string & getObjectName () const
 
CCopasiContainergetObjectParent () const
 
const std::string & getObjectType () const
 
virtual const
CObjectInterface::ObjectSet
getPrerequisites () const
 
virtual RefreshgetRefresh () const
 
UpdateMethodgetUpdateMethod () const
 
virtual voidgetValuePointer () const
 
bool hasCircularDependencies (DataObjectSet &candidates, DataObjectSet &verified, const DataObjectSet &context) const
 
bool hasUpdateMethod () const
 
bool isArray () const
 
bool isContainer () const
 
bool isDataModel () const
 
bool isMatrix () const
 
bool isNameVector () const
 
bool isNonUniqueName () const
 
virtual bool isPrerequisiteForContext (const CObjectInterface *pObject, const CMath::SimulationContextFlag &context, const CObjectInterface::ObjectSet &changedObjects) const
 
bool isReference () const
 
bool isRoot () const
 
bool isSeparator () const
 
bool isStaticString () const
 
bool isValueBool () const
 
bool isValueDbl () const
 
bool isValueInt () const
 
bool isValueInt64 () const
 
bool isValueString () const
 
bool isVector () const
 
virtual bool mustBeDeleted (const DataObjectSet &deletedObjects) const
 
virtual void print (std::ostream *ostream) const
 
void removeDirectDependency (const CCopasiObject *pObject)
 
void setDirectDependencies (const DataObjectSet &directDependencies)
 
bool setObjectName (const std::string &name)
 
void setObjectValue (const C_FLOAT64 &value)
 
void setObjectValue (const C_INT32 &value)
 
void setObjectValue (const bool &value)
 
template<class CType >
void setRefresh (CType *pType, void(CType::*method)(void))
 
template<class CType >
void setUpdateMethod (CType *pType, void(CType::*method)(const C_FLOAT64 &))
 
template<class CType >
void setUpdateMethod (CType *pType, void(CType::*method)(const C_INT32 &))
 
template<class CType >
void setUpdateMethod (CType *pType, void(CType::*method)(const bool &))
 
virtual ~CCopasiObject ()
 
- Public Member Functions inherited from CObjectInterface
 CObjectInterface ()
 
virtual ~CObjectInterface ()
 

Private Attributes

std::string mKey
 
CExpressionmpExpression
 
CModelmpModel
 
const CCopasiObjectmpTarget
 

Additional Inherited Members

- Public Types inherited from CCopasiContainer
typedef std::multimap
< std::string, CCopasiObject * > 
objectMap
 
- Public Types inherited from CCopasiObject
typedef std::set< const
CCopasiObject * > 
DataObjectSet
 
typedef std::vector< Refresh * > DataUpdateSequence
 
- Public Types inherited from CObjectInterface
typedef std::set< const
CObjectInterface * > 
ObjectSet
 
typedef std::vector
< CObjectInterface * > 
UpdateSequence
 
- Static Public Member Functions inherited from CCopasiObject
static std::vector< Refresh * > buildUpdateSequence (const DataObjectSet &objects, const DataObjectSet &uptoDateObjects, const DataObjectSet &context=DataObjectSet())
 
static void setRenameHandler (CRenameHandler *rh)
 
- Static Public Attributes inherited from CCopasiContainer
static const std::vector
< CCopasiContainer * > 
EmptyList
 
- Protected Types inherited from CCopasiObject
enum  Flag {
  Container = 0x1, Vector = 0x2, Matrix = 0x4, NameVector = 0x8,
  Reference = 0x10, ValueBool = 0x20, ValueInt = 0x40, ValueInt64 = 0x80,
  ValueDbl = 0x100, NonUniqueName = 0x200, StaticString = 0x400, ValueString = 0x800,
  Separator = 0x1000, ModelEntity = 0x2000, Array = 0x4000, DataModel = 0x8000,
  Root = 0x10000, Gui = 0x20000
}
 
- Protected Member Functions inherited from CCopasiContainer
template<class CType >
CCopasiObjectaddMatrixReference (const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)
 
template<class CType >
CCopasiObjectaddObjectReference (const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)
 
template<class CType >
CCopasiObjectaddVectorReference (const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)
 
void initObjects ()
 
- Protected Member Functions inherited from CCopasiObject
 CCopasiObject ()
 
 CCopasiObject (const std::string &name, const CCopasiContainer *pParent=NULL, const std::string &type="CN", const unsigned C_INT32 &flag=0)
 
- Protected Attributes inherited from CCopasiContainer
objectMap mObjects
 
- Static Protected Attributes inherited from CCopasiObject
static CRenameHandlersmpRenameHandler = NULL
 

Detailed Description

Definition at line 32 of file CEvent.h.

Constructor & Destructor Documentation

CEventAssignment::CEventAssignment ( const std::string &  targetKey = "",
const CCopasiContainer pParent = NULL 
)

Default constructor

Parameters
conststd::string & targetKey (default: "")
"constCCopasiContainer * pParent (default: NULL)

Definition at line 35 of file CEvent.cpp.

References mpModel, and CModel::setCompileFlag().

36  :
37  CCopasiContainer(targetKey, pParent, "EventAssignment"),
38  mKey(CCopasiRootContainer::getKeyFactory()->add("EventAssignment", this)),
39  mpModel(static_cast<CModel *>(getObjectAncestor("Model"))),
40  mpTarget(NULL),
41  mpExpression(NULL)
42 {
43  if (mpModel != NULL)
44  {
45  mpModel->setCompileFlag(true);
46  }
47 }
CCopasiContainer * getObjectAncestor(const std::string &type) const
CModel * mpModel
Definition: CEvent.h:139
CExpression * mpExpression
Definition: CEvent.h:149
const CCopasiObject * mpTarget
Definition: CEvent.h:144
void setCompileFlag(bool flag=true)
Definition: CModel.cpp:607
static CKeyFactory * getKeyFactory()
std::string mKey
Definition: CEvent.h:134
virtual bool add(CCopasiObject *pObject, const bool &adopt=true)
CEventAssignment::CEventAssignment ( const CEventAssignment src,
const CCopasiContainer pParent = NULL 
)

Copy constructor

Parameters
const CEventAssignment &src
"constCCopasiContainer * pParent (default: NULL)

Definition at line 49 of file CEvent.cpp.

References getExpression(), mpModel, CModel::setCompileFlag(), and setExpression().

50  :
51  CCopasiContainer(src, pParent),
52  mKey(CCopasiRootContainer::getKeyFactory()->add("EventAssignment", this)),
53  mpModel(static_cast<CModel *>(getObjectAncestor("Model"))),
54  mpTarget(src.mpTarget),
55  mpExpression(NULL)
56 {
57  if (mpModel != NULL)
58  {
59  mpModel->setCompileFlag(true);
60  }
61 
63 }
CCopasiContainer * getObjectAncestor(const std::string &type) const
bool setExpression(const std::string &expression)
Definition: CEvent.cpp:167
CModel * mpModel
Definition: CEvent.h:139
CExpression * mpExpression
Definition: CEvent.h:149
const CCopasiObject * mpTarget
Definition: CEvent.h:144
void setCompileFlag(bool flag=true)
Definition: CModel.cpp:607
static CKeyFactory * getKeyFactory()
std::string mKey
Definition: CEvent.h:134
virtual bool add(CCopasiObject *pObject, const bool &adopt=true)
std::string getExpression() const
Definition: CEvent.cpp:216
CEventAssignment::~CEventAssignment ( )

Destructor

Definition at line 65 of file CEvent.cpp.

References mpExpression, mpModel, pdelete, and CModel::setCompileFlag().

66 {
68 
69  if (mpModel != NULL)
70  {
71  mpModel->setCompileFlag(true);
72  }
73 }
#define pdelete(p)
Definition: copasi.h:215
CModel * mpModel
Definition: CEvent.h:139
CExpression * mpExpression
Definition: CEvent.h:149
void setCompileFlag(bool flag=true)
Definition: CModel.cpp:607

Member Function Documentation

bool CEventAssignment::compile ( std::vector< CCopasiContainer * >  listOfContainer)

Compile the event assignment.

Parameters
std::vector<CCopasiContainer * > listOfContainer
Returns
bool success

Definition at line 94 of file CEvent.cpp.

References CModelEntity::ASSIGNMENT, CCopasiObject::clearDirectDependencies(), CExpression::compile(), CKeyFactory::get(), CCopasiObject::getDirectDependencies(), CCopasiRootContainer::getKeyFactory(), CCopasiObject::getObjectName(), CModelEntity::getStatus(), CModelEntity::getValueObject(), mpExpression, mpTarget, CCopasiObject::setDirectDependencies(), and CCopasiMessage::WARNING.

95 {
97 
98  bool success = true;
99 
100  mpTarget = NULL;
101 
102  CModelEntity * pEntity =
104 
105  // The entity type must not be an ASSIGNMENT
106  if (pEntity != NULL &&
107  pEntity->getStatus() != CModelEntity::ASSIGNMENT)
108  {
109  // We need use the virtual method getValueObject to retrieve the
110  // target value from the model entity
111  mpTarget = pEntity->getValueObject();
112  }
113  else if (pEntity != NULL &&
114  pEntity->getStatus() == CModelEntity::ASSIGNMENT)
115  {
116  CCopasiMessage(CCopasiMessage::WARNING, "Invalid EventAssignment for '%s': an Assignment Rule already exists", pEntity->getObjectName().c_str());
117  }
118  else if (pEntity == NULL)
119  {
120  CCopasiMessage(CCopasiMessage::WARNING, "Invalid EventAssignment for '%s': object does not exist.", getObjectName().c_str());
121  }
122 
123  if (mpTarget == NULL)
124  {
125  success = false;
126  }
127 
128  if (mpExpression != NULL)
129  {
130  success &= mpExpression->compile(listOfContainer);
132  }
133  else
134  {
135  success = false;
136  }
137 
138  return success;
139 }
void clearDirectDependencies()
const std::string & getObjectName() const
CCopasiObject * get(const std::string &key)
void setDirectDependencies(const DataObjectSet &directDependencies)
virtual bool compile(std::vector< CCopasiContainer * > listOfContainer=CCopasiContainer::EmptyList)
Definition: CExpression.cpp:97
CExpression * mpExpression
Definition: CEvent.h:149
const CCopasiObject * mpTarget
Definition: CEvent.h:144
virtual const CCopasiObject * getValueObject() const
virtual const DataObjectSet & getDirectDependencies(const DataObjectSet &context=DataObjectSet()) const
static CKeyFactory * getKeyFactory()
const CModelEntity::Status & getStatus() const
std::string CEventAssignment::getExpression ( ) const

Retrieve the expression as a string.

Returns
std::string expression

Definition at line 216 of file CEvent.cpp.

References CEvaluationTree::getInfix(), mpExpression, and CExpression::updateInfix().

Referenced by CEventAssignment(), CMathEventN::CAssignment::compile(), CMathEvent::CAssignment::compile(), and CModelExpansion::duplicateEvent().

217 {
218  if (mpExpression == NULL)
219  return "";
220 
222 
223  return mpExpression->getInfix();
224 }
bool updateInfix()
CExpression * mpExpression
Definition: CEvent.h:149
const std::string & getInfix() const
const CExpression * CEventAssignment::getExpressionPtr ( ) const

Retrieve the pointer to the expression.

Returns
CExpression * pExpression

Definition at line 226 of file CEvent.cpp.

References mpExpression.

Referenced by CModelAdd::addEvents(), CModelAdd::copyEventAssignmentExpression(), CModelExpansion::duplicateEvent(), CModelMerging::mergeMetabolites(), SBMLImporter::removeUnusedFunctions(), and CModelExpansion::replaceInEvent().

227 {
228  return mpExpression;
229 }
CExpression * mpExpression
Definition: CEvent.h:149
CExpression * CEventAssignment::getExpressionPtr ( )

Retrieve the pointer to the expression.

Returns
CExpression * pExpression

Definition at line 231 of file CEvent.cpp.

References mpExpression.

232 {
233  return mpExpression;
234 }
CExpression * mpExpression
Definition: CEvent.h:149
const std::string & CEventAssignment::getKey ( ) const
virtual

Retrieve the key

Returns
const std::string & key

Reimplemented from CCopasiObject.

Definition at line 141 of file CEvent.cpp.

References mKey.

142 {
143  return mKey;
144 }
std::string mKey
Definition: CEvent.h:134
const std::string & CEventAssignment::getTargetKey ( ) const

Retrieve the target key

Returns
const std::string & targetKey

Definition at line 162 of file CEvent.cpp.

References CCopasiObject::getObjectName().

Referenced by CModelAdd::addEvents(), CModelExpansion::duplicateEvent(), CModelMerging::mergeMetabolites(), CModelExpansion::replaceInEvent(), and setTargetKey().

163 {
164  return getObjectName();
165 }
const std::string & getObjectName() const
const CCopasiObject * CEventAssignment::getTargetObject ( ) const

Retrieve a pointer to the target object.

Returns
const CCopasiObject * targetObject

Definition at line 146 of file CEvent.cpp.

References mpTarget.

Referenced by CMathEventN::CAssignment::compile(), and CMathEvent::CAssignment::compile().

147 {
148  return mpTarget;
149 }
const CCopasiObject * mpTarget
Definition: CEvent.h:144
bool CEventAssignment::setExpression ( const std::string &  expression)

Set the expression from an infix string. The return value indicates if parsing the expression was successful.

Parameters
conststd::string & expression
Returns
bool success

Definition at line 167 of file CEvent.cpp.

References CEvaluationTree::getInfix(), mpExpression, mpModel, CModel::setCompileFlag(), and CExpression::setInfix().

Referenced by CEventAssignment(), CModelAdd::copyEventAssignmentExpression(), CModelExpansion::duplicateEvent(), and CCopasiXMLParser::AssignmentElement::end().

168 {
169  if (mpExpression == NULL)
170  mpExpression = new CExpression("Expression", this);
171 
172  if (mpExpression->getInfix() != expression &&
173  mpModel != NULL)
174  {
175  mpModel->setCompileFlag(true);
176  }
177 
178  return mpExpression->setInfix(expression);
179 }
virtual bool setInfix(const std::string &infix)
Definition: CExpression.cpp:63
CModel * mpModel
Definition: CEvent.h:139
CExpression * mpExpression
Definition: CEvent.h:149
void setCompileFlag(bool flag=true)
Definition: CModel.cpp:607
const std::string & getInfix() const
bool CEventAssignment::setExpressionPtr ( CExpression pExpression)

Set the expression from an expression pointer. CEventAssignment takes ownership.

Parameters
CExpression*pExpression
Returns
bool success

Definition at line 181 of file CEvent.cpp.

References CCopasiContainer::add(), CExpression::compile(), mpExpression, mpModel, pdelete, CModel::setCompileFlag(), CCopasiObject::setObjectName(), and CCopasiObject::setObjectParent().

Referenced by SBMLImporter::importEvent().

182 {
183  if (pExpression == mpExpression) return true;
184 
185  if (pExpression == mpExpression) return true;
186 
187  if (pExpression == NULL) return false;
188 
189  if (mpModel != NULL)
190  {
191  mpModel->setCompileFlag(true);
192  }
193 
194  CExpression * pOld = mpExpression;
195  mpExpression = pExpression;
196 
197  mpExpression->setObjectName("Expression");
198  add(mpExpression, true);
199  std::vector< CCopasiContainer * > listOfContainer;
200  listOfContainer.push_back(mpModel);
201 
202  if (mpExpression->compile(listOfContainer))
203  {
204  pdelete(pOld);
205  return true;
206  }
207 
208  // If compile fails we do not take ownership
209  // and we remove the object from the container
210  remove(mpExpression);
212  mpExpression = pOld;
213  return false;
214 }
virtual bool setObjectParent(const CCopasiContainer *pParent)
#define pdelete(p)
Definition: copasi.h:215
CModel * mpModel
Definition: CEvent.h:139
virtual bool compile(std::vector< CCopasiContainer * > listOfContainer=CCopasiContainer::EmptyList)
Definition: CExpression.cpp:97
CExpression * mpExpression
Definition: CEvent.h:149
void setCompileFlag(bool flag=true)
Definition: CModel.cpp:607
virtual bool add(CCopasiObject *pObject, const bool &adopt=true)
bool setObjectName(const std::string &name)
bool CEventAssignment::setObjectParent ( const CCopasiContainer pParent)
virtual

Set the object parent

Parameters
constCCopasiContainer * pParent
Returns
bool success

Reimplemented from CCopasiObject.

Definition at line 75 of file CEvent.cpp.

References CCopasiObject::getObjectAncestor(), CCopasiObject::getObjectParent(), mpModel, CModel::setCompileFlag(), and CCopasiObject::setObjectParent().

76 {
77  if (pParent != getObjectParent() &&
78  mpModel != NULL)
79  {
80  mpModel->setCompileFlag(true);
81  }
82 
83  bool success = CCopasiContainer::setObjectParent(pParent);
84  mpModel = static_cast<CModel *>(getObjectAncestor("Model"));
85 
86  if (mpModel != NULL)
87  {
88  mpModel->setCompileFlag(true);
89  }
90 
91  return success;
92 }
virtual bool setObjectParent(const CCopasiContainer *pParent)
CCopasiContainer * getObjectAncestor(const std::string &type) const
CModel * mpModel
Definition: CEvent.h:139
void setCompileFlag(bool flag=true)
Definition: CModel.cpp:607
Definition: CModel.h:50
CCopasiContainer * getObjectParent() const
bool CEventAssignment::setTargetKey ( const std::string &  targetKey)

Set the key of the target

Parameters
conststd::string & targetKey
Returns
bool success;

Definition at line 151 of file CEvent.cpp.

References getTargetKey(), mpModel, CModel::setCompileFlag(), and CCopasiObject::setObjectName().

Referenced by CModelAdd::addEvents(), CModelMerging::mergeMetabolites(), and CModelExpansion::replaceInEvent().

152 {
153  if (targetKey != getTargetKey() &&
154  mpModel != NULL)
155  {
156  mpModel->setCompileFlag(true);
157  }
158 
159  return setObjectName(targetKey);
160 }
const std::string & getTargetKey() const
Definition: CEvent.cpp:162
CModel * mpModel
Definition: CEvent.h:139
void setCompileFlag(bool flag=true)
Definition: CModel.cpp:607
bool setObjectName(const std::string &name)

Member Data Documentation

std::string CEventAssignment::mKey
private

The key

Definition at line 134 of file CEvent.h.

Referenced by getKey().

CExpression* CEventAssignment::mpExpression
private

The expression to calculate the new value

Definition at line 149 of file CEvent.h.

Referenced by compile(), getExpression(), getExpressionPtr(), setExpression(), setExpressionPtr(), and ~CEventAssignment().

CModel* CEventAssignment::mpModel
private

The parent model

Definition at line 139 of file CEvent.h.

Referenced by CEventAssignment(), setExpression(), setExpressionPtr(), setObjectParent(), setTargetKey(), and ~CEventAssignment().

const CCopasiObject* CEventAssignment::mpTarget
private

The target object

Definition at line 144 of file CEvent.h.

Referenced by compile(), and getTargetObject().


The documentation for this class was generated from the following files: