1 /**
2 * @file SedAnalysis.cpp
3 * @brief Implementation of the SedAnalysis class.
4 * @author DEVISER
5 *
6 * <!--------------------------------------------------------------------------
7 * This file is part of libSEDML. Please visit http://sed-ml.org for more
8 * information about SED-ML. The latest version of libSEDML can be found on
9 * github: https://github.com/fbergmann/libSEDML/
10 *
11
12 * Copyright (c) 2013-2019, Frank T. Bergmann
13 * All rights reserved.
14 *
15
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions are met:
18 *
19
20 * 1. Redistributions of source code must retain the above copyright notice,
21 * this
22 * list of conditions and the following disclaimer.
23 * 2. Redistributions in binary form must reproduce the above copyright notice,
24 * this list of conditions and the following disclaimer in the documentation
25 * and/or other materials provided with the distribution.
26 *
27 * This library is free software; you can redistribute it and/or modify it
28 * under the terms of the GNU Lesser General Public License as published by the
29 * Free Software Foundation. A copy of the license agreement is provided in the
30 * file named "LICENSE.txt" included with this software distribution and also
31 * available online as http://sbml.org/software/libsbml/license.html
32 * ------------------------------------------------------------------------ -->
33 */
34 #include <sedml/SedAnalysis.h>
35 #include <sbml/xml/XMLInputStream.h>
36
37
38 using namespace std;
39
40
41
42 LIBSEDML_CPP_NAMESPACE_BEGIN
43
44
45
46
47 #ifdef __cplusplus
48
49
50 /*
51 * Creates a new SedAnalysis using the given SED-ML Level and @ p version
52 * values.
53 */
SedAnalysis(unsigned int level,unsigned int version)54 SedAnalysis::SedAnalysis(unsigned int level, unsigned int version)
55 : SedSimulation(level, version)
56 {
57 setSedNamespacesAndOwn(new SedNamespaces(level, version));
58 }
59
60
61 /*
62 * Creates a new SedAnalysis using the given SedNamespaces object @p
63 * sedmlns.
64 */
SedAnalysis(SedNamespaces * sedmlns)65 SedAnalysis::SedAnalysis(SedNamespaces *sedmlns)
66 : SedSimulation(sedmlns)
67 {
68 setElementNamespace(sedmlns->getURI());
69 }
70
71
72 /*
73 * Copy constructor for SedAnalysis.
74 */
SedAnalysis(const SedAnalysis & orig)75 SedAnalysis::SedAnalysis(const SedAnalysis& orig)
76 : SedSimulation( orig )
77 {
78 }
79
80
81 /*
82 * Assignment operator for SedAnalysis.
83 */
84 SedAnalysis&
operator =(const SedAnalysis & rhs)85 SedAnalysis::operator=(const SedAnalysis& rhs)
86 {
87 if (&rhs != this)
88 {
89 SedSimulation::operator=(rhs);
90 }
91
92 return *this;
93 }
94
95
96 /*
97 * Creates and returns a deep copy of this SedAnalysis object.
98 */
99 SedAnalysis*
clone() const100 SedAnalysis::clone() const
101 {
102 return new SedAnalysis(*this);
103 }
104
105
106 /*
107 * Destructor for SedAnalysis.
108 */
~SedAnalysis()109 SedAnalysis::~SedAnalysis()
110 {
111 }
112
113
114 /*
115 * Returns the XML element name of this SedAnalysis object.
116 */
117 const std::string&
getElementName() const118 SedAnalysis::getElementName() const
119 {
120 static const string name = "analysis";
121 return name;
122 }
123
124
125 /*
126 * Returns the libSEDML type code for this SedAnalysis object.
127 */
128 int
getTypeCode() const129 SedAnalysis::getTypeCode() const
130 {
131 return SEDML_SIMULATION_ANALYSIS;
132 }
133
134
135 /*
136 * Predicate returning @c true if all the required attributes for this
137 * SedAnalysis object have been set.
138 */
139 bool
hasRequiredAttributes() const140 SedAnalysis::hasRequiredAttributes() const
141 {
142 bool allPresent = SedSimulation::hasRequiredAttributes();
143
144 return allPresent;
145 }
146
147
148
149 /** @cond doxygenLibSEDMLInternal */
150
151 /*
152 * Write any contained elements
153 */
154 void
writeElements(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream & stream) const155 SedAnalysis::writeElements(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream&
156 stream) const
157 {
158 SedSimulation::writeElements(stream);
159 }
160
161 /** @endcond */
162
163
164
165 /** @cond doxygenLibSEDMLInternal */
166
167 /*
168 * Accepts the given SedVisitor
169 */
170 bool
accept(SedVisitor & v) const171 SedAnalysis::accept(SedVisitor& v) const
172 {
173 return false;
174 }
175
176 /** @endcond */
177
178
179
180 /** @cond doxygenLibSEDMLInternal */
181
182 /*
183 * Sets the parent SedDocument
184 */
185 void
setSedDocument(SedDocument * d)186 SedAnalysis::setSedDocument(SedDocument* d)
187 {
188 SedSimulation::setSedDocument(d);
189 }
190
191 /** @endcond */
192
193
194
195 /** @cond doxygenLibSEDMLInternal */
196
197 /*
198 * Gets the value of the "attributeName" attribute of this SedAnalysis.
199 */
200 int
getAttribute(const std::string & attributeName,bool & value) const201 SedAnalysis::getAttribute(const std::string& attributeName,
202 bool& value) const
203 {
204 int return_value = SedSimulation::getAttribute(attributeName, value);
205
206 return return_value;
207 }
208
209 /** @endcond */
210
211
212
213 /** @cond doxygenLibSEDMLInternal */
214
215 /*
216 * Gets the value of the "attributeName" attribute of this SedAnalysis.
217 */
218 int
getAttribute(const std::string & attributeName,int & value) const219 SedAnalysis::getAttribute(const std::string& attributeName,
220 int& value) const
221 {
222 int return_value = SedSimulation::getAttribute(attributeName, value);
223
224 return return_value;
225 }
226
227 /** @endcond */
228
229
230
231 /** @cond doxygenLibSEDMLInternal */
232
233 /*
234 * Gets the value of the "attributeName" attribute of this SedAnalysis.
235 */
236 int
getAttribute(const std::string & attributeName,double & value) const237 SedAnalysis::getAttribute(const std::string& attributeName,
238 double& value) const
239 {
240 int return_value = SedSimulation::getAttribute(attributeName, value);
241
242 return return_value;
243 }
244
245 /** @endcond */
246
247
248
249 /** @cond doxygenLibSEDMLInternal */
250
251 /*
252 * Gets the value of the "attributeName" attribute of this SedAnalysis.
253 */
254 int
getAttribute(const std::string & attributeName,unsigned int & value) const255 SedAnalysis::getAttribute(const std::string& attributeName,
256 unsigned int& value) const
257 {
258 int return_value = SedSimulation::getAttribute(attributeName, value);
259
260 return return_value;
261 }
262
263 /** @endcond */
264
265
266
267 /** @cond doxygenLibSEDMLInternal */
268
269 /*
270 * Gets the value of the "attributeName" attribute of this SedAnalysis.
271 */
272 int
getAttribute(const std::string & attributeName,std::string & value) const273 SedAnalysis::getAttribute(const std::string& attributeName,
274 std::string& value) const
275 {
276 int return_value = SedSimulation::getAttribute(attributeName, value);
277
278 return return_value;
279 }
280
281 /** @endcond */
282
283
284
285 /** @cond doxygenLibSEDMLInternal */
286
287 /*
288 * Predicate returning @c true if this SedAnalysis's attribute
289 * "attributeName" is set.
290 */
291 bool
isSetAttribute(const std::string & attributeName) const292 SedAnalysis::isSetAttribute(const std::string& attributeName) const
293 {
294 bool value = SedSimulation::isSetAttribute(attributeName);
295
296 return value;
297 }
298
299 /** @endcond */
300
301
302
303 /** @cond doxygenLibSEDMLInternal */
304
305 /*
306 * Sets the value of the "attributeName" attribute of this SedAnalysis.
307 */
308 int
setAttribute(const std::string & attributeName,bool value)309 SedAnalysis::setAttribute(const std::string& attributeName, bool value)
310 {
311 int return_value = SedSimulation::setAttribute(attributeName, value);
312
313 return return_value;
314 }
315
316 /** @endcond */
317
318
319
320 /** @cond doxygenLibSEDMLInternal */
321
322 /*
323 * Sets the value of the "attributeName" attribute of this SedAnalysis.
324 */
325 int
setAttribute(const std::string & attributeName,int value)326 SedAnalysis::setAttribute(const std::string& attributeName, int value)
327 {
328 int return_value = SedSimulation::setAttribute(attributeName, value);
329
330 return return_value;
331 }
332
333 /** @endcond */
334
335
336
337 /** @cond doxygenLibSEDMLInternal */
338
339 /*
340 * Sets the value of the "attributeName" attribute of this SedAnalysis.
341 */
342 int
setAttribute(const std::string & attributeName,double value)343 SedAnalysis::setAttribute(const std::string& attributeName, double value)
344 {
345 int return_value = SedSimulation::setAttribute(attributeName, value);
346
347 return return_value;
348 }
349
350 /** @endcond */
351
352
353
354 /** @cond doxygenLibSEDMLInternal */
355
356 /*
357 * Sets the value of the "attributeName" attribute of this SedAnalysis.
358 */
359 int
setAttribute(const std::string & attributeName,unsigned int value)360 SedAnalysis::setAttribute(const std::string& attributeName,
361 unsigned int value)
362 {
363 int return_value = SedSimulation::setAttribute(attributeName, value);
364
365 return return_value;
366 }
367
368 /** @endcond */
369
370
371
372 /** @cond doxygenLibSEDMLInternal */
373
374 /*
375 * Sets the value of the "attributeName" attribute of this SedAnalysis.
376 */
377 int
setAttribute(const std::string & attributeName,const std::string & value)378 SedAnalysis::setAttribute(const std::string& attributeName,
379 const std::string& value)
380 {
381 int return_value = SedSimulation::setAttribute(attributeName, value);
382
383 return return_value;
384 }
385
386 /** @endcond */
387
388
389
390 /** @cond doxygenLibSEDMLInternal */
391
392 /*
393 * Unsets the value of the "attributeName" attribute of this SedAnalysis.
394 */
395 int
unsetAttribute(const std::string & attributeName)396 SedAnalysis::unsetAttribute(const std::string& attributeName)
397 {
398 int value = SedSimulation::unsetAttribute(attributeName);
399
400 return value;
401 }
402
403 /** @endcond */
404
405
406
407 /** @cond doxygenLibSEDMLInternal */
408
409 /*
410 * Creates a new object from the next XMLToken on the XMLInputStream
411 */
412 SedBase*
createObject(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLInputStream & stream)413 SedAnalysis::createObject(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLInputStream&
414 stream)
415 {
416 SedBase* obj = SedSimulation::createObject(stream);
417
418 connectToChild();
419
420 return obj;
421 }
422
423 /** @endcond */
424
425
426
427 /** @cond doxygenLibSEDMLInternal */
428
429 /*
430 * Adds the expected attributes for this element
431 */
432 void
addExpectedAttributes(LIBSBML_CPP_NAMESPACE_QUALIFIER ExpectedAttributes & attributes)433 SedAnalysis::addExpectedAttributes(LIBSBML_CPP_NAMESPACE_QUALIFIER
434 ExpectedAttributes& attributes)
435 {
436 SedSimulation::addExpectedAttributes(attributes);
437 }
438
439 /** @endcond */
440
441
442
443 /** @cond doxygenLibSEDMLInternal */
444
445 /*
446 * Reads the expected attributes into the member data variables
447 */
448 void
readAttributes(const LIBSBML_CPP_NAMESPACE_QUALIFIER XMLAttributes & attributes,const LIBSBML_CPP_NAMESPACE_QUALIFIER ExpectedAttributes & expectedAttributes)449 SedAnalysis::readAttributes(
450 const LIBSBML_CPP_NAMESPACE_QUALIFIER
451 XMLAttributes& attributes,
452 const LIBSBML_CPP_NAMESPACE_QUALIFIER
453 ExpectedAttributes& expectedAttributes)
454 {
455 unsigned int level = getLevel();
456 unsigned int version = getVersion();
457 unsigned int numErrs;
458 bool assigned = false;
459 SedErrorLog* log = getErrorLog();
460
461 SedSimulation::readAttributes(attributes, expectedAttributes);
462
463 if (log)
464 {
465 numErrs = log->getNumErrors();
466
467 for (int n = numErrs-1; n >= 0; n--)
468 {
469 if (log->getError(n)->getErrorId() == SedUnknownCoreAttribute)
470 {
471 const std::string details = log->getError(n)->getMessage();
472 log->remove(SedUnknownCoreAttribute);
473 log->logError(SedmlSimulationAllowedAttributes, level, version,
474 details, getLine(), getColumn());
475 }
476 }
477 }
478 }
479
480 /** @endcond */
481
482
483
484 /** @cond doxygenLibSEDMLInternal */
485
486 /*
487 * Writes the attributes to the stream
488 */
489 void
writeAttributes(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream & stream) const490 SedAnalysis::writeAttributes(LIBSBML_CPP_NAMESPACE_QUALIFIER
491 XMLOutputStream& stream) const
492 {
493 SedSimulation::writeAttributes(stream);
494 }
495
496 /** @endcond */
497
498
499
500
501 #endif /* __cplusplus */
502
503
504 /*
505 * Creates a new SedAnalysis_t using the given SED-ML Level and @ p version
506 * values.
507 */
508 LIBSEDML_EXTERN
509 SedAnalysis_t *
SedAnalysis_create(unsigned int level,unsigned int version)510 SedAnalysis_create(unsigned int level, unsigned int version)
511 {
512 return new SedAnalysis(level, version);
513 }
514
515
516 /*
517 * Creates and returns a deep copy of this SedAnalysis_t object.
518 */
519 LIBSEDML_EXTERN
520 SedAnalysis_t*
SedAnalysis_clone(const SedAnalysis_t * sss)521 SedAnalysis_clone(const SedAnalysis_t* sss)
522 {
523 if (sss != NULL)
524 {
525 return static_cast<SedAnalysis_t*>(sss->clone());
526 }
527 else
528 {
529 return NULL;
530 }
531 }
532
533
534 /*
535 * Frees this SedAnalysis_t object.
536 */
537 LIBSEDML_EXTERN
538 void
SedAnalysis_free(SedAnalysis_t * sss)539 SedAnalysis_free(SedAnalysis_t* sss)
540 {
541 if (sss != NULL)
542 {
543 delete sss;
544 }
545 }
546
547
548 /*
549 * Predicate returning @c 1 (true) if all the required attributes for this
550 * SedAnalysis_t object have been set.
551 */
552 LIBSEDML_EXTERN
553 int
SedAnalysis_hasRequiredAttributes(const SedAnalysis_t * sss)554 SedAnalysis_hasRequiredAttributes(const SedAnalysis_t * sss)
555 {
556 return (sss != NULL) ? static_cast<int>(sss->hasRequiredAttributes()) : 0;
557 }
558
559
560
561
562 LIBSEDML_CPP_NAMESPACE_END
563
564
565