COPASI API  4.16.103
Classes | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Types | List of all members
CCopasiDataModel Class Reference

#include <CCopasiDataModel.h>

Inheritance diagram for CCopasiDataModel:
Inheritance graph
[legend]
Collaboration diagram for CCopasiDataModel:
Collaboration graph
[legend]

Classes

class  CData
 

Public Member Functions

bool addDefaultReports ()
 
bool addDefaultTasks ()
 
CReportDefinitionaddReport (const CCopasiTask::Type &taskType)
 
CCopasiTaskaddTask (const CCopasiTask::Type &taskType)
 
bool appendDependentTasks (std::set< const CCopasiObject * > candidates, std::set< const CCopasiObject * > &dependentTasks) const
 
bool autoSave ()
 
 CCopasiDataModel (const bool withGUI=false)
 
 CCopasiDataModel (const std::string &name, const CCopasiContainer *pParent=NULL, const std::string &type="CN", bool withGUI=false)
 
void changed (const bool &changed=true)
 
void deleteOldData ()
 
bool exportMathModel (const std::string &fileName, CProcessReport *pProcessReport, const std::string &filter, bool overwriteFile=false)
 
std::string exportMathModelToString (CProcessReport *pProcessReport, const std::string &filter)
 
bool exportSBML (const std::string &fileName, bool overwriteFile=false, int sbmlLevel=2, int sbmlVersion=1, bool exportIncomplete=false, bool exportCOPASIMIRIAM=true, CProcessReport *pExportHandler=NULL)
 
std::string exportSBMLToString (CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
 
std::map< CCopasiObject
*, SBase * > & 
getCopasi2SBMLMap ()
 
SBMLDocument * getCurrentSBMLDocument ()
 
CCopasiObjectgetDataObject (const CCopasiObjectName &CN) const
 
const std::string & getFileName () const
 
SCopasiXMLGUIgetGUI ()
 
CListOfLayoutsgetListOfLayouts ()
 
const CListOfLayoutsgetListOfLayouts () const
 
CModelgetModel ()
 
const CModelgetModel () const
 
const COutputDefinitionVectorgetPlotDefinitionList () const
 
COutputDefinitionVectorgetPlotDefinitionList ()
 
const std::string & getReferenceDirectory () const
 
const CReportDefinitionVectorgetReportDefinitionList () const
 
CReportDefinitionVectorgetReportDefinitionList ()
 
const std::string & getSBMLFileName () const
 
CCopasiVectorN< CCopasiTask > * getTaskList ()
 
const CCopasiVectorN
< CCopasiTask > * 
getTaskList () const
 
bool importSBML (const std::string &fileName, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
 
bool importSBMLFromString (const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
 
bool isChanged () const
 
bool loadModel (std::istream &in, const std::string &pwd, CProcessReport *pProcessReport, const bool &deleteOldData=true)
 
bool loadModel (const std::string &fileName, CProcessReport *pProcessReport, const bool &deleteOldData=true)
 
bool newModel (CProcessReport *pProcessReport, const bool &deleteOldData)
 
CObjectInterfaceObjectFromCN (const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &objName) const
 
CCopasiObjectObjectFromName (const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
 
bool removeLayout (const std::string &key)
 
bool saveModel (const std::string &fileName, CProcessReport *pProcessReport, bool overwriteFile=false, const bool &autoSave=false)
 
bool setSBMLFileName (const std::string &fileName)
 
virtual ~CCopasiDataModel ()
 
- Public Member Functions inherited from CCopasiContainer
virtual bool add (CCopasiObject *pObject, const bool &adopt=true)
 
 CCopasiContainer (const std::string &name, const CCopasiContainer *pParent=NULL, const std::string &type="CN", const unsigned C_INT32 &flag=CCopasiObject::Container)
 
 CCopasiContainer (const CCopasiContainer &src, const CCopasiContainer *pParent=NULL)
 
virtual std::string getChildObjectUnits (const CCopasiObject *pObject) const
 
virtual const CObjectInterfacegetObject (const CCopasiObjectName &cn) const
 
virtual const objectMapgetObjects () const
 
virtual std::string getUnits () const
 
virtual const CCopasiObjectgetValueObject () const
 
virtual bool remove (CCopasiObject *pObject)
 
virtual ~CCopasiContainer ()
 
- Public Member Functions inherited from CCopasiObject
void addDirectDependency (const CCopasiObject *pObject)
 
 CCopasiObject (const CCopasiObject &src, const CCopasiContainer *pParent=NULL)
 
void clearDirectDependencies ()
 
void clearRefresh ()
 
bool dependsOn (DataObjectSet candidates, const DataObjectSet &context=DataObjectSet()) const
 
void getAllDependencies (DataObjectSet &dependencies, const DataObjectSet &context) const
 
virtual CCopasiObjectName getCN () const
 
virtual const DataObjectSetgetDirectDependencies (const DataObjectSet &context=DataObjectSet()) const
 
virtual const std::string & getKey () const
 
CCopasiContainergetObjectAncestor (const std::string &type) const
 
CCopasiDataModelgetObjectDataModel ()
 
const CCopasiDataModelgetObjectDataModel () const
 
virtual std::string getObjectDisplayName (bool regular=true, bool richtext=false) const
 
const std::string & getObjectName () const
 
CCopasiContainergetObjectParent () const
 
const std::string & getObjectType () const
 
virtual const
CObjectInterface::ObjectSet
getPrerequisites () const
 
virtual RefreshgetRefresh () const
 
UpdateMethodgetUpdateMethod () const
 
virtual voidgetValuePointer () const
 
bool hasCircularDependencies (DataObjectSet &candidates, DataObjectSet &verified, const DataObjectSet &context) const
 
bool hasUpdateMethod () const
 
bool isArray () const
 
bool isContainer () const
 
bool isDataModel () const
 
bool isMatrix () const
 
bool isNameVector () const
 
bool isNonUniqueName () const
 
virtual bool isPrerequisiteForContext (const CObjectInterface *pObject, const CMath::SimulationContextFlag &context, const CObjectInterface::ObjectSet &changedObjects) const
 
bool isReference () const
 
bool isRoot () const
 
bool isSeparator () const
 
bool isStaticString () const
 
bool isValueBool () const
 
bool isValueDbl () const
 
bool isValueInt () const
 
bool isValueInt64 () const
 
bool isValueString () const
 
bool isVector () const
 
virtual bool mustBeDeleted (const DataObjectSet &deletedObjects) const
 
virtual void print (std::ostream *ostream) const
 
void removeDirectDependency (const CCopasiObject *pObject)
 
void setDirectDependencies (const DataObjectSet &directDependencies)
 
bool setObjectName (const std::string &name)
 
virtual bool setObjectParent (const CCopasiContainer *pParent)
 
void setObjectValue (const C_FLOAT64 &value)
 
void setObjectValue (const C_INT32 &value)
 
void setObjectValue (const bool &value)
 
template<class CType >
void setRefresh (CType *pType, void(CType::*method)(void))
 
template<class CType >
void setUpdateMethod (CType *pType, void(CType::*method)(const C_FLOAT64 &))
 
template<class CType >
void setUpdateMethod (CType *pType, void(CType::*method)(const C_INT32 &))
 
template<class CType >
void setUpdateMethod (CType *pType, void(CType::*method)(const bool &))
 
virtual ~CCopasiObject ()
 
- Public Member Functions inherited from CObjectInterface
 CObjectInterface ()
 
virtual ~CObjectInterface ()
 
- Public Member Functions inherited from COutputHandler
virtual void addInterface (COutputInterface *pInterface)
 
virtual bool compile (std::vector< CCopasiContainer * > listOfContainer, const CCopasiDataModel *pDataModel)
 
 COutputHandler ()
 
 COutputHandler (const COutputHandler &src)
 
virtual void finish ()
 
std::set< COutputInterface * > getInterfaces () const
 
bool isMaster () const
 
virtual void output (const Activity &activity)
 
virtual void removeInterface (COutputInterface *pInterface)
 
virtual void separate (const Activity &activity)
 
void setMaster (COutputHandler *pMaster)
 
virtual ~COutputHandler ()
 
- Public Member Functions inherited from COutputInterface
virtual void close ()
 
 COutputInterface ()
 
 COutputInterface (const COutputInterface &src)
 
virtual const std::set< const
CCopasiObject * > & 
getObjects () const
 
virtual ~COutputInterface ()
 

Public Attributes

std::set< CCopasiObject * > mLastAddedObjects
 
CCopasiVectorS< CMetabOld > * pOldMetabolites
 

Protected Member Functions

void commonAfterLoad (CProcessReport *pProcessReport, const bool &deleteOldData)
 
void popData ()
 
void pushData ()
 
void removeSBMLIdFromFunctions ()
 
- Protected Member Functions inherited from CCopasiContainer
template<class CType >
CCopasiObjectaddMatrixReference (const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)
 
template<class CType >
CCopasiObjectaddObjectReference (const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)
 
template<class CType >
CCopasiObjectaddVectorReference (const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)
 
void initObjects ()
 
- Protected Member Functions inherited from CCopasiObject
 CCopasiObject ()
 
 CCopasiObject (const std::string &name, const CCopasiContainer *pParent=NULL, const std::string &type="CN", const unsigned C_INT32 &flag=0)
 
- Protected Member Functions inherited from COutputHandler
bool compileRefresh (const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiDataModel *pDataModel)
 
void refresh ()
 

Protected Attributes

CData mData
 
CData mOldData
 
CDataModelRenameHandler mRenameHandler
 
- Protected Attributes inherited from CCopasiContainer
objectMap mObjects
 
- Protected Attributes inherited from COutputHandler
std::set< COutputInterface * > mInterfaces
 
std::vector< Refresh * > mObjectRefreshes
 
COutputHandlermpMaster
 
- Protected Attributes inherited from COutputInterface
std::set< const CCopasiObject * > mObjects
 

Private Types

enum  FileType {
  CopasiML = 0, SBML, SEDML, Gepasi,
  unset
}
 

Additional Inherited Members

- Public Types inherited from CCopasiContainer
typedef std::multimap
< std::string, CCopasiObject * > 
objectMap
 
- Public Types inherited from CCopasiObject
typedef std::set< const
CCopasiObject * > 
DataObjectSet
 
typedef std::vector< Refresh * > DataUpdateSequence
 
- Public Types inherited from CObjectInterface
typedef std::set< const
CObjectInterface * > 
ObjectSet
 
typedef std::vector
< CObjectInterface * > 
UpdateSequence
 
- Public Types inherited from COutputInterface
enum  Activity { BEFORE = 0x01, DURING = 0x02, AFTER = 0x04 }
 
- Static Public Member Functions inherited from CCopasiObject
static std::vector< Refresh * > buildUpdateSequence (const DataObjectSet &objects, const DataObjectSet &uptoDateObjects, const DataObjectSet &context=DataObjectSet())
 
static void setRenameHandler (CRenameHandler *rh)
 
- Static Public Attributes inherited from CCopasiContainer
static const std::vector
< CCopasiContainer * > 
EmptyList
 
- Protected Types inherited from CCopasiObject
enum  Flag {
  Container = 0x1, Vector = 0x2, Matrix = 0x4, NameVector = 0x8,
  Reference = 0x10, ValueBool = 0x20, ValueInt = 0x40, ValueInt64 = 0x80,
  ValueDbl = 0x100, NonUniqueName = 0x200, StaticString = 0x400, ValueString = 0x800,
  Separator = 0x1000, ModelEntity = 0x2000, Array = 0x4000, DataModel = 0x8000,
  Root = 0x10000, Gui = 0x20000
}
 
- Static Protected Attributes inherited from CCopasiObject
static CRenameHandlersmpRenameHandler = NULL
 

Detailed Description

Definition at line 78 of file CCopasiDataModel.h.

Member Enumeration Documentation

Enumerator
CopasiML 
SBML 
SEDML 
Gepasi 
unset 

Definition at line 80 of file CCopasiDataModel.h.

Constructor & Destructor Documentation

CCopasiDataModel::CCopasiDataModel ( const bool  withGUI = false)

Definition at line 113 of file CCopasiDataModel.cpp.

References mRenameHandler, newModel(), CCopasiTimer::PROCESS, CCopasiObject::setRenameHandler(), and CCopasiTimer::WALL.

113  :
114  CCopasiContainer("Root", NULL, "CN", CCopasiObject::DataModel),
115  COutputHandler(),
116  mData(withGUI),
117  mOldData(withGUI),
118  mRenameHandler(),
120 {
121  newModel(NULL, true);
123  new CCopasiTimer(CCopasiTimer::WALL, this);
125 }
bool newModel(CProcessReport *pProcessReport, const bool &deleteOldData)
static void setRenameHandler(CRenameHandler *rh)
CDataModelRenameHandler mRenameHandler
CCopasiVectorS< CMetabOld > * pOldMetabolites
CCopasiDataModel::CCopasiDataModel ( const std::string &  name,
const CCopasiContainer pParent = NULL,
const std::string &  type = "CN",
bool  withGUI = false 
)

Definition at line 127 of file CCopasiDataModel.cpp.

References mRenameHandler, newModel(), CCopasiTimer::PROCESS, CCopasiObject::setRenameHandler(), and CCopasiTimer::WALL.

130  :
131  CCopasiContainer(name, pParent, type, CCopasiObject::DataModel),
132  COutputHandler(),
133  mData(withGUI),
134  mOldData(withGUI),
135  mRenameHandler(),
137 {
138  newModel(NULL, true);
140  new CCopasiTimer(CCopasiTimer::WALL, this);
142 }
bool newModel(CProcessReport *pProcessReport, const bool &deleteOldData)
static void setRenameHandler(CRenameHandler *rh)
CDataModelRenameHandler mRenameHandler
CCopasiVectorS< CMetabOld > * pOldMetabolites
CCopasiDataModel::~CCopasiDataModel ( )
virtual

Definition at line 144 of file CCopasiDataModel.cpp.

References deleteOldData(), mData, mOldData, pdelete, pOldMetabolites, and CCopasiObject::setRenameHandler().

145 {
147 
148  // Make sure that the old data is deleted
149  deleteOldData();
150 
151  // Delete the current data
152  mOldData = mData;
153  deleteOldData();
154 
156 }
#define pdelete(p)
Definition: copasi.h:215
static void setRenameHandler(CRenameHandler *rh)
CCopasiVectorS< CMetabOld > * pOldMetabolites

Member Function Documentation

bool CCopasiDataModel::addDefaultReports ( )

Definition at line 1727 of file CCopasiDataModel.cpp.

References addReport(), C_INVALID_INDEX, CCopasiVectorN< CType >::getIndex(), CCopasiTask::getReport(), CReport::getReportDefinition(), mData, CCopasiDataModel::CData::pReportDefinitionList, pTask, CCopasiDataModel::CData::pTaskList, CReport::setReportDefinition(), and CCopasiTask::TypeName.

Referenced by commonAfterLoad().

1728 {
1729  size_t i;
1730 
1731  for (i = 0; CCopasiTask::TypeName[i] != ""; i++)
1732  {
1733  //try to create the report if it doesn't exist
1735  {
1737  }
1738 
1739  //see if the report exists now
1740  CReportDefinition* pReportDef = NULL;
1741 
1744 
1745  //see if the task exists
1746  CCopasiTask* pTask = NULL;
1747 
1749  pTask = (*mData.pTaskList)[CCopasiTask::TypeName[i]];
1750 
1751  if (pTask && pReportDef) //task and report definition exist
1752  {
1753  //if there is no report definition set the default
1754  if (!pTask->getReport().getReportDefinition())
1755  {
1756  pTask->getReport().setReportDefinition(pReportDef);
1757  }
1758 
1759  //TODO: also set the default report if no target file is set
1760  //even if a report is already set?
1761  }
1762  }
1763 
1764  return true;
1765 }
static const std::string TypeName[]
Definition: CCopasiTask.h:67
CReportDefinitionVector * pReportDefinitionList
#define C_INVALID_INDEX
Definition: copasi.h:222
virtual size_t getIndex(const std::string &name) const
CTSSATask * pTask
CReportDefinition * addReport(const CCopasiTask::Type &taskType)
CCopasiVectorN< CCopasiTask > * pTaskList
CReport & getReport()
CReportDefinition * getReportDefinition()
Definition: CReport.cpp:83
void setReportDefinition(CReportDefinition *reportDef)
Definition: CReport.cpp:86
bool CCopasiDataModel::addDefaultTasks ( )

Definition at line 1501 of file CCopasiDataModel.cpp.

References addTask(), C_INVALID_INDEX, CCopasiVectorN< CType >::getIndex(), mData, CCopasiDataModel::CData::pTaskList, and CCopasiTask::TypeName.

Referenced by commonAfterLoad().

1502 {
1503  size_t i;
1504 
1505  for (i = 0; CCopasiTask::TypeName[i] != ""; i++)
1508 
1509  return true;
1510 }
static const std::string TypeName[]
Definition: CCopasiTask.h:67
#define C_INVALID_INDEX
Definition: copasi.h:222
virtual size_t getIndex(const std::string &name) const
CCopasiTask * addTask(const CCopasiTask::Type &taskType)
CCopasiVectorN< CCopasiTask > * pTaskList
CReportDefinition * CCopasiDataModel::addReport ( const CCopasiTask::Type taskType)

Definition at line 1544 of file CCopasiDataModel.cpp.

References CCopasiVectorN< CType >::add(), CCopasiTask::fluxMode, CReportDefinition::getBodyAddr(), CReportDefinition::getFooterAddr(), CReportDefinition::getHeaderAddr(), CCopasiTask::lna, CCopasiTask::lyap, CCopasiTask::mca, mData, CCopasiTask::optimization, CCopasiTask::parameterFitting, CCopasiDataModel::CData::pReportDefinitionList, CCopasiTask::scan, CCopasiTask::sens, CReportDefinition::setComment(), CReportDefinition::setIsTable(), CReportDefinition::setSeparator(), CReportDefinition::setTaskType(), CReportDefinition::setTitle(), CCopasiTask::steadyState, CCopasiTask::timeCourse, CCopasiTask::tssAnalysis, and CCopasiTask::TypeName.

Referenced by addDefaultReports().

1545 {
1546  CReportDefinition * pReport = NULL;
1547 
1548  switch (taskType)
1549  {
1551  pReport = new CReportDefinition(CCopasiTask::TypeName[taskType]);
1552  pReport->setTaskType(taskType);
1553  pReport->setComment("Automatically generated report.");
1554  pReport->setIsTable(false);
1555  pReport->setSeparator(CCopasiReportSeparator("\t"));
1556  pReport->getFooterAddr()->push_back(CCopasiObjectName("CN=Root,Vector=TaskList[Steady-State]"));
1557  break;
1558 
1560  // No default report available.
1561  break;
1562 
1563  case CCopasiTask::scan:
1564  // No default report available.
1565  break;
1566 
1567  case CCopasiTask::fluxMode:
1568  pReport = new CReportDefinition(CCopasiTask::TypeName[taskType]);
1569  pReport->setTaskType(taskType);
1570  pReport->setComment("Automatically generated report.");
1571  pReport->setIsTable(false);
1572  pReport->setSeparator(CCopasiReportSeparator("\t"));
1573  pReport->getFooterAddr()->push_back(CCopasiObjectName("CN=Root,Vector=TaskList[Elementary Flux Modes],Object=Result"));
1574  break;
1575 
1577  pReport = new CReportDefinition(CCopasiTask::TypeName[taskType]);
1578  pReport->setTaskType(taskType);
1579  pReport->setComment("Automatically generated report.");
1580  pReport->setIsTable(false);
1581  pReport->setTitle(false);
1582  pReport->setSeparator(CCopasiReportSeparator("\t"));
1583 
1584  // Header
1585  pReport->getHeaderAddr()->push_back(CCopasiObjectName("CN=Root,Vector=TaskList[Optimization],Object=Description"));
1586  pReport->getHeaderAddr()->push_back(CCopasiObjectName("String=\\[Function Evaluations\\]"));
1587  pReport->getHeaderAddr()->push_back(CCopasiObjectName("Separator=\t"));
1588  pReport->getHeaderAddr()->push_back(CCopasiObjectName("String=\\[Best Value\\]"));
1589  pReport->getHeaderAddr()->push_back(CCopasiObjectName("Separator=\t"));
1590  pReport->getHeaderAddr()->push_back(CCopasiObjectName("String=\\[Best Parameters\\]"));
1591 
1592  // Body
1593  pReport->getBodyAddr()->push_back(CCopasiObjectName("CN=Root,Vector=TaskList[Optimization],Problem=Optimization,Reference=Function Evaluations"));
1594  pReport->getBodyAddr()->push_back(CCopasiObjectName("Separator=\t"));
1595  pReport->getBodyAddr()->push_back(CCopasiObjectName("CN=Root,Vector=TaskList[Optimization],Problem=Optimization,Reference=Best Value"));
1596  pReport->getBodyAddr()->push_back(CCopasiObjectName("Separator=\t"));
1597  pReport->getBodyAddr()->push_back(CCopasiObjectName("CN=Root,Vector=TaskList[Optimization],Problem=Optimization,Reference=Best Parameters"));
1598 
1599  // Footer
1600  pReport->getFooterAddr()->push_back(CCopasiObjectName("String=\n"));
1601  pReport->getFooterAddr()->push_back(CCopasiObjectName("CN=Root,Vector=TaskList[Optimization],Object=Result"));
1602  break;
1603 
1604  //**************************************************************************
1606  pReport = new CReportDefinition(CCopasiTask::TypeName[taskType]);
1607  pReport->setTaskType(taskType);
1608  pReport->setComment("Automatically generated report.");
1609  pReport->setIsTable(false);
1610  pReport->setTitle(false);
1611  pReport->setSeparator(CCopasiReportSeparator("\t"));
1612 
1613  // Header
1614  pReport->getHeaderAddr()->push_back(CCopasiObjectName("CN=Root,Vector=TaskList[Parameter Estimation],Object=Description"));
1615  pReport->getHeaderAddr()->push_back(CCopasiObjectName("String=\\[Function Evaluations\\]"));
1616  pReport->getHeaderAddr()->push_back(CCopasiObjectName("Separator=\t"));
1617  pReport->getHeaderAddr()->push_back(CCopasiObjectName("String=\\[Best Value\\]"));
1618  pReport->getHeaderAddr()->push_back(CCopasiObjectName("Separator=\t"));
1619  pReport->getHeaderAddr()->push_back(CCopasiObjectName("String=\\[Best Parameters\\]"));
1620 
1621  // Body
1622  pReport->getBodyAddr()->push_back(CCopasiObjectName("CN=Root,Vector=TaskList[Parameter Estimation],Problem=Parameter Estimation,Reference=Function Evaluations"));
1623  pReport->getBodyAddr()->push_back(CCopasiObjectName("Separator=\t"));
1624  pReport->getBodyAddr()->push_back(CCopasiObjectName("CN=Root,Vector=TaskList[Parameter Estimation],Problem=Parameter Estimation,Reference=Best Value"));
1625  pReport->getBodyAddr()->push_back(CCopasiObjectName("Separator=\t"));
1626  pReport->getBodyAddr()->push_back(CCopasiObjectName("CN=Root,Vector=TaskList[Parameter Estimation],Problem=Parameter Estimation,Reference=Best Parameters"));
1627 
1628  // Footer
1629  pReport->getFooterAddr()->push_back(CCopasiObjectName("String=\n"));
1630  pReport->getFooterAddr()->push_back(CCopasiObjectName("CN=Root,Vector=TaskList[Parameter Estimation],Object=Result"));
1631  break;
1632 
1633  //**************************************************************************
1634  case CCopasiTask::lyap:
1635  pReport = new CReportDefinition(CCopasiTask::TypeName[taskType]);
1636  pReport->setTaskType(taskType);
1637  pReport->setComment("Automatically generated report.");
1638  pReport->setIsTable(false);
1639  pReport->setTitle(false);
1640  pReport->setSeparator(CCopasiReportSeparator("\t"));
1641 
1642  // Header
1643  pReport->getHeaderAddr()->push_back(CCopasiObjectName("CN=Root,Vector=TaskList[Lyapunov Exponents],Object=Description"));
1644 
1645  // Footer
1646  pReport->getFooterAddr()->push_back(CCopasiObjectName("String=\n"));
1647  pReport->getFooterAddr()->push_back(CCopasiObjectName("CN=Root,Vector=TaskList[Lyapunov Exponents],Object=Result"));
1648  break;
1649 
1650  //**************************************************************************
1651  case CCopasiTask::mca:
1652  pReport = new CReportDefinition(CCopasiTask::TypeName[taskType]);
1653  pReport->setTaskType(taskType);
1654  pReport->setComment("Automatically generated report.");
1655  pReport->setIsTable(false);
1656  pReport->setTitle(false);
1657  pReport->setSeparator(CCopasiReportSeparator("\t"));
1658 
1659  // Header
1660  pReport->getHeaderAddr()->push_back(CCopasiObjectName("CN=Root,Vector=TaskList[Metabolic Control Analysis],Object=Description"));
1661 
1662  // Footer
1663  pReport->getFooterAddr()->push_back(CCopasiObjectName("String=\n"));
1664  pReport->getFooterAddr()->push_back(CCopasiObjectName("CN=Root,Vector=TaskList[Metabolic Control Analysis],Object=Result"));
1665  break;
1666 
1667  //**************************************************************************
1668  case CCopasiTask::lna:
1669  pReport = new CReportDefinition(CCopasiTask::TypeName[taskType]);
1670  pReport->setTaskType(taskType);
1671  pReport->setComment("Automatically generated report.");
1672  pReport->setIsTable(false);
1673  pReport->setTitle(false);
1674  pReport->setSeparator(CCopasiReportSeparator("\t"));
1675 
1676  // Header
1677  pReport->getHeaderAddr()->push_back(CCopasiObjectName("CN=Root,Vector=TaskList[Linear Noise Approximation],Object=Description"));
1678 
1679  // Footer
1680  pReport->getFooterAddr()->push_back(CCopasiObjectName("String=\n"));
1681  pReport->getFooterAddr()->push_back(CCopasiObjectName("CN=Root,Vector=TaskList[Linear Noise Approximation],Object=Result"));
1682  break;
1683 
1684  //**************************************************************************
1685  case CCopasiTask::sens:
1686  pReport = new CReportDefinition(CCopasiTask::TypeName[taskType]);
1687  pReport->setTaskType(taskType);
1688  pReport->setComment("Automatically generated report.");
1689  pReport->setIsTable(false);
1690  pReport->setTitle(false);
1691  pReport->setSeparator(CCopasiReportSeparator("\t"));
1692 
1693  // Header
1694  pReport->getHeaderAddr()->push_back(CCopasiObjectName("CN=Root,Vector=TaskList[Sensitivities],Object=Description"));
1695 
1696  // Footer
1697  pReport->getFooterAddr()->push_back(CCopasiObjectName("String=\n"));
1698  pReport->getFooterAddr()->push_back(CCopasiObjectName("CN=Root,Vector=TaskList[Sensitivities],Object=Result"));
1699  break;
1700 
1701  //**************************************************************************
1703  pReport = new CReportDefinition(CCopasiTask::TypeName[taskType]);
1704  pReport->setTaskType(taskType);
1705  pReport->setComment("Automatically generated report.");
1706  pReport->setIsTable(false);
1707  pReport->setTitle(false);
1708  pReport->setSeparator(CCopasiReportSeparator("\t"));
1709 
1710  // Header
1711  pReport->getHeaderAddr()->push_back(CCopasiObjectName("CN=Root,Vector=TaskList[Time Scale Separation Analysis],Object=Description"));
1712 
1713  // Footer
1714  pReport->getFooterAddr()->push_back(CCopasiObjectName("String=\n"));
1715  pReport->getFooterAddr()->push_back(CCopasiObjectName("CN=Root,Vector=TaskList[Time Scale Separation Analysis],Object=Result"));
1716  break;
1717 
1718  default:
1719  return pReport;
1720  }
1721 
1722  if (pReport) mData.pReportDefinitionList->add(pReport, true);
1723 
1724  return pReport;
1725 }
static const std::string TypeName[]
Definition: CCopasiTask.h:67
bool setTaskType(const CCopasiTask::Type &taskType)
void setTitle(bool title)
CReportDefinitionVector * pReportDefinitionList
void setSeparator(const CCopasiReportSeparator &Separator)
void setIsTable(bool table)
virtual bool add(const CType &src)
void setComment(const std::string &comment)
std::vector< CRegisteredObjectName > * getFooterAddr()
std::vector< CRegisteredObjectName > * getBodyAddr()
std::vector< CRegisteredObjectName > * getHeaderAddr()
CCopasiTask * CCopasiDataModel::addTask ( const CCopasiTask::Type taskType)

Definition at line 1431 of file CCopasiDataModel.cpp.

References CCopasiVectorN< CType >::add(), CCopasiTask::crosssection, CCopasiTask::fluxMode, CCopasiTask::getProblem(), CCopasiTask::lna, CCopasiTask::lyap, CCopasiTask::mca, mData, CCopasiTask::moieties, CCopasiTask::optimization, CCopasiTask::parameterFitting, CCopasiDataModel::CData::pModel, pTask, CCopasiDataModel::CData::pTaskList, CCopasiTask::scan, CCopasiTask::sens, CCopasiProblem::setModel(), CCopasiTask::steadyState, CCopasiTask::timeCourse, and CCopasiTask::tssAnalysis.

Referenced by addDefaultTasks().

1432 {
1433  CCopasiTask * pTask = NULL;
1434 
1435  switch (taskType)
1436  {
1438  pTask = new CSteadyStateTask(mData.pTaskList);
1439  break;
1440 
1442  pTask = new CTrajectoryTask(mData.pTaskList);
1443  break;
1444 
1445  case CCopasiTask::scan:
1446  pTask = new CScanTask(mData.pTaskList);
1447  break;
1448 
1449  case CCopasiTask::fluxMode:
1450  pTask = new CEFMTask(mData.pTaskList);
1451  break;
1452 
1454  pTask = new COptTask(taskType, mData.pTaskList);
1455  break;
1456 
1458  pTask = new CFitTask(taskType, mData.pTaskList);
1459  break;
1460 
1461  case CCopasiTask::mca:
1462  pTask = new CMCATask(mData.pTaskList);
1463  static_cast< CMCAProblem * >(pTask->getProblem())->setSteadyStateRequested(true);
1464  break;
1465 
1466  case CCopasiTask::lna:
1467  pTask = new CLNATask(mData.pTaskList);
1468  static_cast< CLNAProblem * >(pTask->getProblem())->setSteadyStateRequested(true);
1469  break;
1470 
1471  case CCopasiTask::lyap:
1472  pTask = new CLyapTask(mData.pTaskList);
1473  break;
1474 
1475  case CCopasiTask::sens:
1476  pTask = new CSensTask(mData.pTaskList);
1477  break;
1478 
1480  pTask = new CTSSATask(mData.pTaskList);
1481  break;
1482 
1483  case CCopasiTask::moieties:
1484  pTask = new CMoietiesTask(taskType, mData.pTaskList);
1485  break;
1486 
1488  pTask = new CCrossSectionTask(mData.pTaskList);
1489  break;
1490 
1491  default:
1492  return pTask;
1493  }
1494 
1495  pTask->getProblem()->setModel(mData.pModel);
1496  mData.pTaskList->add(pTask);
1497 
1498  return pTask;
1499 }
CCopasiProblem * getProblem()
virtual bool setModel(CModel *pModel)
CTSSATask * pTask
virtual bool add(const CType &src)
CCopasiVectorN< CCopasiTask > * pTaskList
bool CCopasiDataModel::appendDependentTasks ( std::set< const CCopasiObject * >  candidates,
std::set< const CCopasiObject * > &  dependentTasks 
) const

Appends pointers to tasks, which are dependent on any of the candidates to the list dependentTasks.

Parameters
std::set<const CCopasiObject * > candidates
std::set<const CCopasiObject * > & dependentTasks
Returns
bool functionsAppended

Definition at line 1512 of file CCopasiDataModel.cpp.

References CCopasiVector< T >::begin(), CCopasiVector< T >::end(), mData, and CCopasiDataModel::CData::pTaskList.

Referenced by CQReportDefinition::btnDeleteReportClicked(), CQMessageBox::confirmDelete(), and CQReportDM::removeRows().

1514 {
1515  size_t Size = dependentTasks.size();
1516 
1517  std::set< const CCopasiObject * >::const_iterator it = candidates.begin();
1518  std::set< const CCopasiObject * >::const_iterator end = candidates.end();
1519 
1522 
1523  for (; it != end; ++it)
1524  {
1525  const CReportDefinition * pReportDefinition = dynamic_cast< const CReportDefinition * >(*it);
1526 
1527  if (pReportDefinition == NULL)
1528  continue;
1529 
1530  itTask = mData.pTaskList->begin();
1531 
1532  for (; itTask != endTask; ++itTask)
1533  {
1534  if ((*itTask)->getReport().getReportDefinition() == pReportDefinition)
1535  {
1536  dependentTasks.insert(*itTask);
1537  }
1538  }
1539  }
1540 
1541  return Size < dependentTasks.size();
1542 }
iterator begin()
iterator end()
CCopasiVectorN< CCopasiTask > * pTaskList
bool CCopasiDataModel::autoSave ( )

Definition at line 482 of file CCopasiDataModel.cpp.

References CDirEntry::baseName(), COptions::getValue(), CCopasiDataModel::CData::mAutoSaveNeeded, mData, CCopasiDataModel::CData::mSaveFileName, saveModel(), and CDirEntry::Separator.

483 {
484  if (!mData.mAutoSaveNeeded) return true;
485 
486  std::string AutoSave;
487 
488  COptions::getValue("Tmp", AutoSave);
489 
490  if (AutoSave == "") return false;
491 
492  AutoSave += CDirEntry::Separator + "tmp_";
493 
494  if (mData.mSaveFileName != "")
496  else
497  AutoSave += "untitled";
498 
499  AutoSave += ".cps";
500 
501  try
502  {
503  if (!saveModel(AutoSave, NULL, true, true)) return false;
504  }
505 
506  catch (...)
507  {
508  return false;
509  }
510 
511  mData.mAutoSaveNeeded = false;
512  return true;
513 }
static std::string baseName(const std::string &path)
Definition: CDirEntry.cpp:98
static const std::string Separator
Definition: CDirEntry.h:34
bool saveModel(const std::string &fileName, CProcessReport *pProcessReport, bool overwriteFile=false, const bool &autoSave=false)
static void getValue(const std::string &name, CType &value)
Definition: COptions.h:124
void CCopasiDataModel::changed ( const bool &  changed = true)
void CCopasiDataModel::commonAfterLoad ( CProcessReport pProcessReport,
const bool &  deleteOldData 
)
protected

Definition at line 2069 of file CCopasiDataModel.cpp.

References addDefaultReports(), addDefaultTasks(), CCopasiVector< T >::begin(), changed(), CModel::compileIfNecessary(), deleteOldData(), CCopasiVector< T >::end(), CCopasiMessage::getLastMessage(), CModel::getModelParameterSet(), mData, mOldData, CCopasiDataModel::CData::mWithGUI, CCopasiTask::NO_OUTPUT, CCopasiDataModel::CData::pCurrentSBMLDocument, CCopasiDataModel::CData::pGUI, CCopasiDataModel::CData::pListOfLayouts, CCopasiDataModel::CData::pModel, CCopasiDataModel::CData::pPlotDefinitionList, CCopasiDataModel::CData::pReportDefinitionList, CCopasiDataModel::CData::pTaskList, CModelEntity::setObjectParent(), CCopasiObject::setObjectParent(), CCopasiMessage::size(), CModel::updateInitialValues(), and CModelParameterSet::updateModel().

Referenced by importSBML(), importSBMLFromString(), loadModel(), and newModel().

2071 {
2072  if (mData.pModel == NULL)
2073  {
2074  mData.pModel = new CModel(this);
2075  }
2076 
2077  if (mData.pListOfLayouts == NULL)
2078  {
2079  mData.pListOfLayouts = new CListOfLayouts("ListOflayouts", this);
2080  }
2081 
2082  if (mData.pTaskList == NULL)
2083  {
2084  mData.pTaskList = new CCopasiVectorN< CCopasiTask >("TaskList", this);
2085  }
2086 
2087  if (mData.pReportDefinitionList == NULL)
2088  {
2089  mData.pReportDefinitionList = new CReportDefinitionVector("ReportDefinitions", this);
2090  }
2091 
2092  if (mData.pPlotDefinitionList == NULL)
2093  {
2094  mData.pPlotDefinitionList = new COutputDefinitionVector("OutputDefinitions", this);
2095  }
2096 
2097  if (mData.mWithGUI && mData.pGUI == NULL)
2098  {
2099  mData.pGUI = new SCopasiXMLGUI("GUI", this);
2100  }
2101 
2102  // We have at least one task of every type
2103  addDefaultTasks();
2105 
2106  if (mOldData.pModel != NULL &&
2108  {
2110  remove(mOldData.pModel);
2111  }
2112  else
2113  mOldData.pModel = NULL;
2114 
2115  if (mOldData.pTaskList != NULL &&
2117  {
2119  remove(mOldData.pTaskList);
2120  }
2121  else
2122  mOldData.pTaskList = NULL;
2123 
2124  if (mOldData.pReportDefinitionList != NULL &&
2126  {
2129  }
2130  else
2132 
2133  if (mOldData.pPlotDefinitionList != NULL &&
2135  {
2137  remove(mOldData.pPlotDefinitionList);
2138  }
2139  else
2141 
2142  if (mOldData.pListOfLayouts != NULL &&
2144  {
2146  remove(mOldData.pListOfLayouts);
2147  }
2148  else
2149  mOldData.pListOfLayouts = NULL;
2150 
2151  if (mOldData.pGUI != NULL &&
2152  mOldData.pGUI != mData.pGUI)
2153  {
2154  mOldData.pGUI->setObjectParent(NULL);
2155  remove(mOldData.pGUI);
2156  }
2157  else
2158  mOldData.pGUI = NULL;
2159 
2162 
2163 #ifdef COPASI_SEDML
2164 
2165  if (mOldData.pCurrentSEDMLDocument == mData.pCurrentSEDMLDocument)
2166  mOldData.pCurrentSEDMLDocument = NULL;
2167 
2168 #endif
2169 
2171 
2172  // We need to initialize all the task so that results are available
2173 
2174  // We suppress all errors and warnings
2175  size_t Size = CCopasiMessage::size();
2176 
2179 
2180  for (; it != end; ++it)
2181  {
2182  try
2183  {
2184  // need initialize, so that all objects are created for the
2185  // object browser
2186  (*it)->initialize(CCopasiTask::NO_OUTPUT, NULL, NULL);
2187 
2188  // but we should restore any possible changes made to the model
2189  // by the task, without updating the model
2190  bool update = (*it)->isUpdateModel();
2191  (*it)->setUpdateModel(false);
2192  (*it)->restore();
2193  (*it)->setUpdateModel(update);
2194  }
2195 
2196  catch (...) {}
2197  }
2198 
2199  // Remove error messages created by the task initialization as this may fail
2200  // due to incomplete task specification at this time.
2201  while (CCopasiMessage::size() > Size)
2203 
2204  if (mData.pModel)
2205  {
2206  mData.pModel->compileIfNecessary(pProcessReport);
2208  }
2209 
2210  changed(false);
2211 
2212  if (deleteOldData)
2213  {
2215  }
2216 }
virtual bool setObjectParent(const CCopasiContainer *pParent)
const CModelParameterSet & getModelParameterSet() const
Definition: CModel.cpp:1072
iterator begin()
CReportDefinitionVector * pReportDefinitionList
void changed(const bool &changed=true)
COutputDefinitionVector * pPlotDefinitionList
iterator end()
static size_t size()
CListOfLayouts * pListOfLayouts
CCopasiVectorN< CCopasiTask > * pTaskList
SBMLDocument * pCurrentSBMLDocument
virtual bool setObjectParent(const CCopasiContainer *pParent)
bool compileIfNecessary(CProcessReport *pProcessReport)
Definition: CModel.cpp:612
static CCopasiMessage getLastMessage()
bool updateInitialValues()
Definition: CModel.cpp:1461
Definition: CModel.h:50
virtual bool updateModel()
void CCopasiDataModel::deleteOldData ( )

Definition at line 1389 of file CCopasiDataModel.cpp.

References mOldData, CCopasiDataModel::CData::pCurrentSBMLDocument, pdelete, CCopasiDataModel::CData::pGUI, CCopasiDataModel::CData::pListOfLayouts, CCopasiDataModel::CData::pModel, CCopasiDataModel::CData::pPlotDefinitionList, CCopasiDataModel::CData::pReportDefinitionList, and CCopasiDataModel::CData::pTaskList.

Referenced by commonAfterLoad(), DataModelGUI::linkDataModelToGUI(), and ~CCopasiDataModel().

1390 {
1398 
1399 #ifdef COPASI_SEDML
1400  pdelete(mOldData.pCurrentSEDMLDocument);
1401 #endif
1402 }
#define pdelete(p)
Definition: copasi.h:215
CReportDefinitionVector * pReportDefinitionList
COutputDefinitionVector * pPlotDefinitionList
CListOfLayouts * pListOfLayouts
CCopasiVectorN< CCopasiTask > * pTaskList
SBMLDocument * pCurrentSBMLDocument
bool CCopasiDataModel::exportMathModel ( const std::string &  fileName,
CProcessReport pProcessReport,
const std::string &  filter,
bool  overwriteFile = false 
)

Definition at line 969 of file CCopasiDataModel.cpp.

References CCopasiVector< T >::begin(), CCopasiMessage::clearDeque(), CModel::compileIfNecessary(), CDirEntry::dirName(), CCopasiVector< T >::end(), CCopasiMessage::ERROR, CDirEntry::exist(), CODEExporter::exportToStream(), CLocaleString::fromUtf8(), CModel::getModelValues(), CDirEntry::isWritable(), MCDirEntry, MCODEExporter, mData, CCopasiDataModel::CData::pModel, and CCopasiMessage::WARNING.

Referenced by main().

971 {
973 
974  if (fileName == "") return false;
975 
976  if (CDirEntry::exist(fileName))
977  {
978  if (!overwriteFile)
979  {
981  MCDirEntry + 1,
982  fileName.c_str());
983  return false;
984  }
985 
986  if (!CDirEntry::isWritable(fileName))
987  {
989  MCDirEntry + 2,
990  fileName.c_str());
991  return false;
992  }
993  }
994  else if (!CDirEntry::isWritable(CDirEntry::dirName(fileName)))
995  {
997  MCDirEntry + 2,
998  fileName.c_str());
999  return false;
1000  }
1001 
1002  try
1003  {
1004  if (!mData.pModel->compileIfNecessary(pProcessReport))
1005  return false;
1006  }
1007 
1008  catch (...)
1009  {
1010  return false;
1011  }
1012 
1015 
1016  for (; it != end; ++it)
1017  if ((*it)->isUsed()) break;
1018 
1019  if (it != end)
1021 
1022  CODEExporter * pExporter = NULL;
1023 
1024  if (filter == "C Files (*.c)")
1025  {
1026  pExporter = new CODEExporterC;
1027  }
1028  else if (filter == "Berkeley Madonna Files (*.mmd)")
1029  {
1030  pExporter = new CODEExporterBM();
1031  }
1032  else if (filter == "XPPAUT (*.ode)")
1033  {
1034  pExporter = new CODEExporterXPPAUT;
1035  }
1036 
1037  if (pExporter == NULL)
1038  {
1039  return false;
1040  }
1041 
1042  std::ofstream os(CLocaleString::fromUtf8(fileName).c_str(), std::ios::out);
1043 
1044  if (!os.good())
1045  {
1047  MCDirEntry + 3,
1048  fileName.c_str());
1049  return false;
1050  }
1051 
1052  return pExporter->exportToStream(this, os);
1053 }
const CCopasiVectorN< CModelValue > & getModelValues() const
Definition: CModel.cpp:1060
iterator begin()
static void clearDeque()
static std::string dirName(const std::string &path)
Definition: CDirEntry.cpp:135
iterator end()
std::vector< CType * >::const_iterator const_iterator
Definition: CCopasiVector.h:57
#define MCODEExporter
static bool exist(const std::string &path)
Definition: CDirEntry.cpp:78
static bool isWritable(const std::string &path)
Definition: CDirEntry.cpp:95
#define MCDirEntry
bool exportToStream(const CCopasiDataModel *pDataModel, std::ostream &os)
bool compileIfNecessary(CProcessReport *pProcessReport)
Definition: CModel.cpp:612
static CLocaleString fromUtf8(const std::string &utf8)
std::string CCopasiDataModel::exportMathModelToString ( CProcessReport pProcessReport,
const std::string &  filter 
)

Definition at line 917 of file CCopasiDataModel.cpp.

References CCopasiVector< T >::begin(), CModel::compileIfNecessary(), CCopasiVector< T >::end(), CODEExporter::exportToStream(), CModel::getModelValues(), MCODEExporter, mData, CCopasiDataModel::CData::pModel, and CCopasiMessage::WARNING.

918 {
919  CODEExporter * pExporter = NULL;
920 
921  if (filter == "C Files (*.c)")
922  {
923  pExporter = new CODEExporterC;
924  }
925  else if (filter == "Berkeley Madonna Files (*.mmd)")
926  {
927  pExporter = new CODEExporterBM();
928  }
929  else if (filter == "XPPAUT (*.ode)")
930  {
931  pExporter = new CODEExporterXPPAUT;
932  }
933 
934  if (pExporter == NULL)
935  {
936  return "";
937  }
938 
939  try
940  {
941  if (!mData.pModel->compileIfNecessary(pProcessReport))
942  return "";
943  }
944 
945  catch (...)
946  {
947  return "";
948  }
949 
952 
953  for (; it != end; ++it)
954  if ((*it)->isUsed()) break;
955 
956  if (it != end)
958 
959  std::ostringstream os;
960 
961  if (!pExporter->exportToStream(this, os))
962  {
963  return "";
964  }
965 
966  return os.str();
967 }
const CCopasiVectorN< CModelValue > & getModelValues() const
Definition: CModel.cpp:1060
iterator begin()
iterator end()
std::vector< CType * >::const_iterator const_iterator
Definition: CCopasiVector.h:57
#define MCODEExporter
bool exportToStream(const CCopasiDataModel *pDataModel, std::ostream &os)
bool compileIfNecessary(CProcessReport *pProcessReport)
Definition: CModel.cpp:612
bool CCopasiDataModel::exportSBML ( const std::string &  fileName,
bool  overwriteFile = false,
int  sbmlLevel = 2,
int  sbmlVersion = 1,
bool  exportIncomplete = false,
bool  exportCOPASIMIRIAM = true,
CProcessReport pExportHandler = NULL 
)

Definition at line 798 of file CCopasiDataModel.cpp.

References CCopasiMessage::clearDeque(), CModel::compileIfNecessary(), CSBMLExporter::disownSBMLDocument(), CCopasiMessage::ERROR, CCopasiMessage::EXCEPTION, CDirEntry::exist(), CSBMLExporter::exportModel(), CDirEntry::fileName(), CCopasiMessage::getAllMessageText(), CSBMLExporter::getCOPASI2SBMLMap(), CSBMLExporter::getSBMLDocument(), COptions::getValue(), CDirEntry::isRelativePath(), CDirEntry::isWritable(), CDirEntry::makePathAbsolute(), MCDirEntry, CCopasiDataModel::CData::mCopasi2SBMLMap, mData, CCopasiDataModel::CData::mSBMLFileName, CCopasiDataModel::CData::pCurrentSBMLDocument, pdelete, CCopasiDataModel::CData::pModel, and CSBMLExporter::setExportCOPASIMIRIAM().

799 {
801 
802  if (fileName == "") return false;
803 
804  std::string PWD;
805  COptions::getValue("PWD", PWD);
806 
807  std::string FileName = fileName;
808 
809  if (CDirEntry::isRelativePath(FileName) &&
810  !CDirEntry::makePathAbsolute(FileName, PWD))
811  FileName = CDirEntry::fileName(FileName);
812 
813  if (CDirEntry::exist(FileName))
814  {
815  if (!overwriteFile)
816  {
818  MCDirEntry + 1,
819  FileName.c_str());
820  return false;
821  }
822 
823  if (!CDirEntry::isWritable(FileName))
824  {
826  MCDirEntry + 2,
827  FileName.c_str());
828  return false;
829  }
830  }
831 
833  static std::string failedCompile("The model cannot be exported, as it failed to compile. \n%s");
834 
835  try
836  {
837  if (!mData.pModel->compileIfNecessary(pExportHandler))
838  {
840  return false;
841  }
842  }
843  catch (CCopasiException&)
844  {
845  // don't add the exception twice
846  throw;
847  }
848  catch (...)
849  {
851  return false;
852  }
853 
854  CSBMLExporter exporter;
855  exporter.setExportCOPASIMIRIAM(exportCOPASIMIRIAM);
856  SBMLDocument* pOrigSBMLDocument = NULL;
857 
858 #if LIBSBML_VERSION >= 40100
859 
860  // if we export an L2 model to L3 or vice versa, we have to throw away any prior information
861  // about the current sbml document because libsbml does not support the conversion
862  // so we need to make sure that all model elements are created from scratch from the corresponding COPASI elements
863  if (this->mData.pCurrentSBMLDocument != NULL &&
864  ((this->mData.pCurrentSBMLDocument->getLevel() > 2 && sbmlLevel < 3) ||
865  (this->mData.pCurrentSBMLDocument->getLevel() < 3 && sbmlLevel > 2)
866  )
867  )
868  {
869  pOrigSBMLDocument = this->mData.pCurrentSBMLDocument;
870  this->mData.pCurrentSBMLDocument = NULL;
871  }
872 
873 #endif // LIBSBML_VERSION
874 
875  //exporter.setExportHandler(pExportHandler);
876  if (!exporter.exportModel(*this, FileName, sbmlLevel, sbmlVersion, overwriteFile)) return false;
877 
878  // only get the new model if it is not a Level 1 model
879  // During export to Level 1 the function definitions have been deleted and therefore
880  // all information assiociated with the function definitions will be gone if the user exports
881  // to Level 2 after having exported to Level 1
882  // This is actual vital to get around Bug 1086 as well.
883  // Once I have a Level 1 model, all calls to setName on an
884  // SBML object in that model also resets the id, which does not work with the current exporter
885  if ((sbmlLevel != 1 || mData.pCurrentSBMLDocument == NULL) && pOrigSBMLDocument == NULL)
886  {
887 
888  if (mData.pCurrentSBMLDocument != exporter.getSBMLDocument())
890 
891  // disown the SBML Document from the exporter so we don't have to copy it
892  exporter.disownSBMLDocument();
894  // we also need to get the new copasi2sbml map otherwise it contains invalid pointers
895  // since the objects
896  mData.mCopasi2SBMLMap.clear();
897  std::map<const CCopasiObject*, SBase*>::const_iterator it = exporter.getCOPASI2SBMLMap().begin();
898  std::map<const CCopasiObject*, SBase*>::const_iterator endit = exporter.getCOPASI2SBMLMap().end();
899 
900  while (it != endit)
901  {
902  mData.mCopasi2SBMLMap.insert(std::pair<CCopasiObject*, SBase*>(const_cast<CCopasiObject*>(it->first), it->second));
903  ++it;
904  }
905  }
906  // if we have saved the original SBML model somewhere
907  // we have to reset it
908  else if (pOrigSBMLDocument != NULL)
909  {
910  this->mData.pCurrentSBMLDocument = pOrigSBMLDocument;
911  }
912 
913  mData.mSBMLFileName = FileName;
914  return true;
915 }
#define pdelete(p)
Definition: copasi.h:215
static bool isRelativePath(const std::string &path)
Definition: CDirEntry.cpp:414
static std::string getAllMessageText(const bool &chronological=true)
static std::string fileName(const std::string &path)
Definition: CDirEntry.cpp:119
static void clearDeque()
SBMLDocument * getSBMLDocument()
Definition: CSBMLExporter.h:95
void setExportCOPASIMIRIAM(bool exportMIRIAM)
static bool exist(const std::string &path)
Definition: CDirEntry.cpp:78
static bool isWritable(const std::string &path)
Definition: CDirEntry.cpp:95
#define MCDirEntry
static void getValue(const std::string &name, CType &value)
Definition: COptions.h:124
SBMLDocument * pCurrentSBMLDocument
bool compileIfNecessary(CProcessReport *pProcessReport)
Definition: CModel.cpp:612
std::map< CCopasiObject *, SBase * > mCopasi2SBMLMap
void disownSBMLDocument()
static bool makePathAbsolute(std::string &relativePath, const std::string &absoluteTo)
Definition: CDirEntry.cpp:481
const std::map< const CCopasiObject *, SBase * > & getCOPASI2SBMLMap() const
bool exportModel(CCopasiDataModel &dataModel, const std::string &filename, unsigned int sbmlLevel=2, unsigned int sbmlVersion=1, bool overwrite=false)
std::string CCopasiDataModel::exportSBMLToString ( CProcessReport pExportHandler,
int  sbmlLevel,
int  sbmlVersion 
)

Definition at line 709 of file CCopasiDataModel.cpp.

References CCopasiMessage::clearDeque(), CModel::compileIfNecessary(), CSBMLExporter::disownSBMLDocument(), CCopasiMessage::EXCEPTION, CSBMLExporter::exportModelToString(), CCopasiMessage::getAllMessageText(), CSBMLExporter::getCOPASI2SBMLMap(), CSBMLExporter::getSBMLDocument(), CCopasiDataModel::CData::mCopasi2SBMLMap, mData, CCopasiDataModel::CData::pCurrentSBMLDocument, pdelete, CCopasiDataModel::CData::pModel, and CSBMLExporter::setExportCOPASIMIRIAM().

Referenced by test000054::test_bug1002(), test000055::test_bug1004(), test000057::test_bug1006(), test000058::test_bug1025_1(), test000058::test_bug1025_10(), test000058::test_bug1025_2(), test000058::test_bug1025_3(), test000058::test_bug1025_4(), test000058::test_bug1025_5(), test000058::test_bug1025_6(), test000058::test_bug1025_7(), test000058::test_bug1025_8(), test000058::test_bug1025_9(), test000076::test_bug1035_1(), test000076::test_bug1035_2(), test000076::test_bug1035_3(), test000067::test_bug1060(), test000068::test_bug1068(), test000069::test_bug1069(), test000070::test_bug1084(), test000071::test_bug1085(), test000072::test_bug1086(), test000074::test_bug1088(), test000081::test_bug1205(), test000089::test_bug1412(), test000093::test_bug1503_1(), test000093::test_bug1503_2(), test000100::test_bug1692_1(), test000100::test_bug1692_2(), test000101::test_bug1740(), test000102::test_bug1741(), test000103::test_bug1743_l2(), test000103::test_bug1743_l3(), test000050::test_bug894(), test000049::test_bug894(), test000048::test_bug919(), test000051::test_bug988(), test000060::test_bug_1026(), test000061::test_bug_1044(), test000091::test_delay_in_kinetic_law(), test000091::test_delay_in_kinetic_law_local_parameter(), test000082::test_export_delayAssignment_1(), test000082::test_export_delayAssignment_2(), test000082::test_export_delayAssignment_3(), test000082::test_export_delayAssignment_4(), test000082::test_export_delayAssignment_5(), test000082::test_export_delayAssignment_6(), test000077::test_export_dimensionless(), test000064::test_export_event_assignment_expression_and_hasOnlySubstanceUnits_1(), test000064::test_export_event_assignment_expression_and_hasOnlySubstanceUnits_2(), test000064::test_export_event_assignment_expression_and_hasOnlySubstanceUnits_3(), test000064::test_export_event_assignment_expression_and_hasOnlySubstanceUnits_4(), test000064::test_export_event_assignment_expression_and_hasOnlySubstanceUnits_5(), test000064::test_export_event_assignment_expression_and_hasOnlySubstanceUnits_6(), test000064::test_export_event_assignment_expression_and_hasOnlySubstanceUnits_7(), test000064::test_export_event_assignment_expression_and_hasOnlySubstanceUnits_8(), test000097::test_export_global_render_information(), test000097::test_export_local_render_information(), test000098::test_export_notes(), test000087::test_export_reaction_flux_reference_1(), test000087::test_export_reaction_flux_reference_2(), test000064::test_export_rule_expression_and_hasOnlySubstanceUnits_1(), test000064::test_export_rule_expression_and_hasOnlySubstanceUnits_2(), test000064::test_export_rule_expression_and_hasOnlySubstanceUnits_3(), test000064::test_export_rule_expression_and_hasOnlySubstanceUnits_4(), test000064::test_export_rule_expression_and_hasOnlySubstanceUnits_5(), test000064::test_export_rule_expression_and_hasOnlySubstanceUnits_6(), test000064::test_export_rule_expression_and_hasOnlySubstanceUnits_7(), test000064::test_export_rule_expression_and_hasOnlySubstanceUnits_8(), test000097::test_importexport_global_render_information(), test000097::test_importexport_local_render_information(), test000092::test_miriam_export_1(), test000092::test_miriam_export_2(), test000092::test_miriam_export_3(), test000092::test_miriam_export_4(), test000092::test_miriam_export_5(), test000092::test_miriam_export_6(), test000092::test_miriam_export_7(), test000092::test_miriam_export_8(), test000092::test_miriam_export_9(), test000097::test_readexport_global_render_information(), test000097::test_readexport_local_render_information(), test000059::test_unique_id_1(), test000059::test_unique_id_10(), test000059::test_unique_id_11(), test000059::test_unique_id_12(), test000059::test_unique_id_13(), test000059::test_unique_id_14(), test000059::test_unique_id_15(), test000059::test_unique_id_16(), test000059::test_unique_id_17(), test000059::test_unique_id_18(), test000059::test_unique_id_19(), test000059::test_unique_id_2(), test000059::test_unique_id_20(), test000059::test_unique_id_21(), test000059::test_unique_id_21_2(), test000059::test_unique_id_22(), test000059::test_unique_id_3(), test000059::test_unique_id_4(), test000059::test_unique_id_5(), test000059::test_unique_id_6(), test000059::test_unique_id_7(), test000059::test_unique_id_8(), test000059::test_unique_id_9(), Copasi2SBMLTranslator::translateFileToSBML(), and Copasi2SBMLTranslator::translateToSBML().

710 {
712  SBMLDocument* pOrigSBMLDocument = NULL;
713 
714 #if LIBSBML_VERSION >= 40100
715 
716  // if we export an L2 model to L3 or vice versa, we have to throw away any prior information
717  // about the current sbml document because libsbml does not support the conversion
718  // so we need to make sure that all model elements are created from scratch from the corresponding COPASI elements
719  if (this->mData.pCurrentSBMLDocument != NULL &&
720  ((this->mData.pCurrentSBMLDocument->getLevel() > 2 && sbmlLevel < 3) ||
721  (this->mData.pCurrentSBMLDocument->getLevel() < 3 && sbmlLevel > 2)
722  )
723  )
724  {
725  pOrigSBMLDocument = this->mData.pCurrentSBMLDocument;
726  this->mData.pCurrentSBMLDocument = NULL;
727  }
728 
729 #endif // LIBSBML_VERSION
731  static std::string failedCompile("The model cannot be exported, as it failed to compile. \n%s");
732 
733  try
734  {
735  if (!mData.pModel->compileIfNecessary(pExportHandler))
736  {
738  return "";
739  }
740  }
741  catch (CCopasiException&)
742  {
743  // don't add the exception twice
744  throw;
745  }
746  catch (...)
747  {
749  return "";
750  }
751 
752  CSBMLExporter exporter;
753  // Per default export COPASIs MIRIAM annotation.
754  // This should eventually be determined by a setting in the preferences
755  // dialog.
756  exporter.setExportCOPASIMIRIAM(true);
757  std::string str = exporter.exportModelToString(*this, sbmlLevel, sbmlVersion);
758 
759  // only get the new model if it is not a Level 1 model
760  // During export to Level 1 the function definitions have been deleted and therefore
761  // all information assiociated with the function definitions will be gone if the user exports
762  // to Level 2 after having exported to Level 1
763  // This is actual vital to get around Bug 1086 as well.
764  // Once I have a Level 1 model, all calls to setName on an
765  // SBML object in that model also resets the id, which does not work with the current exporter
766  if ((sbmlLevel != 1 || mData.pCurrentSBMLDocument == NULL) && pOrigSBMLDocument == NULL)
767  {
768  if (mData.pCurrentSBMLDocument != exporter.getSBMLDocument())
769  {
771  }
772 
773  // disown the SBML Document from the exporter so we don't have to copy it
774  exporter.disownSBMLDocument();
776  // we also need to get the new copasi2sbml map otherwise it contains invalid pointers
777  // since the objects
778  mData.mCopasi2SBMLMap.clear();
779  std::map<const CCopasiObject*, SBase*>::const_iterator it = exporter.getCOPASI2SBMLMap().begin();
780  std::map<const CCopasiObject*, SBase*>::const_iterator endit = exporter.getCOPASI2SBMLMap().end();
781 
782  while (it != endit)
783  {
784  mData.mCopasi2SBMLMap.insert(std::pair<CCopasiObject*, SBase*>(const_cast<CCopasiObject*>(it->first), it->second));
785  ++it;
786  }
787  }
788  // if we have saved the original SBML model somewhere
789  // we have to reset it
790  else if (pOrigSBMLDocument != NULL)
791  {
792  mData.pCurrentSBMLDocument = pOrigSBMLDocument;
793  }
794 
795  return str;
796 }
#define pdelete(p)
Definition: copasi.h:215
static std::string getAllMessageText(const bool &chronological=true)
static void clearDeque()
SBMLDocument * getSBMLDocument()
Definition: CSBMLExporter.h:95
void setExportCOPASIMIRIAM(bool exportMIRIAM)
const std::string exportModelToString(CCopasiDataModel &dataModel, unsigned int sbmlLevel, unsigned int sbmlVersion)
SBMLDocument * pCurrentSBMLDocument
bool compileIfNecessary(CProcessReport *pProcessReport)
Definition: CModel.cpp:612
std::map< CCopasiObject *, SBase * > mCopasi2SBMLMap
void disownSBMLDocument()
const std::map< const CCopasiObject *, SBase * > & getCOPASI2SBMLMap() const
std::map< CCopasiObject *, SBase * > & CCopasiDataModel::getCopasi2SBMLMap ( )
SBMLDocument * CCopasiDataModel::getCurrentSBMLDocument ( )

Definition at line 1835 of file CCopasiDataModel.cpp.

References mData, and CCopasiDataModel::CData::pCurrentSBMLDocument.

Referenced by CSBMLExporter::createSBMLDocument(), DataModelGUI::importCellDesigner(), stress_test::normalizeMath(), test000054::test_bug1002(), test000055::test_bug1004(), test000056::test_bug1005(), test000057::test_bug1006(), test000058::test_bug1025_1(), test000058::test_bug1025_10(), test000058::test_bug1025_2(), test000058::test_bug1025_3(), test000058::test_bug1025_4(), test000058::test_bug1025_5(), test000058::test_bug1025_6(), test000058::test_bug1025_7(), test000058::test_bug1025_8(), test000058::test_bug1025_9(), test000076::test_bug1035_1(), test000076::test_bug1035_2(), test000076::test_bug1035_3(), test000067::test_bug1060(), test000068::test_bug1068(), test000069::test_bug1069(), test000071::test_bug1085(), test000081::test_bug1205(), test000089::test_bug1412(), test000093::test_bug1503_1(), test000093::test_bug1503_2(), test000049::test_bug894(), test000050::test_bug894(), test000048::test_bug919(), test000051::test_bug988(), test000060::test_bug_1026(), test000061::test_bug_1044(), test000091::test_delay_in_kinetic_law(), test000091::test_delay_in_kinetic_law_local_parameter(), test000082::test_export_delayAssignment_1(), test000082::test_export_delayAssignment_2(), test000082::test_export_delayAssignment_3(), test000082::test_export_delayAssignment_4(), test000082::test_export_delayAssignment_5(), test000082::test_export_delayAssignment_6(), test000077::test_export_dimensionless(), test000064::test_export_event_assignment_expression_and_hasOnlySubstanceUnits_1(), test000064::test_export_event_assignment_expression_and_hasOnlySubstanceUnits_2(), test000064::test_export_event_assignment_expression_and_hasOnlySubstanceUnits_3(), test000064::test_export_event_assignment_expression_and_hasOnlySubstanceUnits_4(), test000064::test_export_event_assignment_expression_and_hasOnlySubstanceUnits_5(), test000064::test_export_event_assignment_expression_and_hasOnlySubstanceUnits_6(), test000064::test_export_event_assignment_expression_and_hasOnlySubstanceUnits_7(), test000064::test_export_event_assignment_expression_and_hasOnlySubstanceUnits_8(), test000087::test_export_reaction_flux_reference_1(), test000087::test_export_reaction_flux_reference_2(), test000064::test_export_rule_expression_and_hasOnlySubstanceUnits_1(), test000064::test_export_rule_expression_and_hasOnlySubstanceUnits_2(), test000064::test_export_rule_expression_and_hasOnlySubstanceUnits_3(), test000064::test_export_rule_expression_and_hasOnlySubstanceUnits_4(), test000064::test_export_rule_expression_and_hasOnlySubstanceUnits_5(), test000064::test_export_rule_expression_and_hasOnlySubstanceUnits_6(), test000064::test_export_rule_expression_and_hasOnlySubstanceUnits_7(), test000064::test_export_rule_expression_and_hasOnlySubstanceUnits_8(), test000075::test_import_time_dependent_function_definition(), test000092::test_miriam_export_7(), test000094::test_notrequired_package(), test000059::test_unique_id_1(), test000059::test_unique_id_10(), test000059::test_unique_id_11(), test000059::test_unique_id_12(), test000059::test_unique_id_13(), test000059::test_unique_id_14(), test000059::test_unique_id_15(), test000059::test_unique_id_16(), test000059::test_unique_id_17(), test000059::test_unique_id_18(), test000059::test_unique_id_19(), test000059::test_unique_id_2(), test000059::test_unique_id_20(), test000059::test_unique_id_21(), test000059::test_unique_id_21_2(), test000059::test_unique_id_22(), test000059::test_unique_id_3(), test000059::test_unique_id_4(), test000059::test_unique_id_5(), test000059::test_unique_id_6(), test000059::test_unique_id_7(), test000059::test_unique_id_8(), and test000059::test_unique_id_9().

1836 {
1837  return mData.pCurrentSBMLDocument;
1838 }
SBMLDocument * pCurrentSBMLDocument
CCopasiObject * CCopasiDataModel::getDataObject ( const CCopasiObjectName CN) const

Retrieve the data object with the given CN

Parameters
constCCopasiObjectName & CN
Returns
CCopasiObject * pObject

Definition at line 1947 of file CCopasiDataModel.cpp.

References CCopasiContainer::getObject().

Referenced by CQPlotSubwidget::addCurve2D(), CSEDMLExporter::createDataGenerators(), CScanItem::CScanItem(), CQOptimizationResult::enterProtected(), CQFittingResult::enterProtected(), CODEExporter::exportExpression(), CSBMLExporter::findModelEntityDependencies(), CArrayAnnotation::getAnnotationsString(), CExperimentObjectMap::CDataColumn::getDefaultScale(), CExpression::getNodeObject(), CSensItem::getSingleObjectDisplayName(), COptItem::getStartValue(), CSensItem::getVariablesPointerList(), CScanWidgetRandom::load(), CScanWidgetScan::load(), Curve2DWidget::LoadFromCurveSpec(), BandedGraphWidget::LoadFromCurveSpec(), HistoWidget::LoadFromCurveSpec(), CQFittingItemWidget::loadSelection(), CQExperimentData::loadTable(), SensitivitiesWidget::loadTask(), CQSimpleSelectionTree::populateTree(), CQReportListItem::refreshText(), COptItem::setObjectCN(), CQFittingItemWidget::setTableText(), CQExperimentData::slotTypeChanged(), and CEvaluationNodeObject::toAST().

1948 {
1949  return dynamic_cast< CCopasiObject *>(const_cast< CObjectInterface * >(getObject(CN)));
1950 }
virtual const CObjectInterface * getObject(const CCopasiObjectName &cn) const
const std::string & CCopasiDataModel::getFileName ( ) const
SCopasiXMLGUI * CCopasiDataModel::getGUI ( )

Definition at line 1815 of file CCopasiDataModel.cpp.

References CCopasiDataModel::CData::isValid(), mData, mOldData, and CCopasiDataModel::CData::pGUI.

Referenced by SliderDialog::getCSlidersForObject(), and save_cps_model_to_stream().

1816 {
1817  if (mData.isValid())
1818  return mData.pGUI;
1819 
1820  return mOldData.pGUI;
1821 }
CListOfLayouts * CCopasiDataModel::getListOfLayouts ( )

Definition at line 1807 of file CCopasiDataModel.cpp.

References CCopasiDataModel::CData::isValid(), mData, mOldData, and CCopasiDataModel::CData::pListOfLayouts.

Referenced by CQNewMainWindow::addGlobalRenderInfoItemsToList(), test000097::addGlobalRenderInformation(), test000097::addLocalRenderInformation(), test000097::createModel(), CSBMLExporter::exportModelToString(), Arguments::handleCommandLine(), DataModelGUI::importCellDesigner(), CQLayoutScene::initializeResolver(), save_cps_model_to_stream(), CQLayoutsWidget::slotBtnNewClicked(), CQLayoutView::slotLayoutChanged(), CQNewMainWindow::slotLayoutChanged(), CQNewMainWindow::slotRenderInfoChanged(), CQLayoutView::slotRenderInformationChanged(), test000097::test_import_global_render_information(), test000097::test_import_local_render_information(), test000097::test_importexport_global_render_information(), test000097::test_importexport_local_render_information(), test000097::test_importwrite_global_render_information(), test000097::test_importwrite_local_render_information(), test000097::test_read_global_render_information(), test000097::test_read_local_render_information(), test000097::test_readexport_global_render_information(), test000097::test_readexport_local_render_information(), test000097::test_readwrite_global_render_information(), test000097::test_readwrite_local_render_information(), CQGLLayoutPainter::update(), updateLayoutList(), CQNewMainWindow::updateLayoutList(), updateRenderInformationList(), and CQNewMainWindow::updateRenderInformationList().

1808 {
1809  if (mData.isValid())
1810  return mData.pListOfLayouts;
1811 
1812  return mOldData.pListOfLayouts;
1813 }
CListOfLayouts * pListOfLayouts
const CListOfLayouts * CCopasiDataModel::getListOfLayouts ( ) const

Definition at line 1799 of file CCopasiDataModel.cpp.

References CCopasiDataModel::CData::isValid(), mData, mOldData, and CCopasiDataModel::CData::pListOfLayouts.

1800 {
1801  if (mData.isValid())
1802  return mData.pListOfLayouts;
1803 
1804  return mOldData.pListOfLayouts;
1805 }
CListOfLayouts * pListOfLayouts
CModel * CCopasiDataModel::getModel ( )

Definition at line 1407 of file CCopasiDataModel.cpp.

References CCopasiDataModel::CData::isValid(), mData, mOldData, and CCopasiDataModel::CData::pModel.

Referenced by CQPlotSubwidget::addCurve2D(), CCopasiXML::buildFunctionList(), CExperiment::calculateStatistics(), CSBMLExporter::check_for_spatial_size_units(), CSBMLExporter::checkForEvents(), CSBMLExporter::checkForInitialAssignments(), CSBMLExporter::checkForODESpeciesInNonfixedCompartment(), CSBMLExporter::checkForPiecewiseFunctions(), CSBMLExporter::checkForUnsupportedObjectReferences(), CSBMLExporter::collectIds(), CTimeSeries::compile(), COutputHandler::compileRefresh(), CQMessageBox::confirmDelete(), CQSpeciesDetail::copy(), CQCompartment::copy(), ReactionsWidget1::copy(), CSBMLExporter::createAreaUnit(), CSBMLExporter::createCompartments(), CSEDMLExporter::createDataGenerators(), CSBMLExporter::createEvents(), CSBMLExporter::createLengthUnit(), CSBMLExporter::createMetabolites(), test000097::createModel(), CSBMLExporter::createParameters(), createParameterSetsForExperiment(), CSBMLExporter::createReactions(), CSBMLExporter::createSBMLDocument(), CSEDMLExporter::createSEDMLDocument(), CSBMLExporter::createSubstanceUnit(), CSBMLExporter::createTimeUnit(), CSBMLExporter::createVolumeUnit(), CQPlotSubwidget::deletePlot(), CQNewMainWindow::elementaryModeTriggeredSlot(), CQLayoutsWidget::enterProtected(), CODEExporter::exportExpression(), CODEExporter::exportObjectNodesFromModel(), CODEExporter::exportToStream(), CSBMLExporter::findAvogadro(), findObjectByDisplayName(), SliderDialog::getCSlidersForObject(), getQuantityParameterOrValue(), QConservedSpeciesAnimation::getScales(), CSensItem::getVariablesPointerList(), SEDMLUtils::getXPathForObject(), CSBMLExporter::hasVolumeAssignment(), QConservedSpeciesAnimation::initialize(), QFluxModeAnimation::initialize(), QTimeCourseAnimation::initialize(), CTSSAMethod::initializeIntegrationsParameter(), CLsodaMethod::initializeParameter(), CScanTask::initSubtask(), CQSpecieDM::insertRows(), CSBMLExporter::isModelSBMLCompatible(), CSlider::isValid(), CQMoietiesTaskResult::load(), CSteadyStateProblem::load(), CQBrowserPaneDM::load(), CTrajectoryProblem::load(), FunctionWidget1::loadParameterTable(), main(), stress_test::normalizeAndSimplifyExpressions(), CQPlotDM::removeRows(), CQReactionDM::removeRows(), CQFunctionDM::removeRows(), CQEventDM::removeRows(), CQGlobalQuantityDM::removeRows(), CQCompartmentDM::removeRows(), CQSpecieDM::removeRows(), CSBMLExporter::replace_local_parameters(), CSBMLExporter::replaceSpeciesReferences(), CSBMLExporter::restore_local_parameters(), CQFittingWidget::runTask(), save_cps_model_to_stream(), ReactionsWidget1::saveToReaction(), CQReactionDM::setEquation(), CSlider::setSliderObject(), CQCrossSectionTaskWidget::showUnits(), CQTrajectoryWidget::showUnits(), CQPlotsWidget::slotBtnActivateAllClicked(), CQPlotsWidget::slotBtnDeactivateAllClicked(), ReactionsWidget1::slotBtnDelete(), CQCompartment::slotBtnDelete(), CQModelValue::slotBtnDelete(), CQEventWidget1::slotBtnDelete(), ReactionsWidget1::slotBtnNew(), CQSpeciesDetail::slotBtnNew(), CQLayoutsWidget::slotBtnNewClicked(), CQPlotsWidget::slotDoubleClicked(), CQReactionsWidget::slotDoubleClicked(), CQReportsWidget::slotDoubleClicked(), CQCompartmentsWidget::slotDoubleClicked(), CQEventsWidget::slotDoubleClicked(), CQGlobalQuantitiesWidget::slotDoubleClicked(), CQSpeciesWidget::slotDoubleClicked(), CQFittingWidget::taskFinishedEvent(), test000053::test1_bug1000(), test000053::test2_bug1000(), test000053::test3_bug1000(), test000053::test4_bug1000(), test000053::test5_bug1000(), test000054::test_bug1002(), test000055::test_bug1004(), test000057::test_bug1006(), test000058::test_bug1025_1(), test000058::test_bug1025_10(), test000058::test_bug1025_2(), test000058::test_bug1025_3(), test000058::test_bug1025_4(), test000058::test_bug1025_5(), test000058::test_bug1025_6(), test000058::test_bug1025_7(), test000058::test_bug1025_8(), test000058::test_bug1025_9(), test000076::test_bug1035_1(), test000076::test_bug1035_2(), test000076::test_bug1035_3(), test000067::test_bug1060(), test000068::test_bug1068(), test000069::test_bug1069(), test000071::test_bug1085(), test000073::test_bug1087(), test000081::test_bug1205(), test000089::test_bug1412(), test000093::test_bug1503_1(), test000093::test_bug1503_2(), test000099::test_bug1675(), test000103::test_bug1743_l2(), test000103::test_bug1743_l3(), test000049::test_bug894(), test000050::test_bug894(), test000048::test_bug919(), test000051::test_bug988(), test000052::test_bug988(), test000060::test_bug_1026(), test000061::test_bug_1044(), test000047::test_delay(), test000091::test_delay_in_kinetic_law(), test000091::test_delay_in_kinetic_law_local_parameter(), test000063::test_events_1(), test000082::test_export_delayAssignment_1(), test000082::test_export_delayAssignment_2(), test000082::test_export_delayAssignment_3(), test000082::test_export_delayAssignment_4(), test000082::test_export_delayAssignment_5(), test000082::test_export_delayAssignment_6(), test000077::test_export_dimensionless(), test000064::test_export_event_assignment_expression_and_hasOnlySubstanceUnits_1(), test000064::test_export_event_assignment_expression_and_hasOnlySubstanceUnits_2(), test000064::test_export_event_assignment_expression_and_hasOnlySubstanceUnits_3(), test000064::test_export_event_assignment_expression_and_hasOnlySubstanceUnits_4(), test000064::test_export_event_assignment_expression_and_hasOnlySubstanceUnits_5(), test000064::test_export_event_assignment_expression_and_hasOnlySubstanceUnits_6(), test000064::test_export_event_assignment_expression_and_hasOnlySubstanceUnits_7(), test000064::test_export_event_assignment_expression_and_hasOnlySubstanceUnits_8(), test000087::test_export_reaction_flux_reference_1(), test000087::test_export_reaction_flux_reference_2(), test000064::test_export_rule_expression_and_hasOnlySubstanceUnits_1(), test000064::test_export_rule_expression_and_hasOnlySubstanceUnits_2(), test000064::test_export_rule_expression_and_hasOnlySubstanceUnits_3(), test000064::test_export_rule_expression_and_hasOnlySubstanceUnits_4(), test000064::test_export_rule_expression_and_hasOnlySubstanceUnits_5(), test000064::test_export_rule_expression_and_hasOnlySubstanceUnits_6(), test000064::test_export_rule_expression_and_hasOnlySubstanceUnits_7(), test000064::test_export_rule_expression_and_hasOnlySubstanceUnits_8(), test000021::test_hasOnlySubstanceUnits(), test000022::test_hasOnlySubstanceUnits(), test000023::test_hasOnlySubstanceUnits(), test000024::test_hasOnlySubstanceUnits(), test000025::test_hasOnlySubstanceUnits(), test000026::test_hasOnlySubstanceUnits(), test000027::test_hasOnlySubstanceUnits(), test000028::test_hasOnlySubstanceUnits(), test000029::test_hasOnlySubstanceUnits(), test000030::test_hasOnlySubstanceUnits(), test000031::test_hasOnlySubstanceUnits(), test000032::test_hasOnlySubstanceUnits(), test000033::test_hasOnlySubstanceUnits(), test000034::test_hasOnlySubstanceUnits(), test000035::test_hasOnlySubstanceUnits(), test000036::test_hasOnlySubstanceUnits(), test000037::test_hasOnlySubstanceUnits(), test000038::test_hasOnlySubstanceUnits(), test000039::test_hasOnlySubstanceUnits(), test000040::test_hasOnlySubstanceUnits(), test000041::test_hasOnlySubstanceUnits(), test000042::test_hasOnlySubstanceUnits(), test000043::test_hasOnlySubstanceUnits(), test000088::test_import_assignment_without_expression(), test000086::test_import_compartment_units_1(), test000084::test_import_compartment_units_1(), test000083::test_import_compartment_units_1(), test000085::test_import_compartment_units_1(), test000086::test_import_compartment_units_10(), test000083::test_import_compartment_units_10(), test000084::test_import_compartment_units_10(), test000085::test_import_compartment_units_10(), test000086::test_import_compartment_units_11(), test000083::test_import_compartment_units_11(), test000084::test_import_compartment_units_11(), test000085::test_import_compartment_units_11(), test000083::test_import_compartment_units_12(), test000085::test_import_compartment_units_12(), test000084::test_import_compartment_units_12(), test000083::test_import_compartment_units_13(), test000085::test_import_compartment_units_13(), test000084::test_import_compartment_units_13(), test000083::test_import_compartment_units_14(), test000085::test_import_compartment_units_14(), test000084::test_import_compartment_units_14(), test000084::test_import_compartment_units_15(), test000085::test_import_compartment_units_15(), test000083::test_import_compartment_units_15(), test000083::test_import_compartment_units_16(), test000085::test_import_compartment_units_16(), test000084::test_import_compartment_units_16(), test000083::test_import_compartment_units_17(), test000084::test_import_compartment_units_17(), test000085::test_import_compartment_units_17(), test000083::test_import_compartment_units_18(), test000085::test_import_compartment_units_18(), test000084::test_import_compartment_units_18(), test000084::test_import_compartment_units_19(), test000085::test_import_compartment_units_19(), test000083::test_import_compartment_units_19(), test000086::test_import_compartment_units_2(), test000084::test_import_compartment_units_2(), test000085::test_import_compartment_units_2(), test000083::test_import_compartment_units_2(), test000083::test_import_compartment_units_20(), test000084::test_import_compartment_units_20(), test000085::test_import_compartment_units_20(), test000083::test_import_compartment_units_21(), test000084::test_import_compartment_units_21(), test000085::test_import_compartment_units_21(), test000086::test_import_compartment_units_3(), test000083::test_import_compartment_units_3(), test000085::test_import_compartment_units_3(), test000084::test_import_compartment_units_3(), test000086::test_import_compartment_units_4(), test000085::test_import_compartment_units_4(), test000084::test_import_compartment_units_4(), test000083::test_import_compartment_units_4(), test000086::test_import_compartment_units_5(), test000085::test_import_compartment_units_5(), test000084::test_import_compartment_units_5(), test000083::test_import_compartment_units_5(), test000086::test_import_compartment_units_6(), test000085::test_import_compartment_units_6(), test000084::test_import_compartment_units_6(), test000083::test_import_compartment_units_6(), test000086::test_import_compartment_units_7(), test000084::test_import_compartment_units_7(), test000083::test_import_compartment_units_7(), test000085::test_import_compartment_units_7(), test000086::test_import_compartment_units_8(), test000084::test_import_compartment_units_8(), test000085::test_import_compartment_units_8(), test000083::test_import_compartment_units_8(), test000086::test_import_compartment_units_9(), test000084::test_import_compartment_units_9(), test000083::test_import_compartment_units_9(), test000085::test_import_compartment_units_9(), test000082::test_import_delayAssignment_1(), test000082::test_import_delayAssignment_2(), test000082::test_import_delayAssignment_3(), test000082::test_import_delayAssignment_4(), test000082::test_import_delayAssignment_5(), test000082::test_import_delayAssignment_6(), test000082::test_import_delayAssignment_7(), test000082::test_import_delayAssignment_8(), test000077::test_import_dimensionless_1(), test000077::test_import_dimensionless_2(), test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_1(), test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_2(), test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_3(), test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_4(), test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_5(), test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_6(), test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_7(), test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_8(), test000088::test_import_eventassignment_without_expression(), test000079::test_import_fast(), test000088::test_import_initialassignment_without_expression(), test000095::test_import_l3_event_1(), test000095::test_import_l3_event_2(), test000095::test_import_l3_event_3(), test000095::test_import_l3_event_4(), test000095::test_import_l3_event_5(), test000098::test_import_notes(), test000087::test_import_reaction_flux_reference_2(), test000066::test_import_reaction_with_constant_flux(), test000066::test_import_reaction_with_constant_flux_function(), test000066::test_import_reaction_with_constant_flux_function_global_parameter(), test000066::test_import_reaction_with_constant_flux_global_parameter(), test000066::test_import_reaction_with_constant_flux_reversible(), test000066::test_import_reaction_with_constant_flux_reversible_function(), test000066::test_import_reaction_with_constant_flux_reversible_function_global_parameter(), test000066::test_import_reaction_with_constant_flux_reversible_global_parameter(), test000065::test_import_reaction_with_unsuitable_kinetic_1(), test000065::test_import_reaction_with_unsuitable_kinetic_2(), test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_1(), test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_2(), test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_3(), test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_4(), test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_5(), test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_6(), test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_7(), test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_8(), test000075::test_import_time_dependent_function_definition(), test000062::test_kineticlaw_without_math(), test000078::test_l2v4_import_unordered_functions(), test000080::test_mass_action_recognition_bug(), test000092::test_miriam_export_1(), test000092::test_miriam_export_2(), test000092::test_miriam_export_3(), test000092::test_miriam_export_4(), test000092::test_miriam_export_5(), test000092::test_miriam_export_6(), test000092::test_miriam_export_7(), test000092::test_miriam_export_8(), test000092::test_miriam_export_9(), test000092::test_miriam_import_1(), test000094::test_notrequired_package(), test000087::test_simulate_reaction_flux_reference_1(), test000045::test_stoichiometricExpression(), test000046::test_stoichiometricExpression(), test000044::test_stoichiometricExpression(), test000059::test_unique_id_1(), test000059::test_unique_id_10(), test000059::test_unique_id_11(), test000059::test_unique_id_12(), test000059::test_unique_id_13(), test000059::test_unique_id_14(), test000059::test_unique_id_15(), test000059::test_unique_id_16(), test000059::test_unique_id_17(), test000059::test_unique_id_18(), test000059::test_unique_id_19(), test000059::test_unique_id_2(), test000059::test_unique_id_20(), test000059::test_unique_id_21(), test000059::test_unique_id_21_2(), test000059::test_unique_id_22(), test000059::test_unique_id_3(), test000059::test_unique_id_4(), test000059::test_unique_id_5(), test000059::test_unique_id_6(), test000059::test_unique_id_7(), test000059::test_unique_id_8(), test000059::test_unique_id_9(), CQGLLayoutPainter::update(), and validate().

1408 {
1409  if (mData.isValid())
1410  return mData.pModel;
1411 
1412  return mOldData.pModel;
1413 }
const CModel * CCopasiDataModel::getModel ( ) const

Definition at line 1404 of file CCopasiDataModel.cpp.

References mData, and CCopasiDataModel::CData::pModel.

const COutputDefinitionVector * CCopasiDataModel::getPlotDefinitionList ( ) const
COutputDefinitionVector * CCopasiDataModel::getPlotDefinitionList ( )

Definition at line 1791 of file CCopasiDataModel.cpp.

References CCopasiDataModel::CData::isValid(), mData, mOldData, and CCopasiDataModel::CData::pPlotDefinitionList.

1792 {
1793  if (mData.isValid())
1794  return mData.pPlotDefinitionList;
1795 
1797 }
COutputDefinitionVector * pPlotDefinitionList
const std::string & CCopasiDataModel::getReferenceDirectory ( ) const

Definition at line 1952 of file CCopasiDataModel.cpp.

References mData, and CCopasiDataModel::CData::mReferenceDir.

Referenced by CQNewMainWindow::CQNewMainWindow(), and SBMLImporter::parseSBML().

1953 {
1954  return mData.mReferenceDir;
1955 }
const CReportDefinitionVector * CCopasiDataModel::getReportDefinitionList ( ) const
CReportDefinitionVector * CCopasiDataModel::getReportDefinitionList ( )

Definition at line 1775 of file CCopasiDataModel.cpp.

References CCopasiDataModel::CData::isValid(), mData, mOldData, and CCopasiDataModel::CData::pReportDefinitionList.

1776 {
1777  if (mData.isValid())
1779 
1781 }
CReportDefinitionVector * pReportDefinitionList
const std::string & CCopasiDataModel::getSBMLFileName ( ) const
CCopasiVectorN< CCopasiTask > * CCopasiDataModel::getTaskList ( )

Definition at line 1415 of file CCopasiDataModel.cpp.

References CCopasiDataModel::CData::isValid(), mData, mOldData, and CCopasiDataModel::CData::pTaskList.

Referenced by CQNewMainWindow::checkForElementaryModesSlot(), COutputAssistant::createDefaultOutput(), CSEDMLExporter::createScanTask(), CSEDMLExporter::createSteadyStateTask(), CSEDMLExporter::createTasks(), CSEDMLExporter::createTimeCourseTask(), CQNewMainWindow::elementaryModeTriggeredSlot(), CFitProblem::elevateChildren(), CQFittingResult::enterProtected(), QFluxModeAnimation::getScales(), QTimeCourseAnimation::getScales(), CMCAProblem::getSubTask(), SEDMLImporter::importTasks(), CFitProblem::initialize(), QFluxModeAnimation::initialize(), CSensMethod::initialize(), CNewtonMethod::initialize(), QTimeCourseAnimation::initialize(), CScanTask::initSubtask(), CQBrowserPaneDM::load(), main(), CQSimpleSelectionTree::populateTree(), Arguments::prepareModel(), save_cps_model_to_stream(), CLNAProblem::setSteadyStateRequested(), CMCAProblem::setSteadyStateRequested(), test000087::test_simulate_reaction_flux_reference_1(), SEDMLImporter::updateCopasiTaskForSimulation(), and validate().

1416 {
1417  if (mData.isValid())
1418  return mData.pTaskList;
1419 
1420  return mOldData.pTaskList;
1421 }
CCopasiVectorN< CCopasiTask > * pTaskList
const CCopasiVectorN< CCopasiTask > * CCopasiDataModel::getTaskList ( ) const

Definition at line 1423 of file CCopasiDataModel.cpp.

References CCopasiDataModel::CData::isValid(), mData, mOldData, and CCopasiDataModel::CData::pTaskList.

1424 {
1425  if (mData.isValid())
1426  return mData.pTaskList;
1427 
1428  return mOldData.pTaskList;
1429 }
CCopasiVectorN< CCopasiTask > * pTaskList
bool CCopasiDataModel::importSBML ( const std::string &  fileName,
CProcessReport pImportHandler = NULL,
const bool &  deleteOldData = true 
)

Definition at line 603 of file CCopasiDataModel.cpp.

References CCopasiContainer::add(), CDirEntry::baseName(), CCopasiMessage::clearDeque(), commonAfterLoad(), SBMLImporter::deleteCopasiModel(), CDirEntry::dirName(), CDirEntry::fileName(), CLocaleString::fromUtf8(), CCopasiRootContainer::getFunctionList(), CCopasiTask::getProblem(), COptions::getValue(), CDirEntry::isRelativePath(), CDirEntry::makePathAbsolute(), CCopasiDataModel::CData::mCopasi2SBMLMap, mData, CCopasiDataModel::CData::mFileType, CCopasiDataModel::CData::mReferenceDir, mRenameHandler, CCopasiDataModel::CData::mSaveFileName, CCopasiDataModel::CData::mSBMLFileName, CDirEntry::normalize(), CCopasiDataModel::CData::pCurrentSBMLDocument, CCopasiDataModel::CData::pListOfLayouts, CCopasiDataModel::CData::pModel, popData(), CCopasiDataModel::CData::pTaskList, pushData(), SBMLImporter::readSBML(), SBMLImporter::restoreFunctionDB(), SBML, CDirEntry::Separator, CDataModelRenameHandler::setEnabled(), SBMLImporter::setImportCOPASIMIRIAM(), SBMLImporter::setImportHandler(), and CDirEntry::suffix().

Referenced by Arguments::handleCommandLine(), main(), and stress_test::normalizeMath().

606 {
607  // During load no objects will be renamed;
608  mRenameHandler.setEnabled(false);
610 
611  std::string PWD;
612  COptions::getValue("PWD", PWD);
613 
614  std::string FileName = fileName;
615 
616  if (CDirEntry::isRelativePath(FileName) &&
617  !CDirEntry::makePathAbsolute(FileName, PWD))
618  FileName = CDirEntry::fileName(FileName);
619 
620  std::ifstream File(CLocaleString::fromUtf8(FileName).c_str());
621 
622  SBMLImporter importer;
623  // Right now we always import the COPASI MIRIAM annotation if it is there.
624  // Later this will be settable by the user in the preferences dialog
625  importer.setImportCOPASIMIRIAM(true);
626  importer.setImportHandler(pImportHandler);
627 
628  CModel* pModel = NULL;
629 
630  SBMLDocument * pSBMLDocument = NULL;
631  std::map<CCopasiObject*, SBase*> Copasi2SBMLMap;
632 
633  CListOfLayouts * pLol = NULL;
634 
635  pushData();
636 
637  try
638  {
639  // store the file name and reference dir, so the importer can use it
642 
643  pModel = importer.readSBML(FileName, CCopasiRootContainer::getFunctionList(),
644  pSBMLDocument, Copasi2SBMLMap, pLol, this);
645  }
646 
647  catch (CCopasiException & except)
648  {
649  importer.restoreFunctionDB();
650  importer.deleteCopasiModel();
651  popData();
652 
654  throw except;
655  }
656 
657  if (pModel == NULL)
658  {
659  importer.restoreFunctionDB();
660  importer.deleteCopasiModel();
661  popData();
662 
664  return false;
665  }
666 
667  if (pModel != NULL)
668  {
669  mData.pModel = pModel;
670  add(mData.pModel, true);
671  }
672 
673  if (pLol != NULL)
674  {
675  mData.pListOfLayouts = pLol;
676  add(mData.pListOfLayouts, true);
677  }
678 
679  mData.pCurrentSBMLDocument = pSBMLDocument;
680  mData.mCopasi2SBMLMap = Copasi2SBMLMap;
681  mData.mFileType = SBML;
682 
683  commonAfterLoad(pImportHandler, deleteOldData);
684 
685  // when importing from SBML, allow continuation on simultaneous events.
686  static_cast<CTrajectoryProblem *>(
687  static_cast<CTrajectoryTask *>((*mData.pTaskList)["Time-Course"])->getProblem()
688  )->setContinueSimultaneousEvents(true);
689 
692  + CDirEntry::baseName(FileName);
693 
694  std::string Suffix = CDirEntry::suffix(FileName);
695 
696  if (strcasecmp(Suffix.c_str(), ".xml") != 0)
697  mData.mSaveFileName += Suffix;
698 
699  mData.mSaveFileName += ".cps";
701  // store the reference directory
704 
706  return true;
707 }
void setImportCOPASIMIRIAM(bool import)
void restoreFunctionDB()
CCopasiProblem * getProblem()
static bool isRelativePath(const std::string &path)
Definition: CDirEntry.cpp:414
void commonAfterLoad(CProcessReport *pProcessReport, const bool &deleteOldData)
void deleteCopasiModel()
void setImportHandler(CProcessReport *pHandler)
static std::string fileName(const std::string &path)
Definition: CDirEntry.cpp:119
static std::string baseName(const std::string &path)
Definition: CDirEntry.cpp:98
static void clearDeque()
static std::string dirName(const std::string &path)
Definition: CDirEntry.cpp:135
static const std::string Separator
Definition: CDirEntry.h:34
CListOfLayouts * pListOfLayouts
void setEnabled(const bool &enabled)
static CFunctionDB * getFunctionList()
static void getValue(const std::string &name, CType &value)
Definition: COptions.h:124
CCopasiVectorN< CCopasiTask > * pTaskList
SBMLDocument * pCurrentSBMLDocument
virtual bool add(CCopasiObject *pObject, const bool &adopt=true)
static std::string normalize(const std::string &path)
Definition: CDirEntry.cpp:560
std::map< CCopasiObject *, SBase * > mCopasi2SBMLMap
Definition: CModel.h:50
static CLocaleString fromUtf8(const std::string &utf8)
static bool makePathAbsolute(std::string &relativePath, const std::string &absoluteTo)
Definition: CDirEntry.cpp:481
CModel * readSBML(std::string filename, CFunctionDB *funDB, SBMLDocument *&pSBMLDocument, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap, CListOfLayouts *&prLol, CCopasiDataModel *pDataModel)
CDataModelRenameHandler mRenameHandler
static std::string suffix(const std::string &path)
Definition: CDirEntry.cpp:159
bool CCopasiDataModel::importSBMLFromString ( const std::string &  sbmlDocumentText,
CProcessReport pImportHandler = NULL,
const bool &  deleteOldData = true 
)

Definition at line 526 of file CCopasiDataModel.cpp.

References CCopasiContainer::add(), CCopasiMessage::clearDeque(), commonAfterLoad(), SBMLImporter::deleteCopasiModel(), CCopasiRootContainer::getFunctionList(), CCopasiTask::getProblem(), CCopasiDataModel::CData::mCopasi2SBMLMap, mData, CCopasiDataModel::CData::mFileType, mRenameHandler, SBMLImporter::parseSBML(), CCopasiDataModel::CData::pCurrentSBMLDocument, CCopasiDataModel::CData::pListOfLayouts, CCopasiDataModel::CData::pModel, popData(), CCopasiDataModel::CData::pTaskList, pushData(), SBMLImporter::restoreFunctionDB(), SBML, CDataModelRenameHandler::setEnabled(), SBMLImporter::setImportCOPASIMIRIAM(), and SBMLImporter::setImportHandler().

Referenced by test000053::test1_bug1000(), test000053::test2_bug1000(), test000053::test3_bug1000(), test000053::test4_bug1000(), test000053::test5_bug1000(), test000055::test_bug1004(), test000056::test_bug1005(), test000057::test_bug1006(), test000058::test_bug1025_1(), test000058::test_bug1025_2(), test000058::test_bug1025_3(), test000058::test_bug1025_4(), test000058::test_bug1025_5(), test000068::test_bug1068(), test000070::test_bug1084(), test000071::test_bug1085(), test000072::test_bug1086(), test000073::test_bug1087(), test000074::test_bug1088(), test000093::test_bug1503_1(), test000093::test_bug1503_2(), test000099::test_bug1675(), test000101::test_bug1740(), test000102::test_bug1741(), test000103::test_bug1743_l2(), test000103::test_bug1743_l3(), test000104::test_bug1744(), test000052::test_bug988(), test000060::test_bug_1026(), test000047::test_delay(), test000090::test_delay_in_function(), test000091::test_delay_in_kinetic_law(), test000091::test_delay_in_kinetic_law_local_parameter(), test000063::test_events_1(), test000032::test_hasOnlySubstanceUnits(), test000027::test_hasOnlySubstanceUnits(), test000035::test_hasOnlySubstanceUnits(), test000036::test_hasOnlySubstanceUnits(), test000023::test_hasOnlySubstanceUnits(), test000037::test_hasOnlySubstanceUnits(), test000028::test_hasOnlySubstanceUnits(), test000038::test_hasOnlySubstanceUnits(), test000024::test_hasOnlySubstanceUnits(), test000039::test_hasOnlySubstanceUnits(), test000029::test_hasOnlySubstanceUnits(), test000040::test_hasOnlySubstanceUnits(), test000030::test_hasOnlySubstanceUnits(), test000041::test_hasOnlySubstanceUnits(), test000042::test_hasOnlySubstanceUnits(), test000025::test_hasOnlySubstanceUnits(), test000031::test_hasOnlySubstanceUnits(), test000043::test_hasOnlySubstanceUnits(), test000033::test_hasOnlySubstanceUnits(), test000022::test_hasOnlySubstanceUnits(), test000026::test_hasOnlySubstanceUnits(), test000034::test_hasOnlySubstanceUnits(), test000021::test_hasOnlySubstanceUnits(), test000088::test_import_assignment_without_expression(), test000086::test_import_compartment_units_1(), test000084::test_import_compartment_units_1(), test000085::test_import_compartment_units_1(), test000083::test_import_compartment_units_1(), test000086::test_import_compartment_units_10(), test000084::test_import_compartment_units_10(), test000085::test_import_compartment_units_10(), test000083::test_import_compartment_units_10(), test000086::test_import_compartment_units_11(), test000084::test_import_compartment_units_11(), test000085::test_import_compartment_units_11(), test000083::test_import_compartment_units_11(), test000084::test_import_compartment_units_12(), test000085::test_import_compartment_units_12(), test000083::test_import_compartment_units_12(), test000084::test_import_compartment_units_13(), test000085::test_import_compartment_units_13(), test000083::test_import_compartment_units_13(), test000084::test_import_compartment_units_14(), test000085::test_import_compartment_units_14(), test000083::test_import_compartment_units_14(), test000084::test_import_compartment_units_15(), test000085::test_import_compartment_units_15(), test000083::test_import_compartment_units_15(), test000085::test_import_compartment_units_16(), test000084::test_import_compartment_units_16(), test000083::test_import_compartment_units_16(), test000084::test_import_compartment_units_17(), test000085::test_import_compartment_units_17(), test000083::test_import_compartment_units_17(), test000084::test_import_compartment_units_18(), test000085::test_import_compartment_units_18(), test000083::test_import_compartment_units_18(), test000083::test_import_compartment_units_19(), test000084::test_import_compartment_units_19(), test000085::test_import_compartment_units_19(), test000086::test_import_compartment_units_2(), test000084::test_import_compartment_units_2(), test000085::test_import_compartment_units_2(), test000083::test_import_compartment_units_2(), test000083::test_import_compartment_units_20(), test000084::test_import_compartment_units_20(), test000085::test_import_compartment_units_20(), test000083::test_import_compartment_units_21(), test000085::test_import_compartment_units_21(), test000084::test_import_compartment_units_21(), test000086::test_import_compartment_units_3(), test000084::test_import_compartment_units_3(), test000085::test_import_compartment_units_3(), test000083::test_import_compartment_units_3(), test000086::test_import_compartment_units_4(), test000084::test_import_compartment_units_4(), test000085::test_import_compartment_units_4(), test000083::test_import_compartment_units_4(), test000086::test_import_compartment_units_5(), test000084::test_import_compartment_units_5(), test000085::test_import_compartment_units_5(), test000083::test_import_compartment_units_5(), test000086::test_import_compartment_units_6(), test000084::test_import_compartment_units_6(), test000083::test_import_compartment_units_6(), test000085::test_import_compartment_units_6(), test000086::test_import_compartment_units_7(), test000084::test_import_compartment_units_7(), test000085::test_import_compartment_units_7(), test000083::test_import_compartment_units_7(), test000086::test_import_compartment_units_8(), test000084::test_import_compartment_units_8(), test000085::test_import_compartment_units_8(), test000083::test_import_compartment_units_8(), test000086::test_import_compartment_units_9(), test000085::test_import_compartment_units_9(), test000084::test_import_compartment_units_9(), test000083::test_import_compartment_units_9(), test000082::test_import_delayAssignment_1(), test000082::test_import_delayAssignment_2(), test000082::test_import_delayAssignment_3(), test000082::test_import_delayAssignment_4(), test000082::test_import_delayAssignment_5(), test000082::test_import_delayAssignment_6(), test000082::test_import_delayAssignment_7(), test000082::test_import_delayAssignment_8(), test000077::test_import_dimensionless_1(), test000077::test_import_dimensionless_2(), test000077::test_import_dimensionless_3(), test000077::test_import_dimensionless_4(), test000077::test_import_dimensionless_5(), test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_1(), test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_2(), test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_3(), test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_4(), test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_5(), test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_6(), test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_7(), test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_8(), test000088::test_import_eventassignment_without_expression(), test000079::test_import_fast(), test000097::test_import_global_render_information(), test000088::test_import_initialassignment_without_expression(), test000095::test_import_l3_event_1(), test000095::test_import_l3_event_2(), test000095::test_import_l3_event_3(), test000095::test_import_l3_event_4(), test000095::test_import_l3_event_5(), test000097::test_import_local_render_information(), test000098::test_import_notes(), test000087::test_import_reaction_flux_reference_1(), test000087::test_import_reaction_flux_reference_2(), test000087::test_import_reaction_flux_reference_3(), test000066::test_import_reaction_with_constant_flux(), test000066::test_import_reaction_with_constant_flux_function(), test000066::test_import_reaction_with_constant_flux_function_global_parameter(), test000066::test_import_reaction_with_constant_flux_global_parameter(), test000066::test_import_reaction_with_constant_flux_reversible(), test000066::test_import_reaction_with_constant_flux_reversible_function(), test000066::test_import_reaction_with_constant_flux_reversible_function_global_parameter(), test000066::test_import_reaction_with_constant_flux_reversible_global_parameter(), test000065::test_import_reaction_with_unsuitable_kinetic_1(), test000065::test_import_reaction_with_unsuitable_kinetic_2(), test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_1(), test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_2(), test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_3(), test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_4(), test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_5(), test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_6(), test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_7(), test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_8(), test000075::test_import_time_dependent_function_definition(), test000097::test_importexport_global_render_information(), test000097::test_importexport_local_render_information(), test000097::test_importwrite_global_render_information(), test000097::test_importwrite_local_render_information(), test000062::test_kineticlaw_without_math(), test000078::test_l2v4_import_unordered_functions(), test000080::test_mass_action_recognition_bug(), test000092::test_miriam_export_1(), test000092::test_miriam_export_2(), test000092::test_miriam_export_3(), test000092::test_miriam_export_4(), test000092::test_miriam_export_5(), test000092::test_miriam_export_6(), test000092::test_miriam_export_7(), test000092::test_miriam_export_8(), test000092::test_miriam_export_9(), test000092::test_miriam_import_1(), test000094::test_notrequired_package(), test000094::test_required_package(), test000087::test_simulate_reaction_flux_reference_1(), test000044::test_stoichiometricExpression(), test000046::test_stoichiometricExpression(), test000045::test_stoichiometricExpression(), test000059::test_unique_id_1(), test000059::test_unique_id_10(), test000059::test_unique_id_17(), test000059::test_unique_id_18(), test000059::test_unique_id_19(), test000059::test_unique_id_2(), test000059::test_unique_id_20(), test000059::test_unique_id_22(), test000059::test_unique_id_3(), test000059::test_unique_id_4(), test000059::test_unique_id_5(), test000059::test_unique_id_6(), test000059::test_unique_id_7(), test000059::test_unique_id_8(), test000059::test_unique_id_9(), and Copasi2SBMLTranslator::translate().

529 {
530  // During load no objects will be renamed;
531  mRenameHandler.setEnabled(false);
532 
533  pushData();
534 
536 
537  SBMLImporter importer;
538  // Right now we always import the COPASI MIRIAM annotation if it is there.
539  // Later this will be configurable by the user in the preferences dialog
540  importer.setImportCOPASIMIRIAM(true);
541  importer.setImportHandler(pImportHandler);
542  //mCopasi2SBMLMap.clear();
543  CModel* pModel = NULL;
544 
545  SBMLDocument * pSBMLDocument = NULL;
546  std::map<CCopasiObject*, SBase*> Copasi2SBMLMap;
547 
548  CListOfLayouts * pLol = NULL; //
549 
550  try
551  {
552  pModel = importer.parseSBML(sbmlDocumentText, CCopasiRootContainer::getFunctionList(),
553  pSBMLDocument, Copasi2SBMLMap, pLol, this);
554  }
555 
556  catch (CCopasiException & except)
557  {
558  importer.restoreFunctionDB();
559  importer.deleteCopasiModel();
560  popData();
561 
563  throw except;
564  }
565 
566  if (pModel == NULL)
567  {
568  importer.restoreFunctionDB();
569  importer.deleteCopasiModel();
570  popData();
571 
573  return false;
574  }
575 
576  if (pModel != NULL)
577  {
578  mData.pModel = pModel;
579  add(mData.pModel, true);
580  }
581 
582  if (pLol != NULL)
583  {
584  mData.pListOfLayouts = pLol;
585  add(mData.pListOfLayouts, true);
586  }
587 
588  mData.pCurrentSBMLDocument = pSBMLDocument;
589  mData.mCopasi2SBMLMap = Copasi2SBMLMap;
590  mData.mFileType = SBML;
591 
592  commonAfterLoad(pImportHandler, deleteOldData);
593 
594  // when importing from SBML, allow continuation on simultaneous events.
595  static_cast<CTrajectoryProblem *>(
596  static_cast<CTrajectoryTask *>((*mData.pTaskList)["Time-Course"])->getProblem()
597  )->setContinueSimultaneousEvents(true);
598 
600  return true;
601 }
void setImportCOPASIMIRIAM(bool import)
void restoreFunctionDB()
CCopasiProblem * getProblem()
void commonAfterLoad(CProcessReport *pProcessReport, const bool &deleteOldData)
void deleteCopasiModel()
void setImportHandler(CProcessReport *pHandler)
static void clearDeque()
CModel * parseSBML(const std::string &sbmlDocumentText, CFunctionDB *funDB, SBMLDocument *&pSBMLDocument, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap, CListOfLayouts *&prLol, CCopasiDataModel *pDataModel)
CListOfLayouts * pListOfLayouts
void setEnabled(const bool &enabled)
static CFunctionDB * getFunctionList()
CCopasiVectorN< CCopasiTask > * pTaskList
SBMLDocument * pCurrentSBMLDocument
virtual bool add(CCopasiObject *pObject, const bool &adopt=true)
std::map< CCopasiObject *, SBase * > mCopasi2SBMLMap
Definition: CModel.h:50
CDataModelRenameHandler mRenameHandler
bool CCopasiDataModel::isChanged ( ) const

Definition at line 1826 of file CCopasiDataModel.cpp.

References CCopasiDataModel::CData::mChanged, and mData.

bool CCopasiDataModel::loadModel ( std::istream &  in,
const std::string &  pwd,
CProcessReport pProcessReport,
const bool &  deleteOldData = true 
)

Definition at line 158 of file CCopasiDataModel.cpp.

References CCopasiContainer::add(), CCopasiMessage::clearDeque(), commonAfterLoad(), CopasiML, CCopasiMessage::ERROR, CCopasiXML::freeGUI(), CCopasiXML::freeLayoutList(), CCopasiXML::freeModel(), CCopasiXML::freePlotList(), CCopasiXML::freeReportList(), CCopasiXML::freeTaskList(), Gepasi, CCopasiRootContainer::getFunctionList(), CCopasiXML::getLayoutList(), CCopasiXML::getModel(), CCopasiXML::getPlotList(), CCopasiXML::getReportList(), CCopasiXML::getTaskList(), CReadConfig::getVersion(), CCopasiXML::load(), CModel::load(), CTrajectoryTask::load(), CSteadyStateTask::load(), MCXML, mData, CCopasiDataModel::CData::mFileType, mRenameHandler, CCopasiDataModel::CData::mWithGUI, newModel(), CCopasiDataModel::CData::pGUI, CCopasiDataModel::CData::pListOfLayouts, CCopasiDataModel::CData::pModel, popData(), CCopasiDataModel::CData::pPlotDefinitionList, CCopasiDataModel::CData::pReportDefinitionList, CCopasiDataModel::CData::pTaskList, pushData(), CCopasiXML::setDatamodel(), CDataModelRenameHandler::setEnabled(), CCopasiXML::setFunctionList(), and CCopasiXML::setGUI().

Referenced by Arguments::handleCommandLine(), load_cps_model_from_stream(), loadModel(), main(), Arguments::prepareModel(), Copasi2SBMLTranslator::translateFileToSBML(), and Copasi2SBMLTranslator::translateToSBML().

162 {
163  // During load no objects will be renamed;
164  mRenameHandler.setEnabled(false);
165 
167 
168  std::string Line;
169  in >> Line;
170 
171  if (!Line.compare(0, 8, "Version="))
172  {
173  in.seekg(0, std::ios_base::beg);
174 
175  CReadConfig inbuf(in);
176 
177  if (inbuf.getVersion() >= "4")
178  {
180  "Can't handle Gepasi Files with Version>=4.");
181 
183  return false;
184  }
185 
186  newModel(NULL, deleteOldData);
188 
189  if (mData.pModel->load(inbuf))
190  {
191  popData();
193  return false;
194  }
195 
196  static_cast<CTrajectoryTask *>((*mData.pTaskList)["Time-Course"])->load(inbuf);
197 
198  static_cast<CSteadyStateTask *>((*mData.pTaskList)["Steady-State"])->load(inbuf);
199  }
200  else if (!Line.find("<?xml") != std::string::npos)
201  {
202  in.seekg(0, std::ios_base::beg);
203  pushData();
205 
206  CCopasiXML XML;
207  XML.setFunctionList(&CCopasiRootContainer::getFunctionList()->loadedFunctions());
208  XML.setDatamodel(this);
209 
210  SCopasiXMLGUI *pGUI = NULL;
211 
212  if (mData.mWithGUI)
213  {
214  pGUI = new SCopasiXMLGUI("GUI", this);
215  XML.setGUI(pGUI);
216  }
217 
218  try
219  {
220  if (!XML.load(in, pwd))
221  {
222  XML.freeModel();
223  XML.freeTaskList();
224  XML.freeReportList();
225  XML.freePlotList();
226  XML.freeGUI();
227  XML.freeLayoutList();
228 
229  // restore the OldData
230  popData();
231 
233  return false;
234  }
235  }
236  catch (...)
237  {
238  XML.freeModel();
239  XML.freeTaskList();
240  XML.freeReportList();
241  XML.freePlotList();
242  XML.freeGUI();
243  XML.freeLayoutList();
244 
245  // restore the OldData
246  popData();
247 
248  // rethrow the exception so the program flow should still be
249  // the same as before
251  throw;
252  }
253 
254  if (XML.getModel() != NULL)
255  {
256  mData.pModel = XML.getModel();
257  add(mData.pModel, true);
258  }
259 
260  if (XML.getTaskList() != NULL)
261  {
262  mData.pTaskList = XML.getTaskList();
263  add(mData.pTaskList, true);
264  }
265 
266  if (XML.getReportList() != NULL)
267  {
270  }
271 
272  if (XML.getPlotList() != NULL)
273  {
276  }
277 
278  if (XML.getLayoutList() != NULL)
279  {
281  add(mData.pListOfLayouts, true);
282  }
283 
284  if (mData.mWithGUI)
285  {
286  mData.pGUI = pGUI;
287  }
288  }
289  else
290  {
292 
294  return false;
295  }
296 
297  commonAfterLoad(pProcessReport, deleteOldData);
298 
300  return true;
301 }
bool freePlotList()
Definition: CCopasiXML.cpp:331
void commonAfterLoad(CProcessReport *pProcessReport, const bool &deleteOldData)
bool freeModel()
Definition: CCopasiXML.cpp:264
CListOfLayouts * getLayoutList() const
Definition: CCopasiXML.cpp:383
bool newModel(CProcessReport *pProcessReport, const bool &deleteOldData)
CReportDefinitionVector * pReportDefinitionList
bool setFunctionList(CCopasiVectorN< CFunction > *pFunctionList)
Definition: CCopasiXML.cpp:270
#define MCXML
COutputDefinitionVector * getPlotList() const
Definition: CCopasiXML.cpp:325
bool freeGUI()
Definition: CCopasiXML.cpp:369
static void clearDeque()
COutputDefinitionVector * pPlotDefinitionList
bool freeTaskList()
Definition: CCopasiXML.cpp:311
bool setDatamodel(CCopasiDataModel *pDataModel)
Definition: CCopasiXML.cpp:299
CListOfLayouts * pListOfLayouts
bool freeLayoutList()
Definition: CCopasiXML.cpp:389
void setEnabled(const bool &enabled)
static CFunctionDB * getFunctionList()
CCopasiVectorN< CCopasiTask > * pTaskList
CReportDefinitionVector * getReportList() const
Definition: CCopasiXML.cpp:345
void load(CReadConfig &configBuffer)
CModel * getModel() const
Definition: CCopasiXML.cpp:260
bool setGUI(SCopasiXMLGUI *pGUI)
Definition: CCopasiXML.cpp:359
bool freeReportList()
Definition: CCopasiXML.cpp:351
virtual bool add(CCopasiObject *pObject, const bool &adopt=true)
virtual bool load(std::istream &is, const std::string &pwd)
Definition: CCopasiXML.cpp:169
CDataModelRenameHandler mRenameHandler
void load(CReadConfig &configBuffer)
CCopasiVectorN< CCopasiTask > * getTaskList() const
Definition: CCopasiXML.cpp:305
C_INT32 load(CReadConfig &configBuffer)
Definition: CModel.cpp:255
bool CCopasiDataModel::loadModel ( const std::string &  fileName,
CProcessReport pProcessReport,
const bool &  deleteOldData = true 
)

Definition at line 303 of file CCopasiDataModel.cpp.

References CDirEntry::baseName(), CopasiML, CDirEntry::dirName(), fatalError, CDirEntry::fileName(), CLocaleString::fromUtf8(), Gepasi, COptions::getValue(), CDirEntry::isRelativePath(), loadModel(), CDirEntry::makePathAbsolute(), mData, CCopasiDataModel::CData::mFileType, CCopasiDataModel::CData::mReferenceDir, CCopasiDataModel::CData::mSaveFileName, CDirEntry::normalize(), CCopasiMessage::RAW, CDirEntry::Separator, and CDirEntry::suffix().

306 {
307  std::string PWD;
308  COptions::getValue("PWD", PWD);
309 
310  std::string FileName = fileName;
311 
312  if (CDirEntry::isRelativePath(FileName) &&
313  !CDirEntry::makePathAbsolute(FileName, PWD))
314  FileName = CDirEntry::fileName(FileName);
315 
316  PWD = CDirEntry::dirName(FileName);
317 
318 #ifdef WIN32
319  std::ifstream File(CLocaleString::fromUtf8(FileName).c_str(), std::ios_base::binary);
320 #else
321  std::ifstream File(CLocaleString::fromUtf8(FileName).c_str());
322 #endif
323 
324  if (File.fail())
325  {
327  "File error when opening '%s'.",
328  FileName.c_str());
329  return false;
330  }
331 
332  if (!loadModel(File, PWD, pProcessReport, deleteOldData))
333  {
334  return false;
335  }
336 
337  switch (mData.mFileType)
338  {
339  case CopasiML:
341  // we have to store the reference directory
343  break;
344 
345  case Gepasi:
348  + CDirEntry::baseName(FileName);
349 
350  {
351  std::string Suffix = CDirEntry::suffix(FileName);
352 
353  if (strcasecmp(Suffix.c_str(), ".gps") != 0)
354  mData.mSaveFileName += Suffix;
355  }
356 
357  mData.mSaveFileName += ".cps";
358 
360  // we have to store the reference directory
362  break;
363 
364  default:
365  fatalError();
366  break;
367  }
368 
369  return true;
370 }
static bool isRelativePath(const std::string &path)
Definition: CDirEntry.cpp:414
#define fatalError()
static std::string fileName(const std::string &path)
Definition: CDirEntry.cpp:119
static std::string baseName(const std::string &path)
Definition: CDirEntry.cpp:98
static std::string dirName(const std::string &path)
Definition: CDirEntry.cpp:135
static const std::string Separator
Definition: CDirEntry.h:34
struct MESSAGES Message
bool loadModel(std::istream &in, const std::string &pwd, CProcessReport *pProcessReport, const bool &deleteOldData=true)
static void getValue(const std::string &name, CType &value)
Definition: COptions.h:124
static std::string normalize(const std::string &path)
Definition: CDirEntry.cpp:560
static CLocaleString fromUtf8(const std::string &utf8)
static bool makePathAbsolute(std::string &relativePath, const std::string &absoluteTo)
Definition: CDirEntry.cpp:481
static std::string suffix(const std::string &path)
Definition: CDirEntry.cpp:159
bool CCopasiDataModel::newModel ( CProcessReport pProcessReport,
const bool &  deleteOldData 
)

Definition at line 515 of file CCopasiDataModel.cpp.

References commonAfterLoad(), and pushData().

Referenced by CCopasiDataModel(), loadModel(), test000068::test_bug1068(), test000093::test_bug1503_1(), test000093::test_bug1503_2(), test000103::test_bug1743_l2(), and test000103::test_bug1743_l3().

517 {
518  //deal with the CModel
519  pushData();
520 
521  commonAfterLoad(pProcessReport, deleteOldData);
522 
523  return true;
524 }
void commonAfterLoad(CProcessReport *pProcessReport, const bool &deleteOldData)
CObjectInterface * CCopasiDataModel::ObjectFromCN ( const std::vector< CCopasiContainer * > &  listOfContainer,
const CCopasiObjectName objName 
) const

Retrieve the object with the given CN

Parameters
conststd::vector< CCopasiContainer * > &listOfContainer
constCCopasiObjectName& objName
Returns
CObjectInterface * pObject

Definition at line 1890 of file CCopasiDataModel.cpp.

References CCopasiObject::getCN(), CCopasiRootContainer::getFunctionList(), CCopasiContainer::getObject(), and CCopasiObjectName::getRemainder().

Referenced by CExpression::getNodeObject(), CMathContainer::getObject(), and ObjectFromName().

1892 {
1893  const CObjectInterface * pObject = NULL;
1894  const CCopasiContainer* pContainer;
1895  CCopasiObjectName ContainerName;
1896  size_t containerIndex;
1897  std::string::size_type pos;
1898 
1899  //favor to search the list of container first
1900  for (containerIndex = 0;
1901  containerIndex < listOfContainer.size() && !pObject;
1902  containerIndex++)
1903  {
1904  pContainer = listOfContainer[containerIndex];
1905 
1906  if (pContainer == NULL)
1907  {
1908  continue;
1909  }
1910 
1911  ContainerName = pContainer->getCN();
1912 
1913  while (ContainerName.getRemainder() != "")
1914  {
1915  ContainerName = ContainerName.getRemainder();
1916  }
1917 
1918  if ((pos = objName.find(ContainerName)) == std::string::npos)
1919  continue;
1920 
1921  if (pos + ContainerName.length() == objName.length())
1922  pObject = pContainer;
1923  else
1924  pObject = pContainer->getObject(objName.substr(pos + ContainerName.length() + 1));
1925  }
1926 
1927  // If we have not found the object in the context we search the whole data model.
1928  if (pObject == NULL)
1929  {
1930  pObject = getObject(objName);
1931  }
1932 
1933  // if still not found search the function database in the root container
1934  if (!pObject)
1935  pObject = CCopasiRootContainer::getFunctionList()->getObject(objName);
1936 
1937  return const_cast< CObjectInterface * >(pObject);
1938 }
virtual CCopasiObjectName getCN() const
CCopasiObjectName getRemainder() const
static CFunctionDB * getFunctionList()
virtual const CObjectInterface * getObject(const CCopasiObjectName &cn) const
CCopasiObject * CCopasiDataModel::ObjectFromName ( const std::vector< CCopasiContainer * > &  listOfContainer,
const CCopasiObjectName CN 
) const

Retrieve the data object with the given CN

Parameters
conststd::vector< CCopasiContainer * > &listOfContainer
constCCopasiObjectName& CN
Returns
CCopasiObject * pObject

Definition at line 1940 of file CCopasiDataModel.cpp.

References ObjectFromCN().

Referenced by CSBMLExporter::checkForUnsupportedObjectReferences(), CTimeSeries::compile(), CExperiment::compile(), CModelParameter::compile(), CopasiPlot::compile(), CModelParameterReactionParameter::compile(), COutputHandler::compileRefresh(), contains_necessary_mass_action_elements(), SBMLImporter::doMapping(), CReport::generateObjectsFromName(), COptProblem::getSubtaskType(), CFitProblem::initialize(), COptProblem::initializeSubtaskBeforeOutput(), SBMLImporter::isConstantFlux(), SBMLImporter::isMassActionExpression(), CODEExporter::isModelEntityExpressionODEExporterCompatible(), CSlider::isValid(), CReaction::object2variable(), CReportDefinition::preCompileTable(), SBMLImporter::renameMassActionParameters(), CSBMLExporter::replace_local_parameters(), CSBMLExporter::replaceSpeciesReferences(), CSBMLExporter::restore_local_parameters(), SBMLImporter::setCorrectUsage(), CQExpressionWidget::setExpression(), test000093::test_bug1503_1(), test000093::test_bug1503_2(), test000099::test_bug1675(), test000052::test_bug988(), test000047::test_delay(), test000091::test_delay_in_kinetic_law(), test000091::test_delay_in_kinetic_law_local_parameter(), test000026::test_hasOnlySubstanceUnits(), test000027::test_hasOnlySubstanceUnits(), test000028::test_hasOnlySubstanceUnits(), test000029::test_hasOnlySubstanceUnits(), test000030::test_hasOnlySubstanceUnits(), test000031::test_hasOnlySubstanceUnits(), test000032::test_hasOnlySubstanceUnits(), test000038::test_hasOnlySubstanceUnits(), test000036::test_hasOnlySubstanceUnits(), test000037::test_hasOnlySubstanceUnits(), test000039::test_hasOnlySubstanceUnits(), test000033::test_hasOnlySubstanceUnits(), test000040::test_hasOnlySubstanceUnits(), test000041::test_hasOnlySubstanceUnits(), test000042::test_hasOnlySubstanceUnits(), test000043::test_hasOnlySubstanceUnits(), test000034::test_hasOnlySubstanceUnits(), test000035::test_hasOnlySubstanceUnits(), test000021::test_hasOnlySubstanceUnits(), test000022::test_hasOnlySubstanceUnits(), test000023::test_hasOnlySubstanceUnits(), test000024::test_hasOnlySubstanceUnits(), test000025::test_hasOnlySubstanceUnits(), test000082::test_import_delayAssignment_1(), test000082::test_import_delayAssignment_2(), test000082::test_import_delayAssignment_3(), test000082::test_import_delayAssignment_4(), test000082::test_import_delayAssignment_5(), test000082::test_import_delayAssignment_6(), test000082::test_import_delayAssignment_7(), test000082::test_import_delayAssignment_8(), test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_1(), test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_2(), test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_3(), test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_4(), test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_5(), test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_6(), test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_7(), test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_8(), test000095::test_import_l3_event_1(), test000095::test_import_l3_event_2(), test000095::test_import_l3_event_3(), test000095::test_import_l3_event_4(), test000095::test_import_l3_event_5(), test000087::test_import_reaction_flux_reference_2(), test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_1(), test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_2(), test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_3(), test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_4(), test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_5(), test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_6(), test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_7(), test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_8(), test000075::test_import_time_dependent_function_definition(), test000087::test_simulate_reaction_flux_reference_1(), and CModelParameter::updateModel().

1942 {
1943  // TODO CRITICAL This does not work for math as object ObjectFromCN only returns a CObjectInterface.
1944  return static_cast< CCopasiObject * >(ObjectFromCN(listOfContainer, objName));
1945 }
CObjectInterface * ObjectFromCN(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &objName) const
void CCopasiDataModel::popData ( )
protected

Definition at line 2053 of file CCopasiDataModel.cpp.

References mData, mOldData, CCopasiDataModel::CData::mWithGUI, CCopasiDataModel::CData::pGUI, CCopasiDataModel::CData::pListOfLayouts, CCopasiDataModel::CData::pModel, CCopasiDataModel::CData::pPlotDefinitionList, CCopasiDataModel::CData::pReportDefinitionList, and CCopasiDataModel::CData::pTaskList.

Referenced by importSBML(), importSBMLFromString(), and loadModel().

2054 {
2055  // Make sure the old data is valid
2056  assert(mOldData.pModel != NULL &&
2057  mOldData.pTaskList != NULL &&
2058  mOldData.pReportDefinitionList != NULL &&
2059  mOldData.pPlotDefinitionList != NULL &&
2060  mOldData.pListOfLayouts != NULL &&
2061  (mOldData.pGUI != NULL || mOldData.mWithGUI == false));
2062 
2063  // TODO CRITICAL We need to clean up mData to avoid memory leaks.
2064 
2065  mData = mOldData;
2066  mOldData = CData(mOldData.mWithGUI);
2067 }
CReportDefinitionVector * pReportDefinitionList
COutputDefinitionVector * pPlotDefinitionList
CListOfLayouts * pListOfLayouts
CCopasiVectorN< CCopasiTask > * pTaskList
void CCopasiDataModel::pushData ( )
protected

Definition at line 2033 of file CCopasiDataModel.cpp.

References mData, mOldData, CCopasiDataModel::CData::mWithGUI, CCopasiDataModel::CData::pGUI, CCopasiDataModel::CData::pListOfLayouts, CCopasiDataModel::CData::pModel, CCopasiDataModel::CData::pPlotDefinitionList, CCopasiDataModel::CData::pReportDefinitionList, and CCopasiDataModel::CData::pTaskList.

Referenced by importSBML(), importSBMLFromString(), loadModel(), and newModel().

2034 {
2035  bool condition = true;
2036 #ifdef COPASI_SEDML
2037  condition = mOldData.pCurrentSEDMLDocument == NULL;
2038 #endif
2039  // make sure the old data has been deleted.
2040  assert(mOldData.pModel == NULL &&
2041  mOldData.pTaskList == NULL &&
2042  mOldData.pReportDefinitionList == NULL &&
2043  mOldData.pPlotDefinitionList == NULL &&
2044  mOldData.pListOfLayouts == NULL &&
2045  mOldData.pGUI == NULL &&
2046  condition
2047  );
2048 
2049  mOldData = mData;
2050  mData = CData(mData.mWithGUI);
2051 }
CReportDefinitionVector * pReportDefinitionList
COutputDefinitionVector * pPlotDefinitionList
CListOfLayouts * pListOfLayouts
CCopasiVectorN< CCopasiTask > * pTaskList
bool CCopasiDataModel::removeLayout ( const std::string &  key)

Definition at line 1870 of file CCopasiDataModel.cpp.

References C_INVALID_INDEX, CKeyFactory::get(), CCopasiRootContainer::getKeyFactory(), mData, and CCopasiDataModel::CData::pListOfLayouts.

1871 {
1872  CLayout *pLayout =
1873  dynamic_cast< CLayout * >(CCopasiRootContainer::getKeyFactory()->get(key));
1874 
1875  if (!pLayout)
1876  return false;
1877 
1878  //Check if Layout with that name exists
1879  size_t index =
1880  mData.pListOfLayouts->CCopasiVector< CLayout >::getIndex(pLayout);
1881 
1882  if (index == C_INVALID_INDEX)
1883  return false;
1884 
1885  mData.pListOfLayouts->CCopasiVector< CLayout >::remove(index);
1886 
1887  return true;
1888 }
CCopasiObject * get(const std::string &key)
#define C_INVALID_INDEX
Definition: copasi.h:222
CListOfLayouts * pListOfLayouts
static CKeyFactory * getKeyFactory()
void CCopasiDataModel::removeSBMLIdFromFunctions ( )
protected

Definition at line 1859 of file CCopasiDataModel.cpp.

References CCopasiRootContainer::getFunctionList(), CFunctionDB::loadedFunctions(), and CCopasiVector< T >::size().

1860 {
1862  size_t i, iMax = pFunDB->loadedFunctions().size();
1863 
1864  for (i = 0; i < iMax; ++i)
1865  {
1866  pFunDB->loadedFunctions()[i]->setSBMLId("");
1867  }
1868 }
CCopasiVectorN< CFunction > & loadedFunctions()
virtual size_t size() const
static CFunctionDB * getFunctionList()
bool CCopasiDataModel::saveModel ( const std::string &  fileName,
CProcessReport pProcessReport,
bool  overwriteFile = false,
const bool &  autoSave = false 
)

Definition at line 372 of file CCopasiDataModel.cpp.

References changed(), CCopasiMessage::clearDeque(), CModel::compileIfNecessary(), CDirEntry::createTmpName(), CCopasiMessage::ERROR, CDirEntry::exist(), CDirEntry::fileName(), CModel::getModelParameterSet(), COptions::getValue(), CDirEntry::isRelativePath(), CDirEntry::isWritable(), CDirEntry::makePathAbsolute(), MCDirEntry, mData, CDirEntry::move(), CCopasiDataModel::CData::mSaveFileName, CDirEntry::normalize(), CCopasiDataModel::CData::pGUI, CCopasiDataModel::CData::pListOfLayouts, CCopasiDataModel::CData::pModel, CCopasiDataModel::CData::pPlotDefinitionList, CCopasiDataModel::CData::pReportDefinitionList, CCopasiDataModel::CData::pTaskList, CModelParameterGroup::refreshFromModel(), CDirEntry::remove(), CCopasiXML::setDatamodel(), CCopasiXML::setGUI(), CCopasiXML::setLayoutList(), CCopasiXML::setModel(), CCopasiXML::setPlotList(), CCopasiXML::setReportList(), and CCopasiXML::setTaskList().

Referenced by autoSave(), main(), Arguments::prepareModel(), and Copasi2SBMLTranslator::translate().

375 {
377 
378  std::string FileName = (fileName != "") ? fileName : mData.mSaveFileName;
379 
380  std::string PWD;
381  COptions::getValue("PWD", PWD);
382 
383  if (CDirEntry::isRelativePath(FileName) &&
384  !CDirEntry::makePathAbsolute(FileName, PWD))
385  FileName = CDirEntry::fileName(FileName);
386 
387  if (CDirEntry::exist(FileName))
388  {
389  if (!overwriteFile)
390  {
392  MCDirEntry + 1,
393  FileName.c_str());
394  return false;
395  }
396 
397  if (!CDirEntry::isWritable(FileName))
398  {
400  MCDirEntry + 2,
401  FileName.c_str());
402  return false;
403  }
404  }
405 
406  try
407  {
408  // We do not care whether the model compiles or not
409  // We just save as much as we can
410  mData.pModel->compileIfNecessary(pProcessReport);
411 
412  // Assure that the parameter set reflects all changes made to the model.
414  }
415 
416  catch (...)
417  {
418  return false;
419  }
420 
421  CCopasiXML XML;
422 
423  XML.setModel(mData.pModel);
427  XML.setGUI(mData.pGUI);
429  XML.setDatamodel(this);
430  bool success = true;
431 
432  if (!autoSave)
433  {
434  // We are first writing to a temporary file to prevent accidental
435  // destruction of an existing file in case the save command fails.
436  std::string TmpFileName;
437  COptions::getValue("Tmp", TmpFileName);
438  TmpFileName = CDirEntry::createTmpName(TmpFileName, ".cps");
439 
440  try
441  {
442  if (!XML.CCopasiXMLInterface::save(TmpFileName, FileName))
443  {
444  CDirEntry::remove(TmpFileName);
445  success = false;
446  }
447  }
448 
449  catch (...)
450  {
451  CDirEntry::remove(TmpFileName);
452  return false;
453  }
454 
455  if (success && !CDirEntry::move(TmpFileName, FileName))
456  success = false;
457  }
458 
459  if (autoSave || !success)
460  {
461  try
462  {
463  if (!XML.CCopasiXMLInterface::save(FileName, FileName))
464  return false;
465  }
466 
467  catch (...)
468  {
469  return false;
470  }
471  }
472 
473  if (!autoSave)
474  {
475  changed(false);
477  }
478 
479  return true;
480 }
static bool remove(const std::string &path)
Definition: CDirEntry.cpp:275
const CModelParameterSet & getModelParameterSet() const
Definition: CModel.cpp:1072
static bool move(const std::string &from, const std::string &to)
Definition: CDirEntry.cpp:233
static bool isRelativePath(const std::string &path)
Definition: CDirEntry.cpp:414
bool setModel(CModel *pModel)
Definition: CCopasiXML.cpp:254
CReportDefinitionVector * pReportDefinitionList
static std::string fileName(const std::string &path)
Definition: CDirEntry.cpp:119
void changed(const bool &changed=true)
static void clearDeque()
COutputDefinitionVector * pPlotDefinitionList
bool setDatamodel(CCopasiDataModel *pDataModel)
Definition: CCopasiXML.cpp:299
static bool exist(const std::string &path)
Definition: CDirEntry.cpp:78
bool setTaskList(CCopasiVectorN< CCopasiTask > *pTaskList)
Definition: CCopasiXML.cpp:288
CListOfLayouts * pListOfLayouts
static bool isWritable(const std::string &path)
Definition: CDirEntry.cpp:95
bool setPlotList(COutputDefinitionVector *pPlotList)
Definition: CCopasiXML.cpp:319
static std::string createTmpName(const std::string &dir, const std::string &suffix)
Definition: CDirEntry.cpp:202
bool setLayoutList(const CListOfLayouts &reportList)
Definition: CCopasiXML.cpp:377
#define MCDirEntry
static void getValue(const std::string &name, CType &value)
Definition: COptions.h:124
CCopasiVectorN< CCopasiTask > * pTaskList
bool setGUI(SCopasiXMLGUI *pGUI)
Definition: CCopasiXML.cpp:359
bool setReportList(CReportDefinitionVector *pReportList)
Definition: CCopasiXML.cpp:339
bool compileIfNecessary(CProcessReport *pProcessReport)
Definition: CModel.cpp:612
static std::string normalize(const std::string &path)
Definition: CDirEntry.cpp:560
virtual bool refreshFromModel(const bool &modifyExistence)
static bool makePathAbsolute(std::string &relativePath, const std::string &absoluteTo)
Definition: CDirEntry.cpp:481
bool CCopasiDataModel::setSBMLFileName ( const std::string &  fileName)

Definition at line 1840 of file CCopasiDataModel.cpp.

References CDirEntry::fileName(), CDirEntry::isRelativePath(), CDirEntry::makePathAbsolute(), mData, CCopasiDataModel::CData::mSaveFileName, CCopasiDataModel::CData::mSBMLFileName, and CDirEntry::normalize().

Referenced by SEDMLImporter::importFirstSBMLModel(), and CCopasiXMLParser::SBMLReferenceElement::start().

1841 {
1843 
1847 
1848  return true;
1849 }
static bool isRelativePath(const std::string &path)
Definition: CDirEntry.cpp:414
static std::string fileName(const std::string &path)
Definition: CDirEntry.cpp:119
static std::string normalize(const std::string &path)
Definition: CDirEntry.cpp:560
static bool makePathAbsolute(std::string &relativePath, const std::string &absoluteTo)
Definition: CDirEntry.cpp:481

Member Data Documentation

CData CCopasiDataModel::mData
protected
std::set<CCopasiObject*> CCopasiDataModel::mLastAddedObjects

Definition at line 312 of file CCopasiDataModel.h.

CData CCopasiDataModel::mOldData
protected
CDataModelRenameHandler CCopasiDataModel::mRenameHandler
protected

Definition at line 303 of file CCopasiDataModel.h.

Referenced by CCopasiDataModel(), importSBML(), importSBMLFromString(), and loadModel().

CCopasiVectorS< CMetabOld >* CCopasiDataModel::pOldMetabolites

This is a hack at the moment to be able to read Gepasi model files

Definition at line 309 of file CCopasiDataModel.h.

Referenced by CModel::load(), CReaction::loadOneRole(), and ~CCopasiDataModel().


The documentation for this class was generated from the following files: