COPASI API  4.16.103
utilities.cpp
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 
14 #include "copasi/xml/CCopasiXML.h"
17 #include "copasi/model/CModel.h"
20 
21 bool load_cps_model_from_stream(std::istream& is, CCopasiDataModel& dataModel)
22 {
23  return dataModel.loadModel(is, std::string(""), NULL);
24 }
25 
26 bool save_cps_model_to_stream(std::ostream& os, CCopasiDataModel* pDataModel)
27 {
28  bool success = true;
29 
30  if (pDataModel != NULL &&
31  pDataModel->getModel() != NULL)
32  {
33  CCopasiXML XML;
34 
35  XML.setModel(pDataModel->getModel());
36  XML.setTaskList(pDataModel->getTaskList());
37  XML.setReportList(pDataModel->getReportDefinitionList());
38  XML.setPlotList(pDataModel->getPlotDefinitionList());
39  XML.setGUI(pDataModel->getGUI());
40  XML.setLayoutList(*pDataModel->getListOfLayouts());
41  XML.setDatamodel(pDataModel);
42 
43  try
44  {
45  success = XML.save(os, "");
46  }
47  catch (...)
48  {
49  return false;
50  }
51  }
52  else
53  {
54  success = false;
55  }
56 
57  return success;
58 }
SCopasiXMLGUI * getGUI()
bool setModel(CModel *pModel)
Definition: CCopasiXML.cpp:254
bool save_cps_model_to_stream(std::ostream &os, CCopasiDataModel *pDataModel)
Definition: utilities.cpp:26
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
const CReportDefinitionVector * getReportDefinitionList() const
bool setDatamodel(CCopasiDataModel *pDataModel)
Definition: CCopasiXML.cpp:299
bool setTaskList(CCopasiVectorN< CCopasiTask > *pTaskList)
Definition: CCopasiXML.cpp:288
CCopasiVectorN< CCopasiTask > * getTaskList()
bool setPlotList(COutputDefinitionVector *pPlotList)
Definition: CCopasiXML.cpp:319
bool loadModel(std::istream &in, const std::string &pwd, CProcessReport *pProcessReport, const bool &deleteOldData=true)
CListOfLayouts * getListOfLayouts()
bool setLayoutList(const CListOfLayouts &reportList)
Definition: CCopasiXML.cpp:377
bool setGUI(SCopasiXMLGUI *pGUI)
Definition: CCopasiXML.cpp:359
const COutputDefinitionVector * getPlotDefinitionList() const
bool setReportList(CReportDefinitionVector *pReportList)
Definition: CCopasiXML.cpp:339
virtual bool save(std::ostream &os, const std::string &relativeTo)
Definition: CCopasiXML.cpp:102