COPASI API  4.16.103
CCopasiRootContainer.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2015 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 // Copyright (C) 2009 by Pedro Mendes, Virginia Tech Intellectual
7 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
8 // and The University of Manchester.
9 // All rights reserved.
10 
11 #include "copasi.h"
12 
13 #include "CCopasiRootContainer.h"
14 #include "ArtisticLicense.h"
22 
24 
26 
28 
29 /**
30  * The default constructor should be private so that nobody can create
31  * new instances of the root container.
32  * The only way to create a root container is through the static init
33  * method.
34  */
36  CCopasiContainer("Root", NULL, "CN", CCopasiObject::Root),
37  mKeyFactory(),
38  mpUnknownResource(NULL),
39  mpFunctionList(NULL),
40  mpConfiguration(NULL),
41  mpDataModelList(NULL),
42  mWithGUI(withGUI),
43  mpUndefined(NULL)
44 {}
45 
46 // Destructor
48 {
49  // save and delete the configuration
50  if (mpConfiguration != NULL &&
51  mWithGUI)
52  {
54  }
55 
56  // delete the configuration
58 
59  // delete the unkown resource
61 
62  // delete the model list
64 
65  // delete the function list
67 
68  // delete the undefined and the unsupported delay function
70 
71  // delete other static variables
72  pdelete(DEFAULT_STYLES);
73 }
74 
75 /**
76  * This method creates the only root container.
77  */
78 void CCopasiRootContainer::init(int argc, char *argv[], const bool & withGUI)
79 {
80  COptions::init(argc, argv);
81 
82  CCopasiMessage::setIsGUI(withGUI);
83 
84  if (pRootContainer == NULL)
85  pRootContainer = new CCopasiRootContainer(withGUI);
86 
87  if (pRootContainer != NULL)
88  pRootContainer->initializeChildren();
89 }
90 
91 // static
93 {
94  if (pRootContainer != NULL)
95  {
96  delete pRootContainer;
97  pRootContainer = NULL;
98  }
99 
101 
103 }
104 
106 {
107  mpUnknownResource = new CMIRIAMResource("Unknown Resource");
108  mpUnknownResource->setMIRIAMDisplayName("-- select --");
109  mpUnknownResource->setMIRIAMURI("urn:miriam:unknown");
110 
111  mpFunctionList = new CFunctionDB("FunctionDB", this);
112  mpFunctionList->load();
113 
114  mpDataModelList = new CCopasiVector<CCopasiDataModel>("ModelList", this);
115 
117  mpConfiguration->load();
118 
119  mpUndefined = new CFunction("undefined", this);
120  mpUndefined->setInfix("nan");
121  mpUndefined->compile();
122 }
123 
124 // static
126 {
127  return pRootContainer;
128 }
129 
130 // static
132 {
133  return pRootContainer->mpConfiguration;
134 }
135 
136 // static
138 {
139  return pRootContainer->mpFunctionList;
140 }
141 
142 // static
144 {
145  return pRootContainer->mpDataModelList;
146 }
147 
148 // static
150 {
151  CCopasiDataModel* pDataModel = new CCopasiDataModel(pRootContainer->mWithGUI);
152  pRootContainer->mpDataModelList->add(pDataModel, true);
153  return pDataModel;
154 }
155 
156 // static
158 {
159  return pRootContainer->mpUndefined;
160 }
161 
162 //static
164 {
165  return &pRootContainer->mKeyFactory;
166 }
167 
168 // static
170 {
171  return *pRootContainer->mpUnknownResource;
172 }
173 
174 // static
176 {
177  if (!pDatamodel)
178  {
179  return false;
180  }
181 
182  pRootContainer->mpDataModelList->remove((CCopasiDataModel *)pDatamodel);
183  pdelete(pDatamodel);
184 
185  return true;
186 }
187 
188 // static
190 {
191  const CCopasiDataModel* pDatamodel = (*CCopasiRootContainer::getDatamodelList())[index];
192  return CCopasiRootContainer::removeDatamodel(pDatamodel);
193 }
194 
195 // static
197 {
198  return CopasiLicenseTxt;
199 }
200 
201 // static
203 {
204  return CopasiLicenseHtml;
205 }
static const char * getLicenseHTML()
#define pdelete(p)
Definition: copasi.h:215
CCopasiRootContainer(const bool &withGUI=false)
static CFunction * getUndefinedFunction()
CMIRIAMResource * mpUnknownResource
static bool removeDatamodel(const CCopasiDataModel *pDatamodel)
void setMIRIAMURI(const std::string &URI)
CCopasiVector< CCopasiDataModel > * mpDataModelList
static void setIsGUI(const bool &isGUI)
#define C_INT32
Definition: copasi.h:90
virtual bool setInfix(const std::string &infix)
Definition: CFunction.cpp:73
CCopasiVector< CLGlobalRenderInformation > * DEFAULT_STYLES
const char * CopasiLicenseTxt
static void cleanup()
Definition: COptions.cpp:243
CConfigurationFile * mpConfiguration
static CConfigurationFile * getConfiguration()
static const char * getLicenseTxt()
virtual bool add(const CType &src)
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
static CFunctionDB * getFunctionList()
virtual void remove(const size_t &index)
static CCopasiDataModel * addDatamodel()
static const CMIRIAMResource & getUnknownMiriamResource()
static CKeyFactory * getKeyFactory()
void setMIRIAMDisplayName(const std::string &displayName)
CCopasiRootContainer * pRootContainer
virtual bool compile()
The class for handling a chemical kinetic function.
Definition: CFunction.h:29
static CCopasiObject * pUnmappedObject
static void init(int argc, char *argv[], const bool &withGui=false)
static const CCopasiContainer * getRoot()
const char * CopasiLicenseHtml
static void init(C_INT argc=0, char *argv[]=NULL)
Definition: COptions.cpp:56