COPASI API  4.16.103
CMIRIAMResource.h
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2015 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 /**
12  * CMIRIAMResource class.
13  * This class is used to describe parameters. This class is C_INT32ended
14  * to be used with C_INT32egration or optimization methods or reactions.
15  *
16  * Created for COPASI by Anton Ruff 2008
17  */
18 
19 #ifndef COPASI_CMIRIAMResource
20 #define COPASI_CMIRIAMResource
21 
24 #include <time.h>
25 #include <string>
27 #include "utilities/utility.h"
28 
29 class CProcessReport;
30 
32 
34 {
35  //Operations
36 public:
37  /**
38  * Default constructor
39  * @param const std::string & name (default: MIRIAM Resource)
40  * @param const CCopasiContainer * pParent (default: NULL)
41  */
42  CMIRIAMResource(const std::string & name = "MIRIAM Resource",
43  const CCopasiContainer * pParent = NULL);
44 
45  /**
46  * Copy constructor
47  * @param const CMIRIAMResource & src
48  * @param const CCopasiContainer * pParent (default: NULL)
49  */
50  CMIRIAMResource(const CMIRIAMResource & src,
51  const CCopasiContainer * pParent = NULL);
52  /**
53  * Specific constructor
54  * @param const CCopasiParameterGroup & group
55  * @param const CCopasiContainer * pParent (default: NULL)
56  */
58  const CCopasiContainer * pParent = NULL);
59 
60  /**
61  * Destructor
62  */
63  virtual ~CMIRIAMResource();
64 
65  /**
66  * Retrieve the list of MIRIAM Resource.
67  * @return const CMIRIAMResource & MIRIAMResource
68  */
70 
71  /**
72  * Set the Display Name of the MIRIAM Resource.
73  * @param const std::string & DisplayName
74  */
75  void setMIRIAMDisplayName(const std::string & displayName);
76 
77  /**
78  * Retrieve the Display Name of the MIRIAM Resource.
79  * @return const std::string & DisplayName
80  */
81  const std::string & getMIRIAMDisplayName() const;
82 
83  /**
84  * Set the URI of the MIRIAM Resource.
85  * @param const std::string & URI
86  */
87  void setMIRIAMURI(const std::string & URI);
88 
89  /**
90  * Retrieve the URI of the MIRIAM Resource.
91  * @return const std::string & URI
92  */
93  const std::string & getMIRIAMURI() const;
94 
95  /**
96  * Retrieve the identifiers.org URL of the MIRIAM Resource.
97  * @return std::string URL
98  */
99  std::string getIdentifiersOrgURL() const;
100 
101  /**
102  * Set the Pattern of the MIRIAM Resource.
103  * @param const std::string & Pattern
104  */
105  void setMIRIAMPattern(const std::string & pattern);
106 
107  /**
108  * Retrieve the Pattern of the MIRIAM Resource.
109  * @return std::string & Pattern
110  */
111  const std::string & getMIRIAMPattern() const;
112 
113  /**
114  * Set whether the resource can be used as reference.
115  * @param const bool & isCitation
116  */
117  void setMIRIAMCitation(const bool & isCitation);
118 
119  /**
120  * Retrieve whether the resource can be used as reference.
121  * @return const bool & isCitation
122  */
123  const bool & getMIRIAMCitation() const;
124 
125  /**
126  * Add a deprecated URL to the MIRIAM Resource
127  * @param const std::string & URL
128  */
129  void addDeprecatedURL(const std::string & URL);
130 
131  /**
132  * Retrieve the deprecated URL of the MIRIAM Resource
133  * @return const CCopasiParameterGroup & deprecatedURLs
134  */
136 
137 private:
138  /**
139  * Allocates all group parameters and assures that they are
140  * properly initialized.
141  */
142  void initializeParameter();
143 
144  //Attributes
145  /**
146  * The name used in the GUI
147  */
148  std::string * mpDisplayName;
149 
150  /**
151  * A pointer to the URI
152  */
153  std::string * mpURI;
154 
155  /**
156  * A pointer to the pattern
157  */
158  std::string * mpPattern;
159 
160  /**
161  * A pointer to a bool indication the the resource an be used as reference
162  */
163  bool * mpCitation;
164 
165  /**
166  * A parameter group holding all deprecated URIs
167  */
169 }; //class CMIRIAMResource
170 
171 /////////////////////////////////////////////////////////////////////////////////////////
172 
174 {
175  //Operations
176 public:
177  /**
178  * Default constructor
179  * @param const std::string & name (default: MIRIAM Resources)
180  * @param const CCopasiContainer * pParent (default: NULL)
181  */
182  CMIRIAMResources(const std::string & name = "MIRIAM Resources",
183  const CCopasiContainer * pParent = NULL);
184 
185  /**
186  * Copy constructor
187  * @param const CMIRIAMResources & src
188  * @param const CCopasiContainer * pParent (default: NULL)
189  */
191  const CCopasiContainer * pParent = NULL);
192  /**
193  * Specific constructor
194  * @param const CCopasiParameterGroup & group
195  * @param const CCopasiContainer * pParent (default: NULL)
196  */
198  const CCopasiContainer * pParent = NULL);
199 
200  /**
201  * Destructor
202  */
203  virtual ~CMIRIAMResources();
204 
205  /**
206  * This methods must be called to elevate subgroups to
207  * derived objects. The default implementation does nothing.
208  * @return bool success
209  */
210  virtual bool elevateChildren();
211 
212  /**
213  * Add a MIRIAM Resource to the list of MIRIAM Resources
214  * @param CMIRIAMResource * pMIRIAMResource
215  */
216  void addMIRIAMResource(CMIRIAMResource * pMIRIAMResource);
217 
218  /**
219  * Retrieve the list of MIRIAM Resources
220  * @return CMIRIAMResources & MIRIAMResources
221  */
222  const CMIRIAMResources & getMIRIAMResources() const;
223 
224  /**
225  * Retrieve the day the resources where last updated
226  * @return const unsigned C_INT32 & lastUpdateDay
227  */
228  const unsigned C_INT32 & getMIRIAMLastUpdateDate() const;
229 
230  /**
231  * Retrieve the of interval between updates
232  * @return const unsigned C_INT32 & updateFrequency
233  */
234  const unsigned C_INT32 & getMIRIAMUpdateFrequency() const;
235 
236  /**
237  * Set the days between updates
238  * @param const size_t & days
239  */
240  void setMIRIAMUpdateFrequencyInDays(const size_t & days);
241 
242  /**
243  * Update the MIRIAM resources
244  * @param CProcessReport * pProcessReport
245  * @return bool success
246  */
247  bool updateMIRIAMResources(CProcessReport * pProcessReport);
248 
249  /**
250  * Update the MIRIAM resources using a local filename
251  * @param CProcessReport * pProcessReport
252  * @return bool success
253  */
254  bool updateMIRIAMResourcesFromFile(CProcessReport * pProcessReport,
255  const std::string& filename);
256 
257  /**
258  * Automatically update the resources when the last update is older than
259  * the current date minus the update interval.
260  * @param CProcessReport * pProcessReport
261  * @return bool success
262  */
263  bool autoUpdateMIRIAMResources(CProcessReport * pProcessReport);
264 
265  /**
266  * Retrieve the indexed resource
267  * @param const size_t index
268  * @return const CMIRIAMResource & resource
269  */
270  const CMIRIAMResource & getMIRIAMResource(const size_t index) const;
271 
272  /**
273  * Retrieve the index of the resource with the given URI
274  * @param const std::string & URI
275  * @return size_t index
276  */
277  size_t getMIRIAMResourceIndex(const std::string & URI) const;
278 
279  /**
280  * Retrieve the index of the resource with the given display name
281  * @param const std::string & displayName
282  * @return size_t index
283  */
284  size_t getResourceIndexFromDisplayName(const std::string & displayName) const;
285 
286  // bool setURI(const std::string & URI);
287 
288  /**
289  * Retrieve the list of MIRIAM resource as a CCopasiParameterGroup
290  * @return const CCopasiParameterGroup & resourceList
291  */
292  const CCopasiParameterGroup & getResourceList() const;
293 
294  /**
295  * Allocates all group parameters and assures that they are
296  * properly initialized.
297  */
298  void initializeParameter();
299 
300 private:
301  //Operations
302  /**
303  * Set the last update date to the current time
304  */
306 
307  /**
308  * Retrieve the current date ins seconds
309  */
310  unsigned C_INT32 getActDateInSeconds();
311 
312  /**
313  * Initialize the display name to resource index map
314  */
315  void createDisplayNameMap();
316 
317  /**
318  * Initialize the URI to resource index map
319  */
320  void createURIMap();
321 
322  /**
323  * A pointer to the last update date.
324  */
326 
327  /**
328  * A pointer to the update interval.
329  */
331 
332  /**
333  * A pointer to the group of MIRIAM resources
334  */
336 
337  /**
338  * A map from display name to resource index
339  */
340  std::map< std::string, size_t > mDisplayName2Resource;
341 
342  /**
343  * A map from URI to resource index
344  */
345  std::map< std::string, size_t > mURI2Resource;
346 }; //class CMIRIAMResources
347 
348 #endif // COPASI_CMIRIAMResource
const std::string & getMIRIAMURI() const
std::string getIdentifiersOrgURL() const
const CMIRIAMResource & getMIRIAMMIRIAMResource() const
const CMIRIAMResource & getMIRIAMResource(const size_t index) const
const CMIRIAMResources & getMIRIAMResources() const
const CCopasiParameterGroup & getResourceList() const
CCopasiParameterGroup * mpDeprecated
std::string * mpDisplayName
void setMIRIAMURI(const std::string &URI)
std::string * mpURI
CCopasiParameterGroup * mpMIRIAMResources
bool autoUpdateMIRIAMResources(CProcessReport *pProcessReport)
void setMIRIAMCitation(const bool &isCitation)
void addDeprecatedURL(const std::string &URL)
void addMIRIAMResource(CMIRIAMResource *pMIRIAMResource)
const unsigned C_INT32 & getMIRIAMLastUpdateDate() const
#define C_INT32
Definition: copasi.h:90
bool updateMIRIAMResourcesFromFile(CProcessReport *pProcessReport, const std::string &filename)
const std::string & getMIRIAMPattern() const
CMIRIAMResources(const std::string &name="MIRIAM Resources", const CCopasiContainer *pParent=NULL)
const std::string & getMIRIAMDisplayName() const
void setMIRIAMUpdateFrequencyInDays(const size_t &days)
virtual ~CMIRIAMResources()
const unsigned C_INT32 & getMIRIAMUpdateFrequency() const
CMIRIAMResource(const std::string &name="MIRIAM Resource", const CCopasiContainer *pParent=NULL)
unsigned C_INT32 * mpUpdateFrequency
void setMIRIAMPattern(const std::string &pattern)
virtual ~CMIRIAMResource()
const CCopasiParameterGroup & getMIRIAMDeprecated() const
virtual bool elevateChildren()
size_t getResourceIndexFromDisplayName(const std::string &displayName) const
unsigned C_INT32 getActDateInSeconds()
std::string * mpPattern
void setMIRIAMDisplayName(const std::string &displayName)
unsigned C_INT32 * mpLastUpdateDate
size_t getMIRIAMResourceIndex(const std::string &URI) const
bool updateMIRIAMResources(CProcessReport *pProcessReport)
std::map< std::string, size_t > mURI2Resource
std::map< std::string, size_t > mDisplayName2Resource
const bool & getMIRIAMCitation() const