COPASI API  4.16.103
Public Types | Public Member Functions | Static Public Attributes | Protected Attributes | Private Member Functions | Private Attributes | List of all members
CModelEntity Class Reference

#include <CModelValue.h>

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

Public Types

enum  Status {
  FIXED = 0, ASSIGNMENT, REACTIONS, ODE,
  TIME
}
 
- 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
 
- Public Types inherited from CAnnotation
typedef std::map< std::string,
std::string > 
UnsupportedAnnotation
 

Public Member Functions

virtual void calculate ()
 
 CModelEntity (const std::string &name="NoName", const CCopasiContainer *pParent=NULL, const std::string &type="ModelEntity", const unsigned C_INT32 &flag=CCopasiObject::Container|CCopasiObject::ValueDbl)
 
 CModelEntity (const CModelEntity &src, const CCopasiContainer *pParent=NULL)
 
virtual bool compile ()
 
virtual std::set< const
CCopasiObject * > 
getDeletedObjects () const
 
std::string getExpression () const
 
const CExpressiongetExpressionPtr () const
 
CExpressiongetExpressionPtr ()
 
std::string getInitialExpression () const
 
const CExpressiongetInitialExpressionPtr () const
 
CExpressiongetInitialExpressionPtr ()
 
const C_FLOAT64getInitialValue () const
 
CCopasiObjectgetInitialValueReference () const
 
virtual const std::string & getKey () const
 
const C_FLOAT64getRate () const
 
CCopasiObjectgetRateReference () const
 
const std::string & getSBMLId () const
 
const CModelEntity::StatusgetStatus () const
 
const C_FLOAT64getValue () const
 
virtual const CCopasiObjectgetValueObject () const
 
virtual voidgetValuePointer () const
 
CCopasiObjectgetValueReference () const
 
bool isFixed () const
 
const bool & isUsed () const
 
virtual bool mustBeDeleted (const DataObjectSet &deletedObjects) const
 
virtual void refreshInitialValue ()
 
bool setExpression (const std::string &expression)
 
bool setExpressionPtr (CExpression *pExpression)
 
bool setInitialExpression (const std::string &expression)
 
bool setInitialExpressionPtr (CExpression *pExpression)
 
virtual void setInitialValue (const C_FLOAT64 &initialValue)
 
void setInitialValuePtr (C_FLOAT64 *pInitialValue)
 
virtual bool setObjectParent (const CCopasiContainer *pParent)
 
void setRate (const C_FLOAT64 &rate)
 
void setSBMLId (const std::string &id)
 
virtual void setStatus (const CModelEntity::Status &status)
 
void setUsed (const bool &used)
 
virtual void setValue (const C_FLOAT64 &value)
 
void setValuePtr (C_FLOAT64 *pValue)
 
 ~CModelEntity ()
 
- 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 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
 
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 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 ()
 
- Public Member Functions inherited from CAnnotation
bool addUnsupportedAnnotation (const std::string &name, const std::string &xml)
 
 CAnnotation ()
 
 CAnnotation (const CAnnotation &src)
 
const std::string & getMiriamAnnotation () const
 
const std::string & getNotes () const
 
UnsupportedAnnotationgetUnsupportedAnnotations ()
 
const UnsupportedAnnotationgetUnsupportedAnnotations () const
 
bool operator== (const CAnnotation &rhs) const
 
bool removeUnsupportedAnnotation (const std::string &name)
 
bool replaceUnsupportedAnnotation (const std::string &name, const std::string &xml)
 
void setMiriamAnnotation (const std::string &miriamAnnotation, const std::string &newId, const std::string &oldId)
 
void setNotes (const std::string &notes)
 
virtual ~CAnnotation ()
 

Static Public Attributes

static const std::string StatusName []
 
static const char * XMLStatus []
 
- Static Public Attributes inherited from CCopasiContainer
static const std::vector
< CCopasiContainer * > 
EmptyList
 

Protected Attributes

CExpressionmpExpression
 
CExpressionmpInitialExpression
 
C_FLOAT64mpIValue
 
CCopasiObjectReference
< C_FLOAT64 > * 
mpIValueReference
 
CModelmpModel
 
CCopasiObjectReference
< C_FLOAT64 > * 
mpRateReference
 
C_FLOAT64mpValue
 
CCopasiObjectReference
< C_FLOAT64 > * 
mpValueReference
 
C_FLOAT64 mRate
 
std::string mSBMLId
 
- Protected Attributes inherited from CCopasiContainer
objectMap mObjects
 
- Protected Attributes inherited from CAnnotation
std::string mKey
 

Private Member Functions

void initObjects ()
 

Private Attributes

Status mStatus
 
bool mUsed
 

Additional Inherited Members

- 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 Member Functions inherited from CAnnotation
static CAnnotationcastObject (CCopasiObject *pObject)
 
static const CAnnotationcastObject (const CCopasiObject *pObject)
 
- 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)
 
- Static Protected Attributes inherited from CCopasiObject
static CRenameHandlersmpRenameHandler = NULL
 

Detailed Description

The base class for CCompartment, CMetab and CModelValue. CModelEntity is a base class for CCompartment, CMetab and CModelValue. These three classes have in common that (in the long run) they can each be model variables (subject to ODEs), constant, or subject to algebraic assignments. In addition, the CMetab objects can also be subject to reactions, and conservation rules.

Definition at line 39 of file CModelValue.h.

Member Enumeration Documentation

The valid states for metabolites

Enumerator
FIXED 
ASSIGNMENT 
REACTIONS 
ODE 
TIME 

Definition at line 53 of file CModelValue.h.

54  {
55  FIXED = 0, //the entity is constant (for species even if they are part of a reaction)
56  ASSIGNMENT, //the entity is changed by an assignment rule
57  REACTIONS, //applies only for species, the species concentration is changed by reactions
58  // DEPENDENT, //applies only for species, the species concentration is determined by conservation rules
59  // UNUSED,
60  ODE, //the entity is changed by an ordinary differential equation
61  TIME
62  };

Constructor & Destructor Documentation

CModelEntity::CModelEntity ( const std::string &  name = "NoName",
const CCopasiContainer pParent = NULL,
const std::string &  type = "ModelEntity",
const unsigned C_INT32 flag = CCopasiObject::Container | CCopasiObject::ValueDbl 
)

Default constructor

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

Definition at line 62 of file CModelValue.cpp.

References CKeyFactory::add(), CONSTRUCTOR_TRACE, CCopasiRootContainer::getKeyFactory(), CCopasiObject::getObjectType(), initObjects(), CAnnotation::mKey, mpIValue, and mpValue.

65  :
67  CAnnotation(),
68  mpValue(NULL),
69  mpIValue(NULL),
70  mRate(0.0),
71  mpExpression(NULL),
72  mpInitialExpression(NULL),
73  mStatus(FIXED),
74  mUsed(false),
75  mpModel(NULL)
76 {
78 
79  initObjects();
80 
81  *mpIValue = 1.0;
82  *mpValue = std::numeric_limits<C_FLOAT64>::quiet_NaN();
83 
85 }
CExpression * mpInitialExpression
Definition: CModelValue.h:341
C_FLOAT64 mRate
Definition: CModelValue.h:331
C_FLOAT64 * mpValue
Definition: CModelValue.h:321
const std::string & getObjectType() const
C_FLOAT64 * mpIValue
Definition: CModelValue.h:326
void initObjects()
std::string mKey
Definition: CAnnotation.h:119
std::string add(const std::string &prefix, CCopasiObject *pObject)
long int flag
Definition: f2c.h:52
static CKeyFactory * getKeyFactory()
Status mStatus
Definition: CModelValue.h:347
CExpression * mpExpression
Definition: CModelValue.h:336
CModel * mpModel
Definition: CModelValue.h:359
#define CONSTRUCTOR_TRACE
Definition: copasi.h:202
CModelEntity::CModelEntity ( const CModelEntity src,
const CCopasiContainer pParent = NULL 
)

Copy constructor

Parameters
constCModelValue & src
constCCopasiContainer * pParent (default: NULL)

Definition at line 87 of file CModelValue.cpp.

References CKeyFactory::add(), CCopasiRootContainer::getKeyFactory(), CAnnotation::getMiriamAnnotation(), CCopasiObject::getObjectType(), initObjects(), CAnnotation::mKey, mpIValue, mpValue, mStatus, CAnnotation::setMiriamAnnotation(), and setStatus().

88  :
89  CCopasiContainer(src, pParent),
90  CAnnotation(src),
91  mpValue(NULL),
92  mpIValue(NULL),
93  mRate(src.mRate),
94  mpExpression(src.mpExpression ? new CExpression(*src.mpExpression, this) : NULL),
96  mStatus(FIXED),
97  mUsed(false),
98  mpModel(NULL)
99 {
101 
102  initObjects();
103 
104  setStatus(src.mStatus);
105 
106  *mpValue = *src.mpValue;
107  *mpIValue = *src.mpIValue;
108 
110 }
CExpression * mpInitialExpression
Definition: CModelValue.h:341
C_FLOAT64 mRate
Definition: CModelValue.h:331
C_FLOAT64 * mpValue
Definition: CModelValue.h:321
const std::string & getObjectType() const
void setMiriamAnnotation(const std::string &miriamAnnotation, const std::string &newId, const std::string &oldId)
const std::string & getMiriamAnnotation() const
C_FLOAT64 * mpIValue
Definition: CModelValue.h:326
void initObjects()
std::string mKey
Definition: CAnnotation.h:119
virtual void setStatus(const CModelEntity::Status &status)
std::string add(const std::string &prefix, CCopasiObject *pObject)
static CKeyFactory * getKeyFactory()
Status mStatus
Definition: CModelValue.h:347
CExpression * mpExpression
Definition: CModelValue.h:336
CModel * mpModel
Definition: CModelValue.h:359
CModelEntity::~CModelEntity ( )

Destructor.

Definition at line 112 of file CModelValue.cpp.

References DESTRUCTOR_TRACE, CModel::getStateTemplate(), mpIValue, mpModel, mpValue, pdelete, and CStateTemplate::remove().

113 {
114  if (mpModel)
116 
117  // After the above call we definitely own the data and
118  // therefore must destroy them.
119 
120  pdelete(mpValue);
121  pdelete(mpIValue);
122  // since the expressions now have the model entity as parent, they should
123  // automatically be destroyed be the destructor of CCopasiContainer
124  //pdelete(mpExpression);
125  //pdelete(mpInitialExpression);
126 
128 }
void remove(CModelEntity *entity)
Definition: CState.cpp:80
#define pdelete(p)
Definition: copasi.h:215
C_FLOAT64 * mpValue
Definition: CModelValue.h:321
C_FLOAT64 * mpIValue
Definition: CModelValue.h:326
#define DESTRUCTOR_TRACE
Definition: copasi.h:206
const CStateTemplate & getStateTemplate() const
Definition: CModel.cpp:1172
CModel * mpModel
Definition: CModelValue.h:359

Member Function Documentation

void CModelEntity::calculate ( void  )
virtual

Calculate the value or the rate depending whether we have an ASIGNMENT or ODE

Reimplemented in CMetab.

Definition at line 197 of file CModelValue.cpp.

References ASSIGNMENT, CExpression::calcValue(), mpExpression, mpValue, mRate, mStatus, and ODE.

Referenced by setStatus().

198 {
199  switch (mStatus)
200  {
201  case ASSIGNMENT:
203  break;
204 
205  case ODE:
207  break;
208 
209  default:
210  break;
211  }
212 }
C_FLOAT64 mRate
Definition: CModelValue.h:331
C_FLOAT64 * mpValue
Definition: CModelValue.h:321
virtual const C_FLOAT64 & calcValue()
Status mStatus
Definition: CModelValue.h:347
CExpression * mpExpression
Definition: CModelValue.h:336
bool CModelEntity::compile ( )
virtual

Compile the model value. This is only needed for status ASIGNMENT and ODE.

Returns
bool success

Reimplemented in CModel, and CMetab.

Definition at line 143 of file CModelValue.cpp.

References CCopasiContainer::add(), CCopasiObject::addDirectDependency(), ASSIGNMENT, CExpression::calcValue(), CExpression::compile(), CExpression::createInitialExpression(), CCopasiObject::getDirectDependencies(), CEvaluationTree::getInfix(), CCopasiObject::getObjectDataModel(), CEvaluationTree::isUsable(), mpExpression, mpInitialExpression, mpIValue, mpIValueReference, mpModel, mpRateReference, mpValueReference, mStatus, ODE, pdelete, CCopasiObject::setDirectDependencies(), and CCopasiObject::setObjectName().

Referenced by CModel::buildSimulatedSequence(), CModel::buildStateTemplate(), setExpression(), setExpressionPtr(), setInitialExpression(), and setInitialExpressionPtr().

144 {
145  bool success = true;
146 
147  std::set< const CCopasiObject * > NoDependencies;
148  std::vector< CCopasiContainer * > listOfContainer;
149  listOfContainer.push_back(mpModel);
150  CCopasiDataModel* pDataModel = NULL;
151 
152  switch (mStatus)
153  {
154  case ASSIGNMENT:
155  success &= mpExpression->compile(listOfContainer);
157 
159  pDataModel = getObjectDataModel();
160  assert(pDataModel != NULL);
162  mpInitialExpression->setObjectName("InitialExpression");
163  add(mpInitialExpression, true);
164  break;
165 
166  case ODE:
168 
169  success &= mpExpression->compile(listOfContainer);
171  break;
172 
173  default:
174  break;
175  }
176 
177  // Here we handle initial expressions for all types.
178  if (mpInitialExpression != NULL &&
179  mpInitialExpression->getInfix() != "")
180  {
181  success &= mpInitialExpression->compile(listOfContainer);
183 
184  // If we have a valid initial expression, we update the initial value.
185  // In case the expression is constant this suffices other are updated lated again.
188  }
189  else
190  {
191  mpIValueReference->setDirectDependencies(NoDependencies);
192  }
193 
194  return success;
195 }
CCopasiDataModel * getObjectDataModel()
#define pdelete(p)
Definition: copasi.h:215
CCopasiObjectReference< C_FLOAT64 > * mpIValueReference
Definition: CModelValue.h:356
CExpression * mpInitialExpression
Definition: CModelValue.h:341
void setDirectDependencies(const DataObjectSet &directDependencies)
CCopasiObjectReference< C_FLOAT64 > * mpRateReference
Definition: CModelValue.h:358
virtual bool compile(std::vector< CCopasiContainer * > listOfContainer=CCopasiContainer::EmptyList)
Definition: CExpression.cpp:97
static CExpression * createInitialExpression(const CExpression &expression, const CCopasiDataModel *pDataModel)
C_FLOAT64 * mpIValue
Definition: CModelValue.h:326
void addDirectDependency(const CCopasiObject *pObject)
virtual const C_FLOAT64 & calcValue()
bool isUsable() const
CCopasiObjectReference< C_FLOAT64 > * mpValueReference
Definition: CModelValue.h:357
virtual const DataObjectSet & getDirectDependencies(const DataObjectSet &context=DataObjectSet()) const
Status mStatus
Definition: CModelValue.h:347
CExpression * mpExpression
Definition: CModelValue.h:336
virtual bool add(CCopasiObject *pObject, const bool &adopt=true)
bool setObjectName(const std::string &name)
CModel * mpModel
Definition: CModelValue.h:359
const std::string & getInfix() const
std::set< const CCopasiObject * > CModelEntity::getDeletedObjects ( ) const
virtual

Retrieve the list of deleted numeric child objects;

Returns
std::set< const CCopasiObject * > deletedObjects

Reimplemented in CMetab, and CCompartment.

Definition at line 587 of file CModelValue.cpp.

References mpIValueReference, mpRateReference, and mpValueReference.

Referenced by CModel::appendDependentModelObjects(), CModel::determineIsAutonomous(), CCompartment::getDeletedObjects(), CMetab::getDeletedObjects(), mustBeDeleted(), CModel::removeModelValue(), CQGlobalQuantityDM::removeRows(), and CQModelValue::slotBtnDelete().

588 {
589  std::set< const CCopasiObject * > Deleted;
590 
591  Deleted.insert(this);
592  Deleted.insert(mpIValueReference);
593  Deleted.insert(mpValueReference);
594  Deleted.insert(mpRateReference);
595 
596  return Deleted;
597 }
CCopasiObjectReference< C_FLOAT64 > * mpIValueReference
Definition: CModelValue.h:356
CCopasiObjectReference< C_FLOAT64 > * mpRateReference
Definition: CModelValue.h:358
CCopasiObjectReference< C_FLOAT64 > * mpValueReference
Definition: CModelValue.h:357
std::string CModelEntity::getExpression ( ) const
const CExpression * CModelEntity::getExpressionPtr ( ) const

Retrieve the pointer to the expression for non FIXED model values.

Returns
CExpression*

Definition at line 250 of file CModelValue.cpp.

References mpExpression.

Referenced by CSBMLExporter::checkForPiecewiseFunctions(), CSBMLExporter::checkForUnsupportedFunctionCalls(), CSBMLExporter::checkForUnsupportedObjectReferences(), CMathObject::compileRate(), CMathObject::compileValue(), CModelAdd::copyExpression(), CSBMLExporter::createRule(), CQGlobalQuantityDM::data(), CQCompartmentDM::data(), CQSpecieDM::data(), CModelExpansion::duplicateCompartment(), CModelExpansion::duplicateGlobalQuantity(), CModelExpansion::duplicateMetab(), CODEExporter::exportModelEntityExpression(), CODEExporter::exportModelValuesExpressions(), SBMLImporter::importRuleForModelEntity(), CModelMerging::mergeMetabolites(), SBMLImporter::removeUnusedFunctions(), CModelExpansion::replaceInModelEntity(), test000093::test_bug1503_1(), test000093::test_bug1503_2(), test000091::test_delay_in_kinetic_law(), test000091::test_delay_in_kinetic_law_local_parameter(), test000027::test_hasOnlySubstanceUnits(), test000034::test_hasOnlySubstanceUnits(), test000023::test_hasOnlySubstanceUnits(), test000025::test_hasOnlySubstanceUnits(), test000033::test_hasOnlySubstanceUnits(), test000087::test_import_reaction_flux_reference_2(), test000075::test_import_time_dependent_function_definition(), test000087::test_simulate_reaction_flux_reference_1(), and CMMLOutput::writeRHS_ModelEntity().

251 {
252  return mpExpression;
253 }
CExpression * mpExpression
Definition: CModelValue.h:336
CExpression * CModelEntity::getExpressionPtr ( )

Retrieve the pointer to the expression for non FIXED model values.

Returns
CExpression*

Definition at line 245 of file CModelValue.cpp.

References mpExpression.

246 {
247  return mpExpression;
248 }
CExpression * mpExpression
Definition: CModelValue.h:336
std::string CModelEntity::getInitialExpression ( ) const

Retrieve the expression for ODE or REACTION model values.

Returns
std::string expression

Definition at line 350 of file CModelValue.cpp.

References ASSIGNMENT, CEvaluationTree::getInfix(), mpInitialExpression, mStatus, and CExpression::updateInfix().

Referenced by CModelAdd::addCompartmentsExpressions(), CModelAdd::addMetabolitesExpressions(), CModelAdd::addModelValuesExpressions(), CModel::buildInitialRefreshSequence(), CModel::convert2NonReversible(), CSBMLExporter::createCompartment(), CSBMLExporter::createMetabolite(), CSBMLExporter::createParameter(), CQGlobalQuantityDM::data(), CQSpecieDM::data(), CModelExpansion::duplicateCompartment(), CModelExpansion::duplicateGlobalQuantity(), CModelExpansion::duplicateMetab(), SliderDialog::fillSliderBox(), CQSimpleSelectionTree::filter(), CParticleReference::getDirectDependencies(), CQSpeciesDetail::load(), CQCompartment::load(), CQModelValue::load(), CModelMerging::mergeMetabolites(), CQSpeciesDetail::save(), CQCompartment::save(), CQModelValue::save(), CCopasiXML::saveModel(), test000041::test_hasOnlySubstanceUnits(), and test000040::test_hasOnlySubstanceUnits().

351 {
352  if (mStatus == ASSIGNMENT || mpInitialExpression == NULL)
353  return "";
354 
356  return mpInitialExpression->getInfix();
357 }
CExpression * mpInitialExpression
Definition: CModelValue.h:341
bool updateInfix()
Status mStatus
Definition: CModelValue.h:347
const std::string & getInfix() const
const CExpression * CModelEntity::getInitialExpressionPtr ( ) const
CExpression * CModelEntity::getInitialExpressionPtr ( )

Retrieve the pointer to the expression for non FIXED model values.

Returns
CExpression*

Definition at line 289 of file CModelValue.cpp.

References mpInitialExpression.

290 {
291  return mpInitialExpression;
292 }
CExpression * mpInitialExpression
Definition: CModelValue.h:341
const C_FLOAT64 & CModelEntity::getInitialValue ( ) const

Retrieve the initial value

Definition at line 138 of file CModelValue.cpp.

References mpIValue.

Referenced by CModelAdd::addCompartments(), CModelAdd::addModelValues(), CFunctionAnalyzer::constructCallParametersActualValues(), CMetab::convertToConcentration(), CMetab::convertToNumber(), CSBMLExporter::createCompartment(), CModelParameterSet::createFromModel(), CSBMLExporter::createMetabolite(), CSBMLExporter::createParameter(), CCSPMethod::cspstep(), CQGlobalQuantityDM::data(), CQCompartmentDM::data(), CQSpecieDM::data(), CModelExpansion::duplicateCompartment(), CModelExpansion::duplicateGlobalQuantity(), CODEExporter::exportCompartments(), CODEExporter::exportExpression(), CODEExporter::exportMetabolites(), CODEExporter::exportModelValues(), CModel::initializeAtolVector(), CQSpeciesDetail::load(), CQCompartment::load(), CQModelValue::load(), CReactionInterface::loadMappingAndValues(), CQUpdatesWidget::loadObjectsTable(), CModelParameter::refreshFromModel(), CMetab::refreshInitialConcentration(), CMetab::refreshInitialValue(), CQSpeciesDetail::save(), CQCompartment::save(), CQModelValue::save(), CQSpecieDM::setData(), CQSpeciesDetail::slotCompartmentChanged(), CModel::suitableForStochasticSimulation(), test000091::test_delay_in_kinetic_law_local_parameter(), test000026::test_hasOnlySubstanceUnits(), test000087::test_simulate_reaction_flux_reference_1(), and ParameterTable::updateTable().

139 {return *mpIValue;}
C_FLOAT64 * mpIValue
Definition: CModelValue.h:326
CCopasiObject * CModelEntity::getInitialValueReference ( ) const

Retrieve object referencing the initial value

Returns
CCopasiObject * initialValueReference

Definition at line 367 of file CModelValue.cpp.

References mpIValueReference.

Referenced by DataModelGUI::buildChangedObjects(), CModel::buildInitialRefreshSequence(), CMetab::compileInitialValueDependencies(), CMathObject::createExtensiveValueExpression(), CModelParameterSet::createFromModel(), CSBMLExporter::createInitialAssignment(), CExpression::createInitialExpression(), CMathObject::createIntensiveValueExpression(), test000097::createModel(), SliderDialog::determineCorrectObjectForSlider(), findObjectByDisplayName(), CMetab::getChildObjectUnits(), getInitialCNForSBase(), CModelParameter::getUnit(), SBMLImporter::importInitialAssignments(), CMathContainer::initializeObjects(), CQSimpleSelectionTree::populateTree(), SBMLImporter::replace_time_with_initial_time(), test000058::test_bug1025_10(), test000058::test_bug1025_2(), test000058::test_bug1025_4(), test000058::test_bug1025_5(), test000058::test_bug1025_7(), test000058::test_bug1025_9(), test000059::test_unique_id_1(), test000059::test_unique_id_12(), test000059::test_unique_id_14(), test000059::test_unique_id_17(), test000059::test_unique_id_18(), test000059::test_unique_id_19(), test000059::test_unique_id_20(), test000059::test_unique_id_21(), test000059::test_unique_id_21_2(), test000059::test_unique_id_3(), test000059::test_unique_id_6(), and test000059::test_unique_id_8().

368 {return mpIValueReference;}
CCopasiObjectReference< C_FLOAT64 > * mpIValueReference
Definition: CModelValue.h:356
const std::string & CModelEntity::getKey ( ) const
virtual

Retrieve the key

Returns
std::string key

Reimplemented from CAnnotation.

Reimplemented in CModel.

Definition at line 131 of file CModelValue.cpp.

References CAnnotation::getKey().

Referenced by CModelAdd::addCompartments(), CModelAdd::addCompartmentsExpressions(), CModelAdd::addMetabolites(), CModelAdd::addMetabolitesExpressions(), CModelAdd::addModelValues(), CModelAdd::addModelValuesExpressions(), CModelAdd::addReactions(), CFixLocalReactionParameters::changeModel(), CQCompartment::copy(), CLayoutInitializer::createCompartmentGlyph(), CMathObject::createExtensiveReactionRateExpression(), CCopasiSpringLayout::createLayout(), CLayoutInitializer::createMetabGlyph(), test000097::createModel(), CSBMLExporter::createSBMLDocument(), CModelExpansion::duplicateCompartment(), CModelExpansion::duplicateGlobalQuantity(), CModelExpansion::duplicateMetab(), CModelExpansion::duplicateReaction(), CODEExporter::exportExpression(), CODEExporter::exportKineticFunction(), CODEExporter::exportMetabolitesConcentrations(), CODEExporter::exportModelEntityExpression(), CODEExporter::exportODEs(), CODEExporterBM::exportSingleCompartment(), CODEExporterXPPAUT::exportSingleCompartment(), CODEExporterC::exportSingleCompartment(), CODEExporterBM::exportSingleMetabolite(), CODEExporterXPPAUT::exportSingleMetabolite(), CODEExporterC::exportSingleMetabolite(), CODEExporterBM::exportSingleModelEntity(), CODEExporterXPPAUT::exportSingleModelEntity(), CODEExporterC::exportSingleModelEntity(), CODEExporterBM::exportSingleModVal(), CODEExporterXPPAUT::exportSingleModVal(), CODEExporterC::exportSingleModVal(), CODEExporterBM::exportSingleODE(), CODEExporterXPPAUT::exportSingleODE(), CODEExporterC::exportSingleODE(), CQSelectionWizardPage::fillTree(), getMetabGlyphForKey(), CMetabNameInterface::getMetaboliteKey(), CEFMTask::getSpeciesChanges(), SBMLImporter::importMIRIAM(), CCopasiSpringLayout::initFromLayout(), CQGlobalQuantityDM::insertRows(), CQCompartmentDM::insertRows(), CQSpecieDM::insertRows(), CODEExporterC::KineticFunction2ODEmember(), CModelMerging::mergeMetabolites(), CODEExporterC::preprocess(), CODEExporter::preprocess(), CCopasiSpringLayout::randomize(), CModelExpansion::replaceInReaction(), CCopasiXML::saveModel(), CQNewMainWindow::selectMetabolite(), CQGlobalQuantityDM::setData(), CQCompartmentDM::setData(), CQSpecieDM::setData(), CChemEq::setMultiplicity(), CModelMerging::simpleCall(), CModelExpansion::simpleCall(), CQEventWidget1::slotAddTarget(), CQSpeciesDetail::slotBtnNew(), CQCompartment::slotBtnNew(), CQModelValue::slotBtnNew(), CQEventWidget1::slotSelectObject(), CCopasiXMLParser::SourceParameterElement::start(), CCopasiXMLParser::ModifierElement::start(), CCopasiXMLParser::ProductElement::start(), CCopasiXMLParser::SubstrateElement::start(), CCopasiXMLParser::AssignmentElement::start(), CCopasiXMLParser::CompartmentGlyphElement::start(), CCopasiXMLParser::MetaboliteGlyphElement::start(), CCopasiXMLParser::TextGlyphElement::start(), test000091::test_delay_in_kinetic_law(), test000091::test_delay_in_kinetic_law_local_parameter(), test000087::test_simulate_reaction_flux_reference_1(), CSBMLExporter::updateMIRIAMAnnotation(), and CMMLOutput::writeRHS().

132 {
133  return CAnnotation::getKey();
134 }
virtual const std::string & getKey() const
const C_FLOAT64 & CModelEntity::getRate ( ) const

Return rate of production of this entity

Definition at line 362 of file CModelValue.cpp.

References mRate.

Referenced by CQGlobalQuantityDM::data(), CQCompartmentDM::data(), CQSpecieDM::data(), CQCompartment::load(), CQModelValue::load(), operator<<(), CMetab::refreshConcentrationRate(), and CQSpeciesDetail::setFramework().

363 {
364  return mRate;
365 }
C_FLOAT64 mRate
Definition: CModelValue.h:331
CCopasiObject * CModelEntity::getRateReference ( ) const

Retrieve object referencing the rate

Returns
CCopasiObject * rateReference

Definition at line 373 of file CModelValue.cpp.

References mpRateReference.

Referenced by CMetab::compile(), CMathObject::createIntensiveRateExpression(), findObjectByDisplayName(), CMathContainer::initializeObjects(), and CQSimpleSelectionTree::populateTree().

374 {return mpRateReference;}
CCopasiObjectReference< C_FLOAT64 > * mpRateReference
Definition: CModelValue.h:358
const std::string & CModelEntity::getSBMLId ( ) const
const CModelEntity::Status & CModelEntity::getStatus ( ) const

Retrieve the status of the entity.

Returns
const CModelEntity::Status & status

Definition at line 141 of file CModelValue.cpp.

References mStatus.

Referenced by CModelAdd::addCompartments(), CModelAdd::addMetabolites(), CModelAdd::addModelValues(), CModel::buildInitialRefreshSequence(), CMetab::calculate(), CLNAMethod::calculateCovarianceMatrixReduced(), CSBMLExporter::checkForODESpeciesInNonfixedCompartment(), CSBMLExporter::checkForPiecewiseFunctions(), CEventAssignment::compile(), CMetab::compile(), CMetab::compileInitialValueDependencies(), CFunctionAnalyzer::constructCallParametersActualValues(), CModel::convert2NonReversible(), CSBMLExporter::createCompartment(), CCopasiSpringLayout::createLayout(), CSBMLExporter::createMetabolite(), CSBMLExporter::createParameter(), CSBMLExporter::createRule(), CQGlobalQuantityDM::data(), CQCompartmentDM::data(), CQSpecieDM::data(), CModelExpansion::duplicateCompartment(), CModelExpansion::duplicateGlobalQuantity(), CModelExpansion::duplicateMetab(), CODEExporter::exportCompartments(), CODEExporter::exportExpression(), CODEExporter::exportMetabolites(), CODEExporter::exportMetabolitesConcentrations(), CODEExporter::exportModelEntityExpression(), CODEExporter::exportModelValues(), CODEExporter::exportModelValuesExpressions(), CODEExporter::exportODEs(), CODEExporterBM::exportSingleCompartment(), CODEExporterXPPAUT::exportSingleCompartment(), CODEExporterC::exportSingleCompartment(), CODEExporterBM::exportSingleMetabolite(), CODEExporterXPPAUT::exportSingleMetabolite(), CODEExporterC::exportSingleMetabolite(), CODEExporterBM::exportSingleModelEntity(), CODEExporterXPPAUT::exportSingleModelEntity(), CODEExporterC::exportSingleModelEntity(), CODEExporterBM::exportSingleModVal(), CODEExporterXPPAUT::exportSingleModVal(), CODEExporterC::exportSingleModVal(), CQSimpleSelectionTree::filter(), CParticleReference::getDirectDependencies(), SBMLImporter::importRuleForModelEntity(), CSteadyStateTask::initialize(), CMathContainer::initializeObjects(), CSBMLExporter::isEventAssignmentSBMLCompatible(), CODEExporter::isModelEntityExpressionODEExporterCompatible(), CParticleReference::isPrerequisiteForContext(), CQSpeciesDetail::load(), CQCompartment::load(), CQModelValue::load(), CQUpdatesWidget::loadObjectsTable(), CModelMerging::mergeMetabolites(), CMetab::mustBeDeleted(), operator<<(), CQSimpleSelectionTree::populateTree(), CODEExporterC::preprocess(), CODEExporter::preprocess(), CMetab::refreshRate(), CMetab::refreshTransitionTime(), SBMLImporter::removeUnusedFunctions(), CSBMLExporter::replaceSpeciesReferences(), CQSpeciesDetail::save(), CQCompartment::save(), CQModelValue::save(), CCopasiXML::saveModel(), CQSpeciesDetail::setFramework(), CMetab::setObjectParent(), CMetab::setStatus(), CHybridMethodODE45::setupBalances(), CHybridMethod::setupBalances(), CHybridMethodLSODA::setupBalances(), CHybridMethodODE45::setupMetab2React(), CTauLeapMethod::start(), CStochDirectMethod::start(), CTrajAdaptiveSA::start(), CTrajectoryMethodDsaLsodar::start(), test000093::test_bug1503_1(), test000093::test_bug1503_2(), test000091::test_delay_in_kinetic_law(), test000091::test_delay_in_kinetic_law_local_parameter(), test000040::test_hasOnlySubstanceUnits(), test000023::test_hasOnlySubstanceUnits(), test000033::test_hasOnlySubstanceUnits(), test000025::test_hasOnlySubstanceUnits(), test000041::test_hasOnlySubstanceUnits(), test000026::test_hasOnlySubstanceUnits(), test000034::test_hasOnlySubstanceUnits(), test000027::test_hasOnlySubstanceUnits(), test000087::test_import_reaction_flux_reference_2(), test000075::test_import_time_dependent_function_definition(), CSteadyStateTask::updateMatrices(), CModelParameter::updateModel(), and ParameterTable::updateTable().

141 {return mStatus;}
Status mStatus
Definition: CModelValue.h:347
const C_FLOAT64 & CModelEntity::getValue ( ) const
const CCopasiObject * CModelEntity::getValueObject ( ) const
virtual

Retrieve the object representing the value;

Reimplemented from CCopasiContainer.

Reimplemented in CMetab.

Definition at line 484 of file CModelValue.cpp.

References mpValueReference.

Referenced by CEventAssignment::compile().

485 {
486  return mpValueReference;
487 }
CCopasiObjectReference< C_FLOAT64 > * mpValueReference
Definition: CModelValue.h:357
void * CModelEntity::getValuePointer ( ) const
virtual

Retrieve a pointer to the value;

Reimplemented from CCopasiObject.

Reimplemented in CMetab.

Definition at line 490 of file CModelValue.cpp.

References C_FLOAT64, and mpValue.

Referenced by CReaction::setScalingFactor().

491 {
492  return const_cast<C_FLOAT64 *>(mpValue);
493 }
C_FLOAT64 * mpValue
Definition: CModelValue.h:321
#define C_FLOAT64
Definition: copasi.h:92
CCopasiObject * CModelEntity::getValueReference ( ) const
void CModelEntity::initObjects ( )
private

Initialize the contained CCopasiObjects

Definition at line 495 of file CModelValue.cpp.

References CStateTemplate::add(), CCopasiContainer::addObjectReference(), C_FLOAT64, CCopasiObject::getObjectAncestor(), CModel::getStateTemplate(), mpIValueReference, mpModel, mpRateReference, mpValueReference, mRate, mSBMLId, refreshInitialValue(), setInitialValue(), setInitialValuePtr(), CCopasiObject::setRefresh(), CCopasiObject::setUpdateMethod(), setValue(), setValuePtr(), CCopasiObject::ValueDbl, and CCopasiObject::ValueString.

Referenced by CModelEntity().

496 {
497  C_FLOAT64 Dummy;
498 
501  Dummy,
504 
506  static_cast<CCopasiObjectReference<C_FLOAT64> *>(addObjectReference("InitialValue",
507  Dummy,
511 
514 
516 
517  mpModel = static_cast<CModel *>(getObjectAncestor("Model"));
518 
519  if (mpModel)
520  {
521  mpModel->getStateTemplate().add(this);
522  }
523  else
524  {
525  // This creates the needed values.
526  setInitialValuePtr(NULL);
527  setValuePtr(NULL);
528  }
529 }
CCopasiContainer * getObjectAncestor(const std::string &type) const
void setRefresh(CType *pType, void(CType::*method)(void))
CCopasiObjectReference< C_FLOAT64 > * mpIValueReference
Definition: CModelValue.h:356
void add(CModelEntity *entity)
Definition: CState.cpp:63
C_FLOAT64 mRate
Definition: CModelValue.h:331
CCopasiObjectReference< C_FLOAT64 > * mpRateReference
Definition: CModelValue.h:358
virtual void setValue(const C_FLOAT64 &value)
void setUpdateMethod(CType *pType, void(CType::*method)(const C_FLOAT64 &))
void setValuePtr(C_FLOAT64 *pValue)
std::string mSBMLId
Definition: CModelValue.h:47
CCopasiObjectReference< C_FLOAT64 > * mpValueReference
Definition: CModelValue.h:357
#define C_FLOAT64
Definition: copasi.h:92
const CStateTemplate & getStateTemplate() const
Definition: CModel.cpp:1172
void setInitialValuePtr(C_FLOAT64 *pInitialValue)
virtual void setInitialValue(const C_FLOAT64 &initialValue)
Definition: CModel.h:50
CModel * mpModel
Definition: CModelValue.h:359
CCopasiObject * addObjectReference(const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)
virtual void refreshInitialValue()
bool CModelEntity::isFixed ( ) const
inline

Check whether the entity is FIXED or not.

Returns
bool isFixed

Definition at line 124 of file CModelValue.h.

References FIXED, and mStatus.

Referenced by getExpression(), CMetab::refreshInitialConcentration(), CMetab::setConcentration(), setExpression(), and setExpressionPtr().

124 {return mStatus == FIXED;}
Status mStatus
Definition: CModelValue.h:347
const bool & CModelEntity::isUsed ( ) const

Retrieve whether the model value is used during simulation

Returns
const bool & used

Definition at line 645 of file CModelValue.cpp.

References mUsed.

Referenced by CModel::buildUserOrder(), and CQUpdatesWidget::loadObjectsTable().

646 {return mUsed;}
bool CModelEntity::mustBeDeleted ( const DataObjectSet deletedObjects) const
virtual

Check whether an object must be deleted because its prerequisites can no longer be fulfilled due to the given deleted objects

Parameters
constDataObjectSet & deletedObjects
Returns
bool mustBeDeleted

Reimplemented from CCopasiObject.

Reimplemented in CMetab.

Definition at line 600 of file CModelValue.cpp.

References getDeletedObjects().

601 {
602  bool MustBeDeleted = false;
603 
604  DataObjectSet ChildObjects = getDeletedObjects();
605 
606  DataObjectSet::const_iterator it = ChildObjects.begin();
607  DataObjectSet::const_iterator end = ChildObjects.end();
608 
609  for (; it != end; ++it)
610  {
611  if (*it == this)
612  {
613  if ((*it)->CCopasiObject::mustBeDeleted(deletedObjects))
614  {
615  MustBeDeleted = true;
616  break;
617  }
618 
619  continue;
620  }
621 
622  if ((*it)->mustBeDeleted(deletedObjects))
623  {
624  MustBeDeleted = true;
625  break;
626  }
627  }
628 
629  return MustBeDeleted;
630 }
virtual std::set< const CCopasiObject * > getDeletedObjects() const
std::set< const CCopasiObject * > DataObjectSet
void CModelEntity::refreshInitialValue ( )
virtual

Refresh the initial value

Reimplemented in CMetab.

Definition at line 214 of file CModelValue.cpp.

References CExpression::calcValue(), CEvaluationTree::getInfix(), mpInitialExpression, and mpIValue.

Referenced by initObjects().

215 {
216  if (mpInitialExpression != NULL &&
217  mpInitialExpression->getInfix() != "")
219 }
CExpression * mpInitialExpression
Definition: CModelValue.h:341
C_FLOAT64 * mpIValue
Definition: CModelValue.h:326
virtual const C_FLOAT64 & calcValue()
const std::string & getInfix() const
bool CModelEntity::setExpression ( const std::string &  expression)

Set the expression for non FIXED model values

Parameters
conststd::string & expression
Returns
bool success

Definition at line 221 of file CModelValue.cpp.

References compile(), isFixed(), mpExpression, mpModel, CModel::setCompileFlag(), and CExpression::setInfix().

Referenced by CModel::convert2NonReversible(), CModelAdd::copyExpression(), CModelExpansion::duplicateCompartment(), CModelExpansion::duplicateGlobalQuantity(), CModelExpansion::duplicateMetab(), CQEventWidget1::loadFromEvent(), CQSpeciesDetail::save(), CQCompartment::save(), CQModelValue::save(), test000058::test_bug1025_10(), test000058::test_bug1025_5(), test000059::test_unique_id_17(), test000059::test_unique_id_18(), test000059::test_unique_id_19(), test000059::test_unique_id_20(), test000059::test_unique_id_21(), and test000059::test_unique_id_21_2().

222 {
223  if (isFixed()) return false;
224 
225  if (mpExpression == NULL)
226  mpExpression = new CExpression("Expression", this);
227 
228  if (mpModel)
229  mpModel->setCompileFlag(true);
230 
231  if (!mpExpression->setInfix(expression)) return false;
232 
233  return compile();
234 }
virtual bool setInfix(const std::string &infix)
Definition: CExpression.cpp:63
virtual bool compile()
bool isFixed() const
Definition: CModelValue.h:124
void setCompileFlag(bool flag=true)
Definition: CModel.cpp:607
CExpression * mpExpression
Definition: CModelValue.h:336
CModel * mpModel
Definition: CModelValue.h:359
bool CModelEntity::setExpressionPtr ( CExpression pExpression)

Set the expression for non FIXED model values

Parameters
CExpression*
Returns
bool success

Definition at line 255 of file CModelValue.cpp.

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

Referenced by SBMLImporter::importRuleForModelEntity().

256 {
257  if (isFixed()) return false;
258 
259  if (pExpression == mpExpression) return true;
260 
261  if (pExpression == NULL) return false;
262 
263  if (mpModel != NULL)
264  {
265  mpModel->setCompileFlag(true);
266  }
267 
268  CExpression * pOld = mpExpression;
269  mpExpression = pExpression;
270 
271  mpExpression->setObjectName("Expression");
272  add(mpExpression, true);
273 
274  if (compile())
275  {
276  pdelete(pOld);
277  return true;
278  }
279 
280  // If compile fails we do not take ownership
281  // and we remove the object from the container
282  remove(mpExpression);
284  mpExpression = pOld;
285 
286  return false;
287 }
virtual bool setObjectParent(const CCopasiContainer *pParent)
#define pdelete(p)
Definition: copasi.h:215
virtual bool compile()
bool isFixed() const
Definition: CModelValue.h:124
void setCompileFlag(bool flag=true)
Definition: CModel.cpp:607
CExpression * mpExpression
Definition: CModelValue.h:336
virtual bool add(CCopasiObject *pObject, const bool &adopt=true)
bool setObjectName(const std::string &name)
CModel * mpModel
Definition: CModelValue.h:359
bool CModelEntity::setInitialExpression ( const std::string &  expression)

Set the expression for ODE or REACTION model values

Parameters
conststd::string & expression
Returns
bool success

Definition at line 333 of file CModelValue.cpp.

References ASSIGNMENT, compile(), mpInitialExpression, mpModel, mStatus, CModel::setCompileFlag(), and CExpression::setInfix().

Referenced by CModel::convert2NonReversible(), CModelAdd::copyInitialExpression(), CModelExpansion::duplicateCompartment(), CModelExpansion::duplicateGlobalQuantity(), CModelExpansion::duplicateMetab(), CCopasiXMLParser::ModelElement::end(), CQSpeciesDetail::save(), CQCompartment::save(), CQModelValue::save(), CQMoietiesTaskResult::slotCreateGlobalQuantity(), and CModelParameter::updateModel().

334 {
335  if (mStatus == ASSIGNMENT) return false;
336 
337  if (mpModel)
338  mpModel->setCompileFlag(true);
339 
340  if (mpInitialExpression == NULL)
341  {
342  mpInitialExpression = new CExpression("InitialExpression", this);
343  }
344 
345  if (!mpInitialExpression->setInfix(expression)) return false;
346 
347  return compile();
348 }
virtual bool setInfix(const std::string &infix)
Definition: CExpression.cpp:63
CExpression * mpInitialExpression
Definition: CModelValue.h:341
virtual bool compile()
void setCompileFlag(bool flag=true)
Definition: CModel.cpp:607
Status mStatus
Definition: CModelValue.h:347
CModel * mpModel
Definition: CModelValue.h:359
bool CModelEntity::setInitialExpressionPtr ( CExpression pExpression)

Set the expression for non FIXED model values

Parameters
CExpression*
Returns
bool success

Definition at line 299 of file CModelValue.cpp.

References CCopasiContainer::add(), ASSIGNMENT, compile(), mpInitialExpression, mpModel, mStatus, pdelete, CModel::setCompileFlag(), CCopasiObject::setObjectName(), and CCopasiObject::setObjectParent().

Referenced by SBMLImporter::importInitialAssignments().

300 {
301  if (mStatus == ASSIGNMENT) return false;
302 
303  if (pExpression == mpInitialExpression) return true;
304 
305  if (pExpression == NULL) return false;
306 
307  if (mpModel != NULL)
308  {
309  mpModel->setCompileFlag(true);
310  }
311 
313  mpInitialExpression = pExpression;
314 
315  mpInitialExpression->setObjectName("InitialExpression");
316  add(mpInitialExpression, true);
317 
318  if (compile())
319  {
320  pdelete(pOld);
321  return true;
322  }
323 
324  // If compile fails we do not take ownership
325  // and we remove the object from the container
326  remove(mpInitialExpression);
328  mpInitialExpression = pOld;
329 
330  return false;
331 }
virtual bool setObjectParent(const CCopasiContainer *pParent)
#define pdelete(p)
Definition: copasi.h:215
CExpression * mpInitialExpression
Definition: CModelValue.h:341
virtual bool compile()
void setCompileFlag(bool flag=true)
Definition: CModel.cpp:607
Status mStatus
Definition: CModelValue.h:347
virtual bool add(CCopasiObject *pObject, const bool &adopt=true)
bool setObjectName(const std::string &name)
CModel * mpModel
Definition: CModelValue.h:359
void CModelEntity::setInitialValue ( const C_FLOAT64 initialValue)
virtual
void CModelEntity::setInitialValuePtr ( C_FLOAT64 pInitialValue)

Set the pointer to the initial value

Parameters
C_FLOAT64* pInitialValue

Definition at line 531 of file CModelValue.cpp.

References C_FLOAT64, mpIValue, mpIValueReference, and CCopasiObjectReference< CType >::setReference().

Referenced by CStateTemplate::add(), initObjects(), and CStateTemplate::remove().

532 {
533  mpIValue = pInitialValue;
534 
535  if (!mpIValue) mpIValue = new C_FLOAT64;
536 
538 }
CCopasiObjectReference< C_FLOAT64 > * mpIValueReference
Definition: CModelValue.h:356
C_FLOAT64 * mpIValue
Definition: CModelValue.h:326
virtual void setReference(referenceType &reference)
#define C_FLOAT64
Definition: copasi.h:92
bool CModelEntity::setObjectParent ( const CCopasiContainer pParent)
virtual

Set the object parent

Parameters
constCCopasiContainer * pParent
Returns
bool success

Reimplemented from CCopasiObject.

Reimplemented in CMetab.

Definition at line 549 of file CModelValue.cpp.

References CStateTemplate::add(), C_FLOAT64, CCopasiObject::getObjectAncestor(), CModel::getStateTemplate(), mpIValue, mpModel, mpValue, pdelete, CStateTemplate::remove(), and CCopasiObject::setObjectParent().

Referenced by CCopasiDataModel::commonAfterLoad(), and CMetab::setObjectParent().

550 {
552  CModel * pNewModel = static_cast<CModel *>(getObjectAncestor("Model"));
553 
554  if (mpModel == pNewModel) return true;
555 
556  C_FLOAT64 InitialValue = *mpIValue;
557  C_FLOAT64 Value = *mpValue;
558 
559  if (mpModel)
560  {
561  // This allocates new objects for mpIValue and mpValueData
563  }
564 
565  // We can safely remove the currently allocated objects as they
566  // are not part of an CStateTemplate
567  pdelete(mpIValue);
568  pdelete(mpValue);
569 
570  if (pNewModel)
571  {
572  pNewModel->getStateTemplate().add(this);
573  }
574  else
575  {
576  mpValue = new C_FLOAT64;
577  mpIValue = new C_FLOAT64;
578  }
579 
580  mpModel = pNewModel;
581  *mpIValue = InitialValue;
582  *mpValue = Value;
583 
584  return true;
585 }
virtual bool setObjectParent(const CCopasiContainer *pParent)
CCopasiContainer * getObjectAncestor(const std::string &type) const
void remove(CModelEntity *entity)
Definition: CState.cpp:80
#define pdelete(p)
Definition: copasi.h:215
void add(CModelEntity *entity)
Definition: CState.cpp:63
C_FLOAT64 * mpValue
Definition: CModelValue.h:321
C_FLOAT64 * mpIValue
Definition: CModelValue.h:326
#define C_FLOAT64
Definition: copasi.h:92
const CStateTemplate & getStateTemplate() const
Definition: CModel.cpp:1172
Definition: CModel.h:50
CModel * mpModel
Definition: CModelValue.h:359
void CModelEntity::setRate ( const C_FLOAT64 rate)

Set the rate (dmValue/dt)

Parameters
const C_FLOAT64 &rate

Definition at line 388 of file CModelValue.cpp.

References mRate.

389 {
390  mRate = rate;
391 }
C_FLOAT64 mRate
Definition: CModelValue.h:331
void CModelEntity::setSBMLId ( const std::string &  id)
void CModelEntity::setStatus ( const CModelEntity::Status status)
virtual

Set the status

Parameters
constCModelEntity::Status & status

Reimplemented in CMetab.

Definition at line 395 of file CModelValue.cpp.

References CCopasiContainer::add(), ASSIGNMENT, calculate(), CCopasiObject::clearRefresh(), CExpression::createInitialExpression(), FIXED, CCopasiObject::getDirectDependencies(), CCopasiObject::getObjectDataModel(), mpExpression, mpInitialExpression, mpIValueReference, mpModel, mpRateReference, mpValue, mpValueReference, mRate, mStatus, mUsed, ODE, pdelete, REACTIONS, CModel::setCompileFlag(), CCopasiObject::setDirectDependencies(), CCopasiObject::setObjectName(), CCopasiObject::setRefresh(), setValuePtr(), and TIME.

Referenced by CModelAdd::addCompartments(), CModelAdd::addModelValues(), CCompartment::CCompartment(), CModel::CModel(), CModelEntity(), CModelExpansion::duplicateCompartment(), CModelExpansion::duplicateGlobalQuantity(), SBMLImporter::importRuleForModelEntity(), CQCompartment::save(), CQModelValue::save(), CQGlobalQuantityDM::setData(), CQCompartmentDM::setData(), CMetab::setStatus(), test000058::test_bug1025_10(), test000058::test_bug1025_5(), test000059::test_unique_id_17(), test000059::test_unique_id_18(), test000059::test_unique_id_19(), test000059::test_unique_id_20(), test000059::test_unique_id_21(), and test000059::test_unique_id_21_2().

396 {
397  if (mStatus != status)
398  {
399  if (mpModel != NULL)
400  mpModel->setCompileFlag(true);
401 
402  // An assignment may not have an initial expression.
403  // However, internally we always create one, which need
404  // to be deleted.
405  if (mStatus == ASSIGNMENT)
407 
408  mStatus = status;
409  this->setValuePtr(mpValue);
410 
411  if (mpModel != NULL)
412  mpModel->setCompileFlag(true);
413 
414  std::set< const CCopasiObject * > NoDependencies;
415 
416  setDirectDependencies(NoDependencies);
417  clearRefresh();
418 
419  mpIValueReference->setDirectDependencies(NoDependencies);
420 
421  mpValueReference->setDirectDependencies(NoDependencies);
423 
424  mpRateReference->setDirectDependencies(NoDependencies);
426  CCopasiDataModel* pDataModel = NULL;
427 
428  switch (mStatus)
429  {
430  case ASSIGNMENT:
431 
432  if (mpExpression == NULL)
433  mpExpression = new CExpression("Expression", this);
434 
436  pDataModel = getObjectDataModel();
438  mpInitialExpression->setObjectName("InitialExpression");
439  add(mpInitialExpression, true);
440 
443 
444  mRate = std::numeric_limits<C_FLOAT64>::quiet_NaN();
445 
446  mUsed = true;
447  break;
448 
449  case ODE:
450 
451  if (mpExpression == NULL)
452  mpExpression = new CExpression("Expression", this);
453 
456 
457  mUsed = true;
458  break;
459 
460  case REACTIONS:
462 
463  mUsed = true;
464  break;
465 
466  case TIME:
468 
469  mUsed = true;
470  break;
471 
472  case FIXED:
474 
475  mRate = 0.0;
476 
477  mUsed = false;
478  break;
479  }
480  }
481 }
CCopasiDataModel * getObjectDataModel()
void setRefresh(CType *pType, void(CType::*method)(void))
#define pdelete(p)
Definition: copasi.h:215
CCopasiObjectReference< C_FLOAT64 > * mpIValueReference
Definition: CModelValue.h:356
CExpression * mpInitialExpression
Definition: CModelValue.h:341
C_FLOAT64 mRate
Definition: CModelValue.h:331
C_FLOAT64 * mpValue
Definition: CModelValue.h:321
void setDirectDependencies(const DataObjectSet &directDependencies)
CCopasiObjectReference< C_FLOAT64 > * mpRateReference
Definition: CModelValue.h:358
static CExpression * createInitialExpression(const CExpression &expression, const CCopasiDataModel *pDataModel)
void setValuePtr(C_FLOAT64 *pValue)
virtual void calculate()
CCopasiObjectReference< C_FLOAT64 > * mpValueReference
Definition: CModelValue.h:357
void setCompileFlag(bool flag=true)
Definition: CModel.cpp:607
virtual const DataObjectSet & getDirectDependencies(const DataObjectSet &context=DataObjectSet()) const
Status mStatus
Definition: CModelValue.h:347
CExpression * mpExpression
Definition: CModelValue.h:336
virtual bool add(CCopasiObject *pObject, const bool &adopt=true)
bool setObjectName(const std::string &name)
CModel * mpModel
Definition: CModelValue.h:359
void CModelEntity::setUsed ( const bool &  used)

Set whether the model entity is used during simulation

Parameters
constbool & used

Definition at line 642 of file CModelValue.cpp.

References mUsed.

Referenced by CModel::buildStateTemplate(), and CModel::CModel().

643 {mUsed = used;}
void CModelEntity::setValue ( const C_FLOAT64 value)
virtual

Set the value

Parameters
constC_FLOAT64 & value

Definition at line 378 of file CModelValue.cpp.

References mpValue.

Referenced by CHybridMethod::fireReaction(), CHybridMethodLSODA::fireReaction(), CHybridMethodODE45::fireReaction(), initObjects(), CQSpecieDM::setData(), and CStochMethod::updateSystemState().

379 {
380  *mpValue = value;
381 }
C_FLOAT64 * mpValue
Definition: CModelValue.h:321
void CModelEntity::setValuePtr ( C_FLOAT64 pValue)

Set the pointer to the value

Parameters
C_FLOAT64* pValue

Definition at line 540 of file CModelValue.cpp.

References C_FLOAT64, mpValue, mpValueReference, and CCopasiObjectReference< CType >::setReference().

Referenced by CStateTemplate::add(), initObjects(), CStateTemplate::remove(), and setStatus().

541 {
542  mpValue = pValue;
543 
544  if (!mpValue) mpValue = new C_FLOAT64;
545 
547 }
C_FLOAT64 * mpValue
Definition: CModelValue.h:321
CCopasiObjectReference< C_FLOAT64 > * mpValueReference
Definition: CModelValue.h:357
virtual void setReference(referenceType &reference)
#define C_FLOAT64
Definition: copasi.h:92

Member Data Documentation

CExpression* CModelEntity::mpExpression
protected

The infix expression for objects of type ASSIGNMENT or ODE

Definition at line 336 of file CModelValue.h.

Referenced by calculate(), CMetab::calculate(), compile(), CMetab::compile(), getExpression(), getExpressionPtr(), setExpression(), setExpressionPtr(), setStatus(), and CMetab::setStatus().

CExpression* CModelEntity::mpInitialExpression
protected
C_FLOAT64* CModelEntity::mpIValue
protected
CCopasiObjectReference<C_FLOAT64>* CModelEntity::mpIValueReference
protected
CModel* CModelEntity::mpModel
protected
CCopasiObjectReference<C_FLOAT64>* CModelEntity::mpRateReference
protected
C_FLOAT64* CModelEntity::mpValue
protected
CCopasiObjectReference<C_FLOAT64>* CModelEntity::mpValueReference
protected
C_FLOAT64 CModelEntity::mRate
protected
std::string CModelEntity::mSBMLId
protected

The id of the corresponding parameter in an SBML file. This value is either set upon importing an SBML file, or when the object is first exported to an SBML file.

Definition at line 47 of file CModelValue.h.

Referenced by getSBMLId(), initObjects(), and setSBMLId().

Status CModelEntity::mStatus
private
bool CModelEntity::mUsed
private

Indicates whether the model value is used, i.e., must be calculated during the simulation

Definition at line 353 of file CModelValue.h.

Referenced by isUsed(), setStatus(), and setUsed().

const std::string CModelEntity::StatusName
static
const char * CModelEntity::XMLStatus
static
Initial value:
=
{
"fixed",
"assignment",
"reactions",
"ode",
"time",
NULL
}

XML representation of the states

Definition at line 72 of file CModelValue.h.

Referenced by CCopasiXML::saveModel(), CCopasiXML::saveModelParameter(), CCopasiXMLParser::ModelParameterElement::start(), CCopasiXMLParser::MetaboliteElement::start(), CCopasiXMLParser::CompartmentElement::start(), and CCopasiXMLParser::ModelValueElement::start().


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