COPASI API  4.40.278
CFunction Class Reference

The class for handling a chemical kinetic function. More...

#include <CFunction.h>

Inheritance diagram for CFunction:
[legend]

Public Member Functions

bool addVariable (const std::string &name, CFunctionParameter::Role usage=CFunctionParameter::Role::VARIABLE, const CFunctionParameter::DataType &type=CFunctionParameter::DataType::FLOAT64)
 
virtual bool applyData (const CData &data, CUndoData::CChangeSet &changes)
 
virtual const C_FLOAT64calcValue (const CCallParameters< C_FLOAT64 > &callParameters)
 
 CFunction (const CFunction &src, const CDataContainer *pParent)
 
 CFunction (const std::string &name="NoName", const CDataContainer *pParent=NO_PARENT, const Type &type=Function)
 
CFunctioncreateCopy () const
 
void createListOfParametersForMathML (std::vector< std::vector< std::string > > &env)
 
virtual void createUndoData (CUndoData &undoData, const CUndoData::Type &type, const CData &oldData=CData(), const CCore::Framework &framework=CCore::Framework::ParticleNumbers) const
 
const std::string & getKey () const
 
const std::string & getSBMLId () const
 
virtual size_t getVariableIndex (const std::string &name) const
 
CFunctionParametersgetVariables ()
 
const CFunctionParametersgetVariables () const
 
virtual const C_FLOAT64getVariableValue (const size_t &index) const
 
virtual bool isReadOnly () const
 
const TriLogicisReversible () const
 
bool isSuitable (const size_t noSubstrates, const size_t noProducts, const TriLogic reversible)
 
virtual void load (CReadConfig &configBuffer, CReadConfig::Mode mode=CReadConfig::SEARCH)
 
bool operator== (const CFunction &rhs) const
 
virtual CIssue setInfix (const std::string &infix)
 
void setReversible (const TriLogic &reversible)
 
void setSBMLId (const std::string &id)
 
std::pair< CFunction *, CFunction * > splitFunction (const CEvaluationNode *node, const std::string &name1, const std::string &name2) const
 
virtual CData toData () const
 
virtual std::string writeMathML (const std::vector< std::vector< std::string > > &variables, bool expand=true, bool fullExpand=true) const
 
virtual void writeMathML (std::ostream &out, size_t l=0) const
 
virtual ~CFunction ()
 
- Public Member Functions inherited from CEvaluationTree
bool calls (std::set< std::string > &list) const
 
 CEvaluationTree (const CEvaluationTree &src, const CDataContainer *pParent)
 
 CEvaluationTree (const std::string &name="NoName", const CDataContainer *pParent=NO_PARENT, const Type &type=Function)
 
virtual CIssue compile ()
 
bool containsCN (const DataObjectSet &elements) const
 
std::string::size_type getErrorPosition () const
 
const std::string & getInfix () const
 
const std::vector< CEvaluationNode * > & getNodeList () const
 
virtual const CObjectInterfacegetNodeObject (const CCommonName &CN) const
 
CEvaluationNodegetRoot ()
 
const CEvaluationNodegetRoot () const
 
const CEvaluationTree::TypegetType () const
 
bool hasCircularDependency () const
 
bool hasDiscontinuity () const
 
bool isBoolean () const
 
bool mapObjectNodes (const CDataContainer *pSrc, const CDataContainer *pTarget)
 
bool operator== (const CEvaluationTree &rhs) const
 
virtual bool setRoot (CEvaluationNode *pRootNode)
 
bool setTree (const ASTNode &pRootNode, bool isFunction)
 
size_t size () const
 
virtual ASTNode * toAST (const CDataModel *pDataModel) const
 
CIssue updateTree ()
 
virtual ~CEvaluationTree ()
 
- Public Member Functions inherited from CDataContainer
virtual bool add (CDataObject *pObject, const bool &adopt=true)
 
virtual bool appendDeletedDependentData (CUndoData &undoData) const
 
 CDataContainer (const CDataContainer &src, const CDataContainer *pParent)
 
 CDataContainer (const std::string &name, const CDataContainer *pParent=NO_PARENT, const std::string &type="CN", const CFlags< Flag > &flag=CFlags< Flag >::None)
 
virtual std::string getChildObjectUnits (const CDataObject *pObject) const
 
void getDescendants (CDataObject::DataObjectSet &descendants, const bool &recursive=false) const
 
virtual size_t getIndex (const CDataObject *pObject) const
 
virtual const CObjectInterfacegetObject (const CCommonName &cn) const override
 
virtual objectMapgetObjects ()
 
virtual const objectMapgetObjects () const
 
virtual const std::string getUnits () const override
 
virtual const CDataObjectgetValueObject () const override
 
virtual CUndoObjectInterfaceinsert (const CData &data) override
 
void objectRenamed (CDataObject *pObject, const std::string &oldName)
 
virtual bool remove (CDataObject *pObject)
 
virtual ~CDataContainer ()
 
- Public Member Functions inherited from CDataObject
void addIssue (const CIssue &issue)
 
void addReference (const CDataContainer *pReference)
 
virtual void calculateValue () override
 
 CDataObject (const CDataObject &src, const CDataContainer *pParent=NULL)
 
virtual void destruct () override
 
virtual CCommonName getCN () const override
 
virtual const CDataObjectgetDataObject () const override
 
CDataContainergetObjectAncestor (const std::string &type) const
 
CDataModelgetObjectDataModel () const
 
virtual std::string getObjectDisplayName () const override
 
const CObjectInterfacegetObjectFromCN (const CCommonName &cn) const
 
const std::string & getObjectName () const
 
CDataContainergetObjectParent () const
 
const std::string & getObjectType () const
 
virtual const CObjectInterface::ObjectSetgetPrerequisites () const override
 
virtual const CValiditygetValidity () const override
 
virtual void * getValuePointer () const override
 
bool hasFlag (const Flag &flag) const
 
virtual bool isPrerequisiteForContext (const CObjectInterface *pObject, const CCore::SimulationContextFlag &context, const CObjectInterface::ObjectSet &changedObjects) const override
 
bool prerequisitsContains (const DataObjectSet &objects) const
 
virtual void print (std::ostream *ostream) const override
 
void removeIssue (const CIssue &issue)
 
void removeReference (const CDataContainer *pReference)
 
bool setObjectName (const std::string &name)
 
virtual bool setObjectParent (const CDataContainer *pParent)
 
void validityChanged (const CValidity &changedValidity) override
 
void validityRemoved (const CValidity &changedValidity)
 
virtual ~CDataObject ()
 
- Public Member Functions inherited from CObjectInterface
 CObjectInterface ()
 
 CObjectInterface (const CObjectInterface &src)
 
virtual ~CObjectInterface ()
 
- Public Member Functions inherited from CUndoObjectInterface
 CUndoObjectInterface ()
 
 CUndoObjectInterface (const CUndoObjectInterface &src)
 
bool generateUuid ()
 
const xg::Guid & getUuid () const
 
bool setUuid (const std::string &uuid)
 
bool setUuid (const xg::Guid &uuid)
 
virtual void updateIndex (const size_t &index, const CUndoObjectInterface *pUndoObject)
 
virtual ~CUndoObjectInterface ()
 
- Public Member Functions inherited from CAnnotation
bool addUnsupportedAnnotation (const std::string &name, const std::string &xml)
 
bool applyData (const CData &data, CUndoData::CChangeSet &changes)
 
 CAnnotation ()
 
 CAnnotation (const CAnnotation &src)
 
void createUndoData (CUndoData &undoData, const CUndoData::Type &type, const CData &oldData=CData(), const CCore::Framework &framework=CCore::Framework::ParticleNumbers) const
 
const std::string & getMiriamAnnotation () const
 
const std::string & getNotes () const
 
UnsupportedAnnotationgetUnsupportedAnnotations ()
 
const UnsupportedAnnotationgetUnsupportedAnnotations () const
 
void initMiriamAnnotation (const std::string &newId)
 
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)
 
CData toData () const
 
virtual ~CAnnotation ()
 

Static Public Member Functions

static bool completeFunctionList (std::vector< const CFunction * > &list, const size_t &added=0)
 
static CFunctionfromData (const CData &data, CUndoObjectInterface *pParent)
 
- Static Public Member Functions inherited from CEvaluationTree
static CEvaluationTreecopy (const CEvaluationTree &src)
 
static CEvaluationTreecreate (CEvaluationTree::Type type)
 
static CEvaluationNodefromAST (const ASTNode *pASTNode, bool isFunction)
 
static CEvaluationTreefromData (const CData &data, CUndoObjectInterface *pParent)
 
- Static Public Member Functions inherited from CDataContainer
static CDataContainerfromData (const CData &data, CUndoObjectInterface *pParent)
 
- Static Public Member Functions inherited from CDataObject
static CDataObjectfromData (const CData &data, CUndoObjectInterface *pParent)
 
static void sanitizeObjectName (std::string &name)
 
- Static Public Member Functions inherited from CObjectInterface
static const CDataObjectDataObject (const CObjectInterface *pInterface)
 
static CObjectInterfaceGetObjectFromCN (const ContainerList &listOfContainer, const CCommonName &objName)
 
- Static Public Member Functions inherited from CUndoObjectInterface
template<class CType >
static CType * fromData (const CData &, CUndoObjectInterface *)
 
- Static Public Member Functions inherited from CAnnotation
static CMIRIAMInfoallocateMiriamInfo (CDataContainer *pParent)
 
static CAnnotationcastObject (CDataObject *pObject)
 
static const CAnnotationcastObject (const CDataObject *pObject)
 
static void freeMiriamInfo (CDataContainer *pParent)
 

Protected Member Functions

 CFunction (const CFunction &src)
 
CIssue initVariables ()
 
- Protected Member Functions inherited from CEvaluationTree
void buildCalculationSequence ()
 
void calculate ()
 
 CEvaluationTree (const CEvaluationTree &src)
 
void clearNodes ()
 
CIssue compileNodes ()
 
CIssue parse ()
 
void setType (const CEvaluationTree::Type &type)
 
- Protected Member Functions inherited from CDataContainer
template<class CType >
CDataMatrixReference< CType > * addMatrixReference (const std::string &name, CType &reference, const CFlags< Flag > &flag=CFlags< Flag >::None)
 
template<class CType >
CDataObjectReference< CType > * addObjectReference (const std::string &name, CType &reference, const CFlags< Flag > &flag=CFlags< Flag >::None)
 
template<class CType >
CDataVectorReference< CType > * addVectorReference (const std::string &name, CType &reference, const CFlags< Flag > &flag=CFlags< Flag >::None)
 
 CDataContainer (const CDataContainer &src)
 
void initObjects ()
 
- Protected Member Functions inherited from CDataObject
 CDataObject ()
 
 CDataObject (const std::string &name, const CDataContainer *pParent=static_cast< CDataContainer * >((void *) 0), const std::string &type="CN", const CFlags< Flag > &flag=CFlags< Flag >::None)
 

Private Attributes

CCallParameters< C_FLOAT64 >::const_iterator mCallParametersBegin
 
TriLogic mReversible
 
std::string mSBMLId
 
CFunctionParameters mVariables
 

Friends

std::ostream & operator<< (std::ostream &os, const CFunction &f)
 

Additional Inherited Members

- Public Types inherited from CEvaluationTree
enum  Type {
  Function = 0 , MassAction , PreDefined , UserDefined ,
  Expression , MathExpression
}
 
- Public Types inherited from CDataContainer
typedef CDataObjectMap objectMap
 
- Public Types inherited from CDataObject
typedef std::set< const CDataObject * > DataObjectSet
 
enum  Flag {
  Container , Vector , Matrix , NameVector ,
  Reference , ValueBool , ValueInt , ValueInt64 ,
  ValueDbl , NonUniqueName , StaticString , ValueString ,
  Separator , DisplayName , ModelEntity , Array ,
  DataModel , Root , Gui , __SIZE
}
 
- Public Types inherited from CObjectInterface
typedef std::vector< const CDataContainer * > ContainerList
 
typedef std::set< const CObjectInterface * > ObjectSet
 
- Public Types inherited from CAnnotation
typedef std::map< std::string, std::string > UnsupportedAnnotation
 
- Static Public Attributes inherited from CEvaluationTree
static const std::string TypeName []
 
static const char * XMLType []
 
- Static Public Attributes inherited from CDataContainer
static const CObjectInterface::ContainerList EmptyList
 
- Protected Attributes inherited from CEvaluationTree
CVector< CEvaluationNode * > mCalculationSequence
 
std::string mInfix
 
std::vector< CEvaluationNode * > * mpNodeList
 
const C_FLOAT64mpRootValue
 
CEvaluationTree::Type mType
 
C_FLOAT64 mValue
 
- Protected Attributes inherited from CDataContainer
objectMap mObjects
 
- Protected Attributes inherited from CDataObject
ObjectSet mPrerequisits
 
std::set< CDataContainer * > mReferences
 
- Protected Attributes inherited from CObjectInterface
CValidity mValidity
 
- Protected Attributes inherited from CAnnotation
std::string mKey
 

Detailed Description

The class for handling a chemical kinetic function.

This class is designed to handle all about a given chemical kinetic function from editing and displaying (with help of MathML) the function to calculating the function value.

Constructor & Destructor Documentation

◆ CFunction() [1/3]

CFunction::CFunction ( const CFunction src)
protected

Referenced by createCopy(), and splitFunction().

◆ CFunction() [2/3]

CFunction::CFunction ( const std::string &  name = "NoName",
const CDataContainer pParent = NO_PARENT,
const Type type = Function 
)

Default constructor

Parameters
conststd::string & name (default: "NoName")
constCEvaluationTree::Type & type (default: Function)
constCDataContainer * pParent (default: NULL)

References CKeyFactory::add(), CRootContainer::getKeyFactory(), CAnnotation::initMiriamAnnotation(), and CAnnotation::mKey.

◆ CFunction() [3/3]

CFunction::CFunction ( const CFunction src,
const CDataContainer pParent 
)

◆ ~CFunction()

CFunction::~CFunction ( )
virtual

Member Function Documentation

◆ addVariable()

bool CFunction::addVariable ( const std::string &  name,
CFunctionParameter::Role  usage = CFunctionParameter::Role::VARIABLE,
const CFunctionParameter::DataType type = CFunctionParameter::DataType::FLOAT64 
)

Function to add the description of a variable.

Parameters
conststring & name
conststring & usage (Default: VARIABLE)
constCFunctionParameters::DataType & type (Default: value)
Returns
bool success

References CFunctionParameters::add(), and mVariables.

Referenced by SBMLImporter::createCFunctionFromFunctionTree(), and CReaction::setFunctionFromExpressionTree().

◆ applyData()

bool CFunction::applyData ( const CData data,
CUndoData::CChangeSet changes 
)
virtual

Apply the provided data to the object

Parameters
constCData & data
Returns
bool success

Reimplemented from CEvaluationTree.

References CEvaluationTree::applyData(), and CAnnotation::applyData().

◆ calcValue()

const C_FLOAT64 & CFunction::calcValue ( const CCallParameters< C_FLOAT64 > &  callParameters)
virtual

Function to calculate the value of the function

Parameters
constCCallParameters<C_FLOAT64> & callParameters
Returns
const C_FLOAT64 & result

Reimplemented in CMassAction.

References CCallParameters< Type >::begin(), CEvaluationTree::calculate(), mCallParametersBegin, and CEvaluationTree::mValue.

Referenced by CEvaluationNodeCall::calculate().

◆ completeFunctionList()

bool CFunction::completeFunctionList ( std::vector< const CFunction * > &  list,
const size_t &  added = 0 
)
static

Complete the list of evaluation tree such that all called trees are includes.

Parameters
std::vector<const CFunction * > & list
constsize_t & added (Default: list.size())
Returns
bool success

References C_INVALID_INDEX, CEvaluationNode::CALL, CRootContainer::getFunctionList(), CDataVectorN< CType >::getIndex(), CEvaluationTree::getNodeList(), and CFunctionDB::loadedFunctions().

Referenced by CFunctionDB::getUsedFunctions().

◆ createCopy()

CFunction * CFunction::createCopy ( ) const

Function to duplicate itself

References CFunction(), CEvaluationTree::getRoot(), mReversible, and CEvaluationTree::setRoot().

◆ createListOfParametersForMathML()

void CFunction::createListOfParametersForMathML ( std::vector< std::vector< std::string > > &  env)

Function to create a list of the names of the function parameters in MathML format. This list can be passed as the env argument to the writeMathML() method.

Parameters
std::vector<std::vector<std::string>> & env

References CMathMl::fixName(), CDataObject::getObjectName(), getVariables(), and CFunctionParameters::size().

◆ createUndoData()

void CFunction::createUndoData ( CUndoData undoData,
const CUndoData::Type type,
const CData oldData = CData(),
const CCore::Framework framework = CCore::Framework::ParticleNumbers 
) const
virtual

Create the undo data which represents the changes recording the differences between the provided oldData and the current data.

Parameters
CUndoData& undoData
constCUndoData::Type & type
constCData & oldData (default: empty data)
constCCore::Framework & framework (default: CCore::Framework::ParticleNumbers)
Returns
CUndoData undoData

Reimplemented from CDataContainer.

References CUndoData::CHANGE, CAnnotation::createUndoData(), and CDataContainer::createUndoData().

◆ fromData()

CFunction * CFunction::fromData ( const CData data,
CUndoObjectInterface pParent 
)
static

Static method to create a CDataObject based on the provided data

Parameters
constCData & data
Returns
CFunction * pDataObject

References CEvaluationTree::fromData(), and pdelete.

◆ getKey()

◆ getSBMLId()

◆ getVariableIndex()

size_t CFunction::getVariableIndex ( const std::string &  name) const
virtual

Function to retrieve the index to the value of the named variable.

Parameters
conststd::string & name
Returns
size_t index

Reimplemented from CEvaluationTree.

References CFunctionParameters::findParameterByName(), and mVariables.

Referenced by CODEExporter::exportKineticFunction(), and CODEExporter::exportSingleFunction().

◆ getVariables() [1/2]

◆ getVariables() [2/2]

const CFunctionParameters & CFunction::getVariables ( ) const

Function to retrive the definition of the parameters

Returns
const CFunctionParameters & variables

References mVariables.

◆ getVariableValue()

const C_FLOAT64 & CFunction::getVariableValue ( const size_t &  index) const
virtual

Function to retrieve the value of the indexed variable.

Note this function is only usable during calcValue, since the values of the call parameters are only defined during that time.

Parameters
constsize_t & index
Returns
const C_FLOAT64 & variableValue

Reimplemented from CEvaluationTree.

References mCallParametersBegin.

◆ initVariables()

◆ isReadOnly()

bool CFunction::isReadOnly ( ) const
virtual

Check whether a function is read only

Returns
bool isReadOnly

References CEvaluationTree::MassAction, CEvaluationTree::mType, and CEvaluationTree::PreDefined.

◆ isReversible()

◆ isSuitable()

bool CFunction::isSuitable ( const size_t  noSubstrates,
const size_t  noProducts,
const TriLogic  reversible 
)

◆ load()

void CFunction::load ( CReadConfig configBuffer,
CReadConfig::Mode  mode = CReadConfig::SEARCH 
)
virtual

Function to load an object with data coming from a CReadConfig object. (CReadConfig object reads an input stream)

Parameters
CReadConfig &configBuffer
CReadConfig::Modemode (default: CReadConfig::SEARCH)
Returns
Fail

References C_INT32, fatalError, CReadConfig::getVariable(), mReversible, CReadConfig::SEARCH, setInfix(), CDataObject::setObjectName(), CEvaluationTree::setType(), and CEvaluationTree::UserDefined.

Referenced by CFunctionDB::load().

◆ operator==()

bool CFunction::operator== ( const CFunction rhs) const

Comparison operator

Parameters
constCFunction & rhs
Returns
bool equal

References mVariables.

◆ setInfix()

◆ setReversible()

void CFunction::setReversible ( const TriLogic reversible)

◆ setSBMLId()

◆ splitFunction()

◆ toData()

CData CFunction::toData ( ) const
virtual

Retrieve the data describing the object

Returns
CData data

Reimplemented from CEvaluationTree.

References CData::appendData(), CEvaluationTree::toData(), and CAnnotation::toData().

◆ writeMathML() [1/2]

std::string CFunction::writeMathML ( const std::vector< std::vector< std::string > > &  variables,
bool  expand = true,
bool  fullExpand = true 
) const
virtual

Function to write the mathematical formula in format of MathML.

Parameters
std::ostream& out
conststd::vector< std::vector< std::string > > & variables
boolexpand = true
boolfullExpand
Returns
std::string

Reimplemented in CMassAction.

References CEvaluationNode::buildMMLString(), CMathMl::fixName(), CDataObject::getObjectName(), and CEvaluationTree::getRoot().

◆ writeMathML() [2/2]

void CFunction::writeMathML ( std::ostream &  out,
size_t  l = 0 
) const
virtual

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Parameters
std::ostream& out
size_tl

References CMathMl::fixName(), CDataObject::getObjectName(), getVariables(), CFunctionParameters::size(), and SPC.

Referenced by CEvaluationNodeCall::getMMLString(), and CMMLOutput::writeRHS().

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const CFunction f 
)
friend

Insert operator

Member Data Documentation

◆ mCallParametersBegin

CCallParameters< C_FLOAT64 >::const_iterator CFunction::mCallParametersBegin
private

A pointer to the call parameters during calculation.

Referenced by calcValue(), and getVariableValue().

◆ mReversible

TriLogic CFunction::mReversible
private

Whether the function is reversible

Referenced by createCopy(), isReversible(), load(), setReversible(), and splitFunction().

◆ mSBMLId

std::string CFunction::mSBMLId
private

The id of the corresponding function 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.

Referenced by getSBMLId(), and setSBMLId().

◆ mVariables

CFunctionParameters CFunction::mVariables
private

The description of the variables of the function. It describes which variables need to be passed to the function for evaluation and its eventual type.

Referenced by addVariable(), getVariableIndex(), getVariables(), initVariables(), isSuitable(), operator==(), and splitFunction().


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