COPASI API  4.16.103
CCopasiXML.h
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2014 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) 2003 - 2007 by Pedro Mendes, Virginia Tech Intellectual
12 // Properties, Inc. and EML Research, gGmbH.
13 // All rights reserved.
14 
15 /**
16  * CCopasiXML class.
17  * This class implements a CCopasiXMLInterface to the COPASI XML specified in
18  * http://www.copasi.org/schema/copasi.xsd
19  *
20  * Created for COPASI by Stefan Hoops 2003
21  * Copyright Stefan Hoops
22  */
23 
24 #ifndef COPASI_CCopasiXML
25 #define COPASI_CCopasiXML
26 
28 #include "utilities/CVersion.h"
29 
30 class CAnnotation;
31 class CModel;
32 class CModelParameter;
33 class CEvaluationTree;
34 class CFunction;
35 class CCopasiTask;
38 class CListOfLayouts;
39 class CLPoint;
40 class CLDimensions;
41 class CLBoundingBox;
42 class CLCurve;
43 
44 class CCopasiParameter;
47 class CCopasiDataModel;
48 
52 class CLLocalStyle;
53 class CLGlobalStyle;
54 class CLColorDefinition;
55 class CLGradientBase;
56 class CLLinearGradient;
57 class CLRadialGradient;
58 class CLLineEnding;
59 class CLRenderPoint;
61 class CLGroup;
62 class CLTransformation2D;
63 class CLImage;
65 class CLText;
66 class CLRenderCurve;
68 class CLRectangle;
69 class CLEllipse;
70 class CLPolygon;
71 class CLGradientStop;
72 class CLLineEnding;
73 class CLStyle;
74 
76 {
77  // Operations
78 public:
79  /**
80  * Constructor
81  */
82  CCopasiXML();
83 
84  /**
85  * Destructor
86  */
87  ~CCopasiXML();
88 
89  /**
90  * Save information to a given ostream.
91  * @param std::ostream & os
92  * @param const std::string & relativeTo
93  * @return bool success
94  */
95  virtual bool save(std::ostream & os,
96  const std::string & relativeTo);
97 
98  /**
99  * Load information from a given istream.
100  * @param std::istream & is
101  * @param const std::string & pwd
102  * @return bool success
103  */
104  virtual bool load(std::istream & is,
105  const std::string & pwd);
106 
107  /**
108  * Set the model.
109  * @param CModel * pModel
110  * @return bool success
111  */
112  bool setModel(CModel * pModel);
113 
114  /**
115  * Retreive the model.
116  * @return CModel * pModel
117  */
118  CModel * getModel() const;
119 
120  /**
121  * Retreive whether the XML contains a model.
122  * @return bool have Model
123  */
124  bool haveModel() const;
125 
126  /**
127  * Free the model.
128  * @return bool success
129  */
130  bool freeModel();
131 
132  /**
133  * Set the function list.
134  * @param CopasiVectorN< CFunction > * pFunctionList
135  * @return bool success
136  */
137  bool setFunctionList(CCopasiVectorN< CFunction > *pFunctionList);
138 
139  /**
140  * Retrieve the function list.
141  * @return CCopasiVectorN< CFunction > * pFunctionList
142  */
144 
145  /**
146  * Retrieve whether the XML contains a function list.
147  * @return bool haveFunctionList
148  */
149  bool haveFunctionList() const;
150 
151  /**
152  * Free the function list.
153  * @return bool success
154  */
155  bool freeFunctionList();
156 
157  /**
158  * Set the task list.
159  * @param CCopasiVectorN< CCopasiTask > *pTaskList
160  * @return bool success
161  */
163 
164  /**
165  * Set the datamodel.
166  * @param CCopasiDataModel* pDataModel
167  * @return bool success
168  */
169  bool setDatamodel(CCopasiDataModel* pDataModel);
170 
171  /**
172  * Retrieve the task list.
173  * @return CCopasiVectorN< CCopasiTask > * taskList
174  */
176 
177  /**
178  * Retrieve whether the XML contains a task list.
179  * @return bool haveTaskList
180  */
181  bool haveTaskList() const;
182 
183  /**
184  * Free the task list.
185  * @return bool success
186  */
187  bool freeTaskList();
188 
189  /**
190  * Set the plot list.
191  * @param COutputDefinitionVector * pPlotList
192  * @return bool success
193  */
194  bool setPlotList(COutputDefinitionVector * pPlotList);
195 
196  /**
197  * Retrieve the plot list.
198  * @return COutputDefinitionVector * plotList
199  */
201 
202  /**
203  * Retrieve whether the XML contains a plot list.
204  * @return bool havePlotList
205  */
206  bool havePlotList() const;
207 
208  /**
209  * Free the plot list.
210  * @return bool success
211  */
212  bool freePlotList();
213 
214  /**
215  * Set the report list.
216  * @param CReportDefinitionVector *pReportList
217  * @return bool success
218  */
219  bool setReportList(CReportDefinitionVector * pReportList);
220 
221  /**
222  * Retrieve the report list.
223  * @return CReportDefinitionVector * reportList
224  */
226 
227  /**
228  * Retrieve whether the XML contains a report list.
229  * @return bool haveReportList
230  */
231  bool haveReportList() const;
232 
233  /**
234  * Free the report list.
235  * @return bool success
236  */
237  bool freeReportList();
238 
239  /**
240  * Set the GUI.
241  * @param SCopasiXMLGUI *pGUI
242  * @return bool success
243  */
244  bool setGUI(SCopasiXMLGUI *pGUI);
245 
246  /**
247  * Retrieve the SCopasiXMLGUI.
248  * @return SCopasiXMLGUI * pGUI
249  */
250  SCopasiXMLGUI * getGUI() const;
251 
252  /**
253  * Retrieve whether the XML contains a GUI.
254  * @return bool have GUI
255  */
256  bool haveGUI() const;
257 
258  /**
259  * Free the GUI.
260  * @return bool success
261  */
262  bool freeGUI();
263 
264  /**
265  * Set the layout list.
266  * @param const CListOfLayouts & reportList
267  * @return bool success
268  */
269  bool setLayoutList(const CListOfLayouts & reportList);
270 
271  /**
272  * Retrieve the layout list.
273  * @return CListOfLayouts * layoutList
274  */
275  CListOfLayouts * getLayoutList() const;
276 
277  /**
278  * Retrieve whether the XML contains a layout list.
279  * @return bool haveLayoutList
280  */
281  bool haveLayoutList() const;
282 
283  /**
284  * Free the layout list.
285  * @return bool success
286  */
287  bool freeLayoutList();
288 
289 private:
290  /**
291  * Save the model.
292  * @return bool success
293  */
294  bool saveModel();
295 
296  /**
297  * Save a model parameter
298  * @param const CModelParameter * pModelParameter
299  * @return bool success
300  */
301  bool saveModelParameter(const CModelParameter * pModelParameter);
302 
303  bool saveAnnotation(const CAnnotation * pAnnotation);
304 
305  /**
306  * Save the list of functions.
307  * @return bool success
308  */
309  bool saveFunctionList();
310 
311  /**
312  * Save the list of tasks.
313  * @return bool success
314  */
315  bool saveTaskList();
316 
317  /**
318  * Save the list of plots.
319  * @return bool success
320  */
321  bool savePlotList();
322 
323  /**
324  * Save the list of reports.
325  * @return bool success
326  */
327  bool saveReportList();
328 
329  /**
330  * Save GUI information
331  * @return bool success
332  */
333  bool saveGUI();
334 
335  /**
336  * Save the list of layout.
337  * @return bool success
338  */
339  bool saveLayoutList();
340 
341  void savePosition(const CLPoint& p, const std::string & tag = "Position");
342 
343  void saveDimensions(const CLDimensions& d);
344 
345  void saveBoundingBox(const CLBoundingBox& bb);
346 
347  void saveCurve(const CLCurve& c);
348 
349  /**
350  * Save the SBML reference information
351  * @return bool success
352  */
353  bool saveSBMLReference();
354 
355  /**
356  * Save a Report Section such as Header, Body or Footer.
357  * @param const std::string & name
358  * @param const std::vector <CCopasiObjectName> & section
359  * @return bool success
360  */
361  bool saveReportSection(const std::string & name,
362  const std::vector <CRegisteredObjectName> & section);
363 
364  /**
365  * Build a list of functions.
366  * @return bool success
367  */
368  bool buildFunctionList();
369 
370  /**
371  * Fix files written with Version 4.10.55, which wrote the square root of user defined weights for the
372  * parameter fitting task
373  */
374  void fixBuild55();
375 
376  /**
377  * Fix files written with Version 4.12.81 and earlier, which wrote the exp(mean) and exp(std. deviation) for
378  * normal random distributions in the scan task.
379  */
380  void fixBuild81();
381 
382  /**
383  * Saves the list of global render information objects.
384  */
386 
387  /**
388  * Saves the list of local render information objects.
389  */
391 
392  /**
393  * Saves a single global render information object.
394  */
396 
397  /**
398  * Saves a single local render information object.
399  */
401 
402  /**
403  * Saves the attributes that render information objects have in common.
404  */
406 
407  /**
408  * Saves color definitions, gradient definitions and line endings.
409  */
411 
412  /**
413  * Save a single color definition element.
414  */
415  void saveColorDefinition(const CLColorDefinition& color);
416 
417  /**
418  * Saves a single linear gradient definition.
419  */
420  void saveLinearGradient(const CLLinearGradient& gradient);
421 
422  /**
423  * Saves a single radial gradient definition.
424  */
425  void saveRadialGradient(const CLRadialGradient& gradient);
426 
427  /**
428  * Adds the attributes common to radial and linear gradient.
429  */
430  void saveGradientAttributes(const CLGradientBase& gradient, CXMLAttributeList& attributes);
431 
432  /**
433  * Saves the elements that are common to linear and radial gradients.
434  */
435  void saveGradientElements(const CLGradientBase& gradient);
436 
437  /**
438  * Saves a single gradient stop element.
439  */
440  void saveGradientStop(const CLGradientStop& stop);
441 
442  /**
443  * Saves a line ending definiton,
444  */
445  void saveLineEnding(const CLLineEnding& lineEnding);
446 
447  /**
448  * Saves a single local style element.
449  */
450  void saveLocalStyle(const CLLocalStyle& style);
451 
452  /**
453  * Saves a single local style element.
454  */
455  void saveGlobalStyle(const CLGlobalStyle& style);
456 
457  /**
458  * Adds the attributes common to both style types.
459  */
460  void saveStyleAttributes(const CLStyle& style, CXMLAttributeList& attributes);
461 
462  /**
463  * Saves the elements common to both style types.
464  */
465  void saveStyleElements(const CLStyle& style);
466 
467  /**
468  * Saves a group element.
469  */
470  void saveGroupElement(const CLGroup& group);
471 
472  /**
473  * Saves the attributes for a transformation.
474  */
475  void saveTransformationAttributes(const CLTransformation2D& transformation, CXMLAttributeList& attributes);
476 
477  /**
478  * Saves the attributes for a 1D element
479  */
480  void save1DAttributes(const CLGraphicalPrimitive1D& primitive, CXMLAttributeList& attributes);
481 
482  /**
483  * Saves the attributes for a 2D element
484  */
485  void save2DAttributes(const CLGraphicalPrimitive2D& primitive, CXMLAttributeList& attributes);
486 
487  /**
488  * Saves the attributes for a text element.
489  * We make this a template so that we can use it for a group as well as a text element.
490  */
491  template<typename TEXTELEMENT>
492  void saveTextAttributes(const TEXTELEMENT& text, CXMLAttributeList& attributes);
493 
494  /**
495  * Saves the startHead and endHead attribute as found in group and curves.
496  * We write it as a template so that it can be used on curves and group elements.
497  */
498  template<typename HEADELEMENT>
499  void saveArrowHeadAttributes(const HEADELEMENT& element, CXMLAttributeList& attributes);
500 
501  /**
502  * Saves a class that is subclasses from Transformation2D.
503  * This covers images, curves, rectangles, ellipses, polygons, text elements and groups.
504  */
505  void saveTransformation2D(const CLTransformation2D& transformation);
506 
507  /**
508  * saves a single image element.
509  */
510  void saveImageElement(const CLImage& image);
511 
512  /**
513  * saves a single rectangle element.
514  */
515  void saveRectangleElement(const CLRectangle& rectangle);
516 
517  /**
518  * saves a single ellipse element.
519  */
520  void saveEllipseElement(const CLEllipse& ellipse);
521 
522  /**
523  * saves a single text element.
524  */
525  void saveRenderTextElement(const CLText& text);
526 
527  /**
528  * saves a single image element.
529  */
530  void savePolygonElement(const CLPolygon& polygon);
531 
532  /**
533  * saves a single image element.
534  */
535  void saveRenderCurveElement(const CLRenderCurve& curve);
536 
537  /**
538  * saves a vector of curve elements. This can be called from the polygon as well as the curve.
539  */
540  void saveCurveElements(const std::vector<CLRenderPoint*>& curveElements);
541 
542  /**
543  * saves a single render point element.
544  */
545  void saveRenderPoint(const CLRenderPoint& point);
546 
547  // Attributes
548 
549  /**
550  * Pointer to a model which has been loaded or is to be saved.
551  * The ownership is handed to the user.
552  */
554 
555  /**
556  * Pointer to a vector of functions which has been loaded or is to be saved.
557  * The ownership is handed to the user.
558  */
560 
561  /**
562  * Pointer to a vector of tasks which has been loaded or is to be saved.
563  * The ownership is handed to the user.
564  */
566 
567  /**
568  * Pointer to a vector of reports which has been loaded or is to be saved.
569  * The ownership is handed to the user.
570  */
572 
573  /**
574  * Pointer to a vector of plots which has been loaded or is to be saved.
575  * The ownership is handed to the user.
576  */
578 
579  /**
580  * Pointer to a GUI related information, which has been loaded or is to be saved.
581  * The ownership is handed to the user.
582  */
584 
585  /**
586  * Pointer to a vector of plots which has been loaded or is to be saved.
587  * The ownership is handed to the user.
588  */
590 
591  /**
592  * SBML Reference
593  */
594  std::map< std::string, std::string > mSBMLReference;
595 
596  /**
597  * Pointer to the datamodel
598  */
600 
601  /**
602  * Remember if we already issued MCXML21
603  */
605 };
606 
607 #endif // COPASI_CCopasiXML
bool freePlotList()
Definition: CCopasiXML.cpp:331
CCopasiVectorN< CFunction > * getFunctionList() const
Definition: CCopasiXML.cpp:276
void saveColorDefinition(const CLColorDefinition &color)
void saveBoundingBox(const CLBoundingBox &bb)
void saveDimensions(const CLDimensions &d)
void save1DAttributes(const CLGraphicalPrimitive1D &primitive, CXMLAttributeList &attributes)
Definition: CLText.h:27
void saveGradientElements(const CLGradientBase &gradient)
void saveCurveElements(const std::vector< CLRenderPoint * > &curveElements)
void saveLocalStyle(const CLLocalStyle &style)
void saveTransformation2D(const CLTransformation2D &transformation)
CReportDefinitionVector * mpReportList
Definition: CCopasiXML.h:571
bool freeModel()
Definition: CCopasiXML.cpp:264
bool setModel(CModel *pModel)
Definition: CCopasiXML.cpp:254
void fixBuild81()
bool haveGUI() const
Definition: CCopasiXML.cpp:367
CListOfLayouts * getLayoutList() const
Definition: CCopasiXML.cpp:383
void saveRenderPoint(const CLRenderPoint &point)
bool setFunctionList(CCopasiVectorN< CFunction > *pFunctionList)
Definition: CCopasiXML.cpp:270
SCopasiXMLGUI * mpGUI
Definition: CCopasiXML.h:583
bool saveReportList()
bool savePlotList()
CCopasiVectorN< CFunction > * mpFunctionList
Definition: CCopasiXML.h:559
bool haveModel() const
Definition: CCopasiXML.cpp:262
void fixBuild55()
void saveGradientAttributes(const CLGradientBase &gradient, CXMLAttributeList &attributes)
SCopasiXMLGUI * getGUI() const
Definition: CCopasiXML.cpp:365
COutputDefinitionVector * getPlotList() const
Definition: CCopasiXML.cpp:325
void saveListOfGlobalRenderInformation(const CCopasiVector< CLGlobalRenderInformation > &list)
void saveTextAttributes(const TEXTELEMENT &text, CXMLAttributeList &attributes)
bool haveFunctionList() const
Definition: CCopasiXML.cpp:279
bool freeGUI()
Definition: CCopasiXML.cpp:369
void saveLinearGradient(const CLLinearGradient &gradient)
bool freeFunctionList()
Definition: CCopasiXML.cpp:282
void saveListOfLocalRenderInformation(const CCopasiVector< CLLocalRenderInformation > &list)
void saveStyleAttributes(const CLStyle &style, CXMLAttributeList &attributes)
bool saveModel()
Definition: CCopasiXML.cpp:395
bool freeTaskList()
Definition: CCopasiXML.cpp:311
void saveImageElement(const CLImage &image)
bool havePlotList() const
Definition: CCopasiXML.cpp:328
void saveRectangleElement(const CLRectangle &rectangle)
bool saveAnnotation(const CAnnotation *pAnnotation)
Definition: CCopasiXML.cpp:922
void saveGlobalStyle(const CLGlobalStyle &style)
bool haveTaskList() const
Definition: CCopasiXML.cpp:308
bool setDatamodel(CCopasiDataModel *pDataModel)
Definition: CCopasiXML.cpp:299
CCopasiDataModel * mpDataModel
Definition: CCopasiXML.h:599
void saveGradientStop(const CLGradientStop &stop)
void saveTransformationAttributes(const CLTransformation2D &transformation, CXMLAttributeList &attributes)
Definition: CLBase.h:54
bool setTaskList(CCopasiVectorN< CCopasiTask > *pTaskList)
Definition: CCopasiXML.cpp:288
COutputDefinitionVector * mpPlotList
Definition: CCopasiXML.h:577
void saveGroupElement(const CLGroup &group)
std::map< std::string, std::string > mSBMLReference
Definition: CCopasiXML.h:594
bool freeLayoutList()
Definition: CCopasiXML.cpp:389
bool setPlotList(COutputDefinitionVector *pPlotList)
Definition: CCopasiXML.cpp:319
void save2DAttributes(const CLGraphicalPrimitive2D &primitive, CXMLAttributeList &attributes)
void saveLineEnding(const CLLineEnding &lineEnding)
void saveArrowHeadAttributes(const HEADELEMENT &element, CXMLAttributeList &attributes)
void saveRenderInformationAttributes(const CLRenderInformationBase &renderInfo, CXMLAttributeList &attributes)
bool setLayoutList(const CListOfLayouts &reportList)
Definition: CCopasiXML.cpp:377
bool haveLayoutList() const
Definition: CCopasiXML.cpp:386
bool saveSBMLReference()
CReportDefinitionVector * getReportList() const
Definition: CCopasiXML.cpp:345
void saveCurve(const CLCurve &c)
void saveLocalRenderInformation(const CLLocalRenderInformation &renderInfo)
void savePolygonElement(const CLPolygon &polygon)
void saveEllipseElement(const CLEllipse &ellipse)
CModel * getModel() const
Definition: CCopasiXML.cpp:260
bool setGUI(SCopasiXMLGUI *pGUI)
Definition: CCopasiXML.cpp:359
bool setReportList(CReportDefinitionVector *pReportList)
Definition: CCopasiXML.cpp:339
void saveStyleElements(const CLStyle &style)
bool saveLayoutList()
void savePosition(const CLPoint &p, const std::string &tag="Position")
CListOfLayouts * mpLayoutList
Definition: CCopasiXML.h:589
bool saveGUI()
bool freeReportList()
Definition: CCopasiXML.cpp:351
The class for handling a chemical kinetic function.
Definition: CFunction.h:29
CCopasiVectorN< CCopasiTask > * mpTaskList
Definition: CCopasiXML.h:565
void saveRenderInformationDefinitionElements(const CLRenderInformationBase &renderInfo)
Definition: CModel.h:50
virtual bool load(std::istream &is, const std::string &pwd)
Definition: CCopasiXML.cpp:169
CModel * mpModel
Definition: CCopasiXML.h:553
bool saveFunctionList()
bool mMCXML21Issued
Definition: CCopasiXML.h:604
bool saveReportSection(const std::string &name, const std::vector< CRegisteredObjectName > &section)
CCopasiVectorN< CCopasiTask > * getTaskList() const
Definition: CCopasiXML.cpp:305
bool buildFunctionList()
void saveRadialGradient(const CLRadialGradient &gradient)
bool saveTaskList()
bool haveReportList() const
Definition: CCopasiXML.cpp:348
void saveRenderTextElement(const CLText &text)
void saveGlobalRenderInformation(const CLGlobalRenderInformation &renderInfo)
virtual bool save(std::ostream &os, const std::string &relativeTo)
Definition: CCopasiXML.cpp:102
bool saveModelParameter(const CModelParameter *pModelParameter)
Definition: CCopasiXML.cpp:963
void saveRenderCurveElement(const CLRenderCurve &curve)