COPASI API  4.16.103
CFunctionDB.h
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2013 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 // Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual
7 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
8 // and The University of Manchester.
9 // All rights reserved.
10 
11 // Copyright (C) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
12 // Properties, Inc. and EML Research, gGmbH.
13 // All rights reserved.
14 
15 /**
16  * CFunctionDB
17  *
18  * Created for Copasi by Stefan Hoops
19  * (C) Stefan Hoops 2001
20  */
21 
22 #ifndef COPASI_CFunctionDB
23 #define COPASI_CFunctionDB
24 
26 
29 #include "utilities/CReadConfig.h"
31 
32 class CFunction;
33 class CModel;
34 
35 /** @dia:pos 106.082,17.0878 */
36 class CFunctionDB : public CCopasiContainer
37 {
38  // Attributes
39 private:
40  /**
41  * Filename which contains the function database
42  */
43  std::string mFilename;
44 
45  /**
46  * Vector of the currently loaded functions
47  */
49 
50  // Operations
51 
52 public:
53  /**
54  * Default constructor
55  * @param const std::string & name (default: "NoName")
56  * @param const CCopasiContainer * pParent (default: NULL)
57  */
58  //CFunctionDB(const std::string & name = "FunctionDB",
59  // const CCopasiContainer * pParent = NULL);
60  CFunctionDB(const std::string & name,
61  const CCopasiContainer * pParent);
62 
63  /**
64  * Destructor
65  */
66  virtual ~CFunctionDB();
67 
68  /**
69  *
70  */
71  void cleanup();
72 
73  void initObjects();
74 
75  bool load();
76 
77  bool load(const std::string& fileName);
78  bool save(const std::string& fileName);
79 
80  /**
81  * Loads an object with data coming from a CReadConfig object.
82  * (CReadConfig object reads an input stream)
83  * @param pconfigbuffer reference to a CReadConfig object.
84  * @return mFail
85  */
86  C_INT32 load(CReadConfig & configbuffer);
87 
88  /**
89  *
90  */
91  void setFilename(const std::string & filename);
92 
93  /**
94  *
95  */
96  std::string getFilename() const;
97 
98 #ifdef FFFF
99  /**
100  * Load the function functionName from the database
101  * @param "const string" &functionName
102  * @return CEvaluationTree * function (NULL if function can not be loaded)
103  */
104  CEvaluationTree * dBLoad(const std::string & functionName);
105 #endif // FFFF
106 
107  /**
108  * Add the function to the database
109  * @param CFunction * pFunction
110  * @param const bool & adopt (default = false)
111  * @return bool success
112  */
113  bool add(CFunction * pFunction, const bool & adopt);
114 
115  /**
116  * Add the function to the database, if necessary adapt the name so it
117  * is unique.
118  */
119  CFunction * addAndAdaptName(CFunction * pFunction);
120 
121 #ifdef FFFF
122  /**
123  * Add the function to the database
124  * @param const std::string & name
125  * @param const CEvaluationTree::Type & type (Default: CEvaluationTree::Base)
126  * @return bool success
127  */
128  CEvaluationTree* createFunction(const std::string &name, const CEvaluationTree::Type & type = CEvaluationTree::Function);
129 #endif // FFFF
130 
131  bool removeFunction(size_t index);
132 
133  bool removeFunction(const std::string &key);
134 
135  /**
136  * Delete the function functionName from the database
137  * @param "const string" &functionName
138  * @return C_INT32 Fail
139  */
140  //void dBDelete(const std::string & functionName);
141 
142  /**
143  * Search for a function among the loaded functions. If no
144  * function is found NULL is returned
145  * @param "const string" &functionName
146  * @return CFunction *
147  */
148  CFunction * findFunction(const std::string & functionName);
149 
150  /**
151  * Search for a function among the loaded functions. If no
152  * function is found the database is searched and the apropriate
153  * function is loaded.
154  * @param "const string" &functionName
155  * @return CFunction * function (NULL if function is not found)
156  */
157  CFunction * findLoadFunction(const std::string & functionName);
158 
159  /**
160  * Retrieves the vector of loaded functions.
161  * @return "CCopasiVectorNS < CFunction > &" loadedFunctions
162  */
164 
165  /**
166  * Retrieves the vector of functions that are suitable for a
167  * number of substrates, products and reversibility status.
168  * Note: The returns CCopasiVector has to be deleted after use!
169  * @param "const size_t" noSubstrates the number of substrates
170  * @param "const size_t" noProducts the number of products
171  * @param "const TriLogic" reversible the reversibility status
172  * @return "std::vector<CFunction*> " suitableFunctions
173  */
174  std::vector<CFunction*>
175  suitableFunctions(const size_t noSubstrates,
176  const size_t noProducts,
177  const TriLogic reversibility);
178 
179  /**
180  * Appends pointers to function, which are dependent on any of the candidates
181  * to the list dependentFunctions.
182  * @param std::set< const CCopasiObject * > candidates
183  * @param std::set< const CCopasiObject * > & dependentFunctions
184  * @return bool functionsAppended
185  */
186  bool appendDependentFunctions(std::set< const CCopasiObject * > candidates,
187  std::set< const CCopasiObject * > & dependentFunctions) const;
188 
189  /**
190  * Retrieve a list of evaluation trees depending on the tree with the
191  * given name.
192  * @param const std::string & name
193  * @return std::set<std::string> list
194  */
195  std::set<std::string> listDependentTrees(const std::string & name) const;
196 
197  /**
198  * Retrieves a list of all functions used in the model
199  * @return std::vector< CEvaluationTree * > usedFunctions
200  */
201  std::vector< CFunction * > getUsedFunctions(const CModel* pModel) const;
202 };
203 
204 #endif // COPASI_CFunctionDB
std::string mFilename
Definition: CFunctionDB.h:42
CCopasiVectorN< CFunction > mLoadedFunctions
Definition: CFunctionDB.h:47
CCopasiVectorN< CFunction > & loadedFunctions()
CFunction * addAndAdaptName(CFunction *pFunction)
std::vector< CFunction * > suitableFunctions(const size_t noSubstrates, const size_t noProducts, const TriLogic reversibility)
virtual ~CFunctionDB()
Definition: CFunctionDB.cpp:46
TriLogic
Definition: copasi.h:125
std::vector< CFunction * > getUsedFunctions(const CModel *pModel) const
#define C_INT32
Definition: copasi.h:90
CFunction * findLoadFunction(const std::string &functionName)
void initObjects()
Definition: CFunctionDB.cpp:54
void cleanup()
Definition: CFunctionDB.cpp:52
std::set< std::string > listDependentTrees(const std::string &name) const
CFunctionDB(const std::string &name, const CCopasiContainer *pParent)
Definition: CFunctionDB.cpp:36
void setFilename(const std::string &filename)
bool appendDependentFunctions(std::set< const CCopasiObject * > candidates, std::set< const CCopasiObject * > &dependentFunctions) const
Header file of class CCopasiContainer.
bool save(const std::string &fileName)
Definition: CFunctionDB.cpp:91
bool removeFunction(size_t index)
std::string getFilename() const
The class for handling a chemical kinetic function.
Definition: CFunction.h:29
Definition: CModel.h:50
CFunction * findFunction(const std::string &functionName)
CNormalFunction * createFunction(const CEvaluationNode *node)
bool add(CFunction *pFunction, const bool &adopt)