1 /**
2  * @file SedObjective.cpp
3  * @brief Implementation of the SedObjective 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/SedObjective.h>
35 #include <sbml/xml/XMLInputStream.h>
36 
37 #include <sedml/SedLeastSquareObjectiveFunction.h>
38 
39 
40 using namespace std;
41 
42 
43 
44 LIBSEDML_CPP_NAMESPACE_BEGIN
45 
46 
47 
48 
49 #ifdef __cplusplus
50 
51 
52 /*
53  * Creates a new SedObjective using the given SED-ML Level and @ p version
54  * values.
55  */
SedObjective(unsigned int level,unsigned int version)56 SedObjective::SedObjective(unsigned int level, unsigned int version)
57   : SedBase(level, version)
58   , mElementName("objective")
59 {
60   setSedNamespacesAndOwn(new SedNamespaces(level, version));
61 }
62 
63 
64 /*
65  * Creates a new SedObjective using the given SedNamespaces object @p sedmlns.
66  */
SedObjective(SedNamespaces * sedmlns)67 SedObjective::SedObjective(SedNamespaces *sedmlns)
68   : SedBase(sedmlns)
69   , mElementName("objective")
70 {
71   setElementNamespace(sedmlns->getURI());
72 }
73 
74 
75 /*
76  * Copy constructor for SedObjective.
77  */
SedObjective(const SedObjective & orig)78 SedObjective::SedObjective(const SedObjective& orig)
79   : SedBase( orig )
80   , mElementName ( orig.mElementName )
81 {
82 }
83 
84 
85 /*
86  * Assignment operator for SedObjective.
87  */
88 SedObjective&
operator =(const SedObjective & rhs)89 SedObjective::operator=(const SedObjective& rhs)
90 {
91   if (&rhs != this)
92   {
93     SedBase::operator=(rhs);
94     mElementName = rhs.mElementName;
95   }
96 
97   return *this;
98 }
99 
100 
101 /*
102  * Creates and returns a deep copy of this SedObjective object.
103  */
104 SedObjective*
clone() const105 SedObjective::clone() const
106 {
107   return new SedObjective(*this);
108 }
109 
110 
111 /*
112  * Destructor for SedObjective.
113  */
~SedObjective()114 SedObjective::~SedObjective()
115 {
116 }
117 
118 
119 /*
120  * Predicate returning @c true if this abstract "SedObjective" is of type
121  * SedLeastSquareObjectiveFunction
122  */
123 bool
isSedLeastSquareObjectiveFunction() const124 SedObjective::isSedLeastSquareObjectiveFunction() const
125 {
126   return dynamic_cast<const SedLeastSquareObjectiveFunction*>(this) != NULL;
127 }
128 
129 
130 /*
131  * Returns the XML element name of this SedObjective object.
132  */
133 const std::string&
getElementName() const134 SedObjective::getElementName() const
135 {
136   return mElementName;
137 }
138 
139 
140 
141 /** @cond doxygenLibSEDMLInternal */
142 
143 /*
144  * Sets the XML name of this SedObjective object.
145  */
146 void
setElementName(const std::string & name)147 SedObjective::setElementName(const std::string& name)
148 {
149   mElementName = name;
150 }
151 
152 /** @endcond */
153 
154 
155 /*
156  * Returns the libSEDML type code for this SedObjective object.
157  */
158 int
getTypeCode() const159 SedObjective::getTypeCode() const
160 {
161   return SEDML_OBJECTIVE;
162 }
163 
164 
165 
166 /** @cond doxygenLibSEDMLInternal */
167 
168 /*
169  * Write any contained elements
170  */
171 void
writeElements(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream & stream) const172 SedObjective::writeElements(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream&
173   stream) const
174 {
175   SedBase::writeElements(stream);
176 }
177 
178 /** @endcond */
179 
180 
181 
182 /** @cond doxygenLibSEDMLInternal */
183 
184 /*
185  * Accepts the given SedVisitor
186  */
187 bool
accept(SedVisitor & v) const188 SedObjective::accept(SedVisitor& v) const
189 {
190   return false;
191 }
192 
193 /** @endcond */
194 
195 
196 
197 /** @cond doxygenLibSEDMLInternal */
198 
199 /*
200  * Sets the parent SedDocument
201  */
202 void
setSedDocument(SedDocument * d)203 SedObjective::setSedDocument(SedDocument* d)
204 {
205   SedBase::setSedDocument(d);
206 }
207 
208 /** @endcond */
209 
210 
211 
212 /** @cond doxygenLibSEDMLInternal */
213 
214 /*
215  * Gets the value of the "attributeName" attribute of this SedObjective.
216  */
217 int
getAttribute(const std::string & attributeName,bool & value) const218 SedObjective::getAttribute(const std::string& attributeName,
219                            bool& value) const
220 {
221   int return_value = SedBase::getAttribute(attributeName, value);
222 
223   return return_value;
224 }
225 
226 /** @endcond */
227 
228 
229 
230 /** @cond doxygenLibSEDMLInternal */
231 
232 /*
233  * Gets the value of the "attributeName" attribute of this SedObjective.
234  */
235 int
getAttribute(const std::string & attributeName,int & value) const236 SedObjective::getAttribute(const std::string& attributeName, int& value) const
237 {
238   int return_value = SedBase::getAttribute(attributeName, value);
239 
240   return return_value;
241 }
242 
243 /** @endcond */
244 
245 
246 
247 /** @cond doxygenLibSEDMLInternal */
248 
249 /*
250  * Gets the value of the "attributeName" attribute of this SedObjective.
251  */
252 int
getAttribute(const std::string & attributeName,double & value) const253 SedObjective::getAttribute(const std::string& attributeName,
254                            double& value) const
255 {
256   int return_value = SedBase::getAttribute(attributeName, value);
257 
258   return return_value;
259 }
260 
261 /** @endcond */
262 
263 
264 
265 /** @cond doxygenLibSEDMLInternal */
266 
267 /*
268  * Gets the value of the "attributeName" attribute of this SedObjective.
269  */
270 int
getAttribute(const std::string & attributeName,unsigned int & value) const271 SedObjective::getAttribute(const std::string& attributeName,
272                            unsigned int& value) const
273 {
274   int return_value = SedBase::getAttribute(attributeName, value);
275 
276   return return_value;
277 }
278 
279 /** @endcond */
280 
281 
282 
283 /** @cond doxygenLibSEDMLInternal */
284 
285 /*
286  * Gets the value of the "attributeName" attribute of this SedObjective.
287  */
288 int
getAttribute(const std::string & attributeName,std::string & value) const289 SedObjective::getAttribute(const std::string& attributeName,
290                            std::string& value) const
291 {
292   int return_value = SedBase::getAttribute(attributeName, value);
293 
294   return return_value;
295 }
296 
297 /** @endcond */
298 
299 
300 
301 /** @cond doxygenLibSEDMLInternal */
302 
303 /*
304  * Predicate returning @c true if this SedObjective's attribute "attributeName"
305  * is set.
306  */
307 bool
isSetAttribute(const std::string & attributeName) const308 SedObjective::isSetAttribute(const std::string& attributeName) const
309 {
310   bool value = SedBase::isSetAttribute(attributeName);
311 
312   return value;
313 }
314 
315 /** @endcond */
316 
317 
318 
319 /** @cond doxygenLibSEDMLInternal */
320 
321 /*
322  * Sets the value of the "attributeName" attribute of this SedObjective.
323  */
324 int
setAttribute(const std::string & attributeName,bool value)325 SedObjective::setAttribute(const std::string& attributeName, bool value)
326 {
327   int return_value = SedBase::setAttribute(attributeName, value);
328 
329   return return_value;
330 }
331 
332 /** @endcond */
333 
334 
335 
336 /** @cond doxygenLibSEDMLInternal */
337 
338 /*
339  * Sets the value of the "attributeName" attribute of this SedObjective.
340  */
341 int
setAttribute(const std::string & attributeName,int value)342 SedObjective::setAttribute(const std::string& attributeName, int value)
343 {
344   int return_value = SedBase::setAttribute(attributeName, value);
345 
346   return return_value;
347 }
348 
349 /** @endcond */
350 
351 
352 
353 /** @cond doxygenLibSEDMLInternal */
354 
355 /*
356  * Sets the value of the "attributeName" attribute of this SedObjective.
357  */
358 int
setAttribute(const std::string & attributeName,double value)359 SedObjective::setAttribute(const std::string& attributeName, double value)
360 {
361   int return_value = SedBase::setAttribute(attributeName, value);
362 
363   return return_value;
364 }
365 
366 /** @endcond */
367 
368 
369 
370 /** @cond doxygenLibSEDMLInternal */
371 
372 /*
373  * Sets the value of the "attributeName" attribute of this SedObjective.
374  */
375 int
setAttribute(const std::string & attributeName,unsigned int value)376 SedObjective::setAttribute(const std::string& attributeName,
377                            unsigned int value)
378 {
379   int return_value = SedBase::setAttribute(attributeName, value);
380 
381   return return_value;
382 }
383 
384 /** @endcond */
385 
386 
387 
388 /** @cond doxygenLibSEDMLInternal */
389 
390 /*
391  * Sets the value of the "attributeName" attribute of this SedObjective.
392  */
393 int
setAttribute(const std::string & attributeName,const std::string & value)394 SedObjective::setAttribute(const std::string& attributeName,
395                            const std::string& value)
396 {
397   int return_value = SedBase::setAttribute(attributeName, value);
398 
399   return return_value;
400 }
401 
402 /** @endcond */
403 
404 
405 
406 /** @cond doxygenLibSEDMLInternal */
407 
408 /*
409  * Unsets the value of the "attributeName" attribute of this SedObjective.
410  */
411 int
unsetAttribute(const std::string & attributeName)412 SedObjective::unsetAttribute(const std::string& attributeName)
413 {
414   int value = SedBase::unsetAttribute(attributeName);
415 
416   return value;
417 }
418 
419 /** @endcond */
420 
421 
422 
423 
424 #endif /* __cplusplus */
425 
426 
427 /*
428  * Creates a new SedLeastSquareObjectiveFunction using the given SED-ML Level
429  * and @ p version values.
430  */
431 LIBSEDML_EXTERN
432 SedLeastSquareObjectiveFunction_t *
SedObjective_createLeastSquareObjectiveFunction(unsigned int level,unsigned int version)433 SedObjective_createLeastSquareObjectiveFunction(unsigned int level,
434                                                 unsigned int version)
435 {
436   return new SedLeastSquareObjectiveFunction(level, version);
437 }
438 
439 
440 /*
441  * Creates and returns a deep copy of this SedObjective_t object.
442  */
443 LIBSEDML_EXTERN
444 SedObjective_t*
SedObjective_clone(const SedObjective_t * so)445 SedObjective_clone(const SedObjective_t* so)
446 {
447   if (so != NULL)
448   {
449     return static_cast<SedObjective_t*>(so->clone());
450   }
451   else
452   {
453     return NULL;
454   }
455 }
456 
457 
458 /*
459  * Frees this SedObjective_t object.
460  */
461 LIBSEDML_EXTERN
462 void
SedObjective_free(SedObjective_t * so)463 SedObjective_free(SedObjective_t* so)
464 {
465   if (so != NULL)
466   {
467     delete so;
468   }
469 }
470 
471 
472 /*
473  * Predicate returning @c 1 if this SedObjective_t is of type
474  * SedLeastSquareObjectiveFunction_t
475  */
476 LIBSEDML_EXTERN
477 int
SedObjective_isSedLeastSquareObjectiveFunction(const SedObjective_t * so)478 SedObjective_isSedLeastSquareObjectiveFunction(const SedObjective_t * so)
479 {
480   return (so != NULL) ?
481     static_cast<int>(so->isSedLeastSquareObjectiveFunction()) : 0;
482 }
483 
484 
485 
486 
487 LIBSEDML_CPP_NAMESPACE_END
488 
489 
490