COPASI API  4.16.103
CFunctionParameter.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/function/CFunctionParameter.cpp,v $
3 // $Revision: 1.37 $
4 // $Name: $
5 // $Author: ssahle $
6 // $Date: 2009/04/24 12:44:38 $
7 // End CVS Header
8 
9 // Copyright (C) 2008 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
11 // and The University of Manchester.
12 // All rights reserved.
13 
14 // Copyright (C) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
15 // Properties, Inc. and EML Research, gGmbH.
16 // All rights reserved.
17 
18 /**
19  * CFunctionParameter
20  *
21  * Created for COPASI by Stefan Hoops
22  * (C) Stefan Hoops 2001
23  */
24 
25 #include "copasi.h"
26 #include "CFunctionParameter.h"
27 #include "report/CKeyFactory.h"
29 
30 //static
31 const std::string CFunctionParameter::DataTypeName[] =
32  {"Integer", "Double", "Vector of Integer", "Vector of Double", ""};
33 
34 //static
35 const std::string CFunctionParameter::RoleNameXML[] =
36  {"substrate", "product", "modifier", "constant", "volume", "time", "variable", ""};
37 
38 //static
39 const std::string CFunctionParameter::RoleNameDisplay[] =
40  {"Substrate", "Product", "Modifier", "Parameter", "Volume", "Time", "Variable", ""};
41 
42 //static
44 {
45  C_INT32 i;
46 
47  for (i = 0; (RoleNameXML[i] != "") && (RoleNameXML[i] != xmlrole); ++i) {};
48 
49  if (RoleNameXML[i] == "")
50  return VARIABLE; //default for invalid XML string
51  else
52  return (Role)i;
53 }
54 
55 CFunctionParameter::CFunctionParameter(const std::string & name,
56  const CCopasiContainer * pParent):
57  CCopasiContainer(name, pParent, "Variable"),
58  mKey(CCopasiRootContainer::getKeyFactory()->add("FunctionParameter", this)),
59  mType((CFunctionParameter::DataType) - 1),
60  mUsage(VARIABLE),
61  mIsUsed(true)
63 
65  const CCopasiContainer * pParent):
66  CCopasiContainer(src, pParent),
67  mKey(CCopasiRootContainer::getKeyFactory()->add("FunctionParameter", this)),
68  mType(src.mType),
69  mUsage(src.mUsage),
70  mIsUsed(src.mIsUsed)
72 
73 CFunctionParameter::CFunctionParameter(const std::string &name,
74  const enum CFunctionParameter::DataType &type,
75  Role usage,
76  const CCopasiContainer * pParent):
77  CCopasiContainer(name, pParent, "Variable"),
78  mKey(CCopasiRootContainer::getKeyFactory()->add("FunctionParameter", this)),
79  mType(type),
80  mUsage(usage),
81  mIsUsed(true)
83 
85 {
88 }
89 
91 
93  CReadConfig::Mode mode)
94 {
95  std::string tmp;
96  configbuffer.getVariable("FunctionParameter", "string", &tmp, mode);
97  setObjectName(tmp);
98  configbuffer.getVariable("DataType", "C_INT32", &mType);
99  configbuffer.getVariable("Usage", "string", &mUsage);
100 }
101 
102 const std::string & CFunctionParameter::getKey() const {return mKey;}
103 
105 
107 
109 {mType = type;}
110 
112 
114 {
115  return mType;
116 }
117 
118 void CFunctionParameter::setIsUsed(const bool & isUsed)
119 {mIsUsed = isUsed;}
120 
121 /**
122  * Retrieve whether the parameter is used within a function
123  * @return const bool & isUsed
124  */
125 const bool & CFunctionParameter::isUsed() const
126 {return mIsUsed;}
127 
128 std::ostream& operator<<(std::ostream &os, const CFunctionParameter & d)
129 {
130  //os << "CFunctionParameter: "
131  os << d.getObjectName();
132 
133  if (d.mType != 1) os << " mType " << d.mType;
134 
135  os << " [" << CFunctionParameter::RoleNameDisplay[d.mUsage] << "]";
136 
137  return os;
138 }
bool remove(const std::string &key)
const CFunctionParameter::DataType & getType() const
void setIsUsed(const bool &isUsed)
static const std::string DataTypeName[]
void setUsage(Role usage)
const std::string & getObjectName() const
virtual const std::string & getKey() const
void setType(const CFunctionParameter::DataType &type)
CFunctionParameter::DataType mType
CFunctionParameter(const std::string &name="NoName", const CCopasiContainer *pParent=NULL)
#define C_INT32
Definition: copasi.h:90
static const std::string RoleNameXML[]
#define DESTRUCTOR_TRACE
Definition: copasi.h:206
static Role xmlRole2Enum(const std::string &role)
static CKeyFactory * getKeyFactory()
std::ostream & operator<<(std::ostream &os, const CFunctionParameter &d)
static const std::string RoleNameDisplay[]
C_INT32 getVariable(const std::string &name, const std::string &type, void *pout, CReadConfig::Mode mode=CReadConfig::NEXT)
Definition: CReadConfig.cpp:81
bool setObjectName(const std::string &name)
const bool & isUsed() const
#define CONSTRUCTOR_TRACE
Definition: copasi.h:202
virtual void load(CReadConfig &configbuffer, CReadConfig::Mode mode=CReadConfig::NEXT)