1 /**
2 * @file SedAxis.cpp
3 * @brief Implementation of the SedAxis 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/SedAxis.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 SedAxis using the given SED-ML Level and @ p version values.
52 */
SedAxis(unsigned int level,unsigned int version)53 SedAxis::SedAxis(unsigned int level, unsigned int version)
54 : SedBase(level, version)
55 , mType (SEDML_AXISTYPE_INVALID)
56 , mMin (util_NaN())
57 , mIsSetMin (false)
58 , mMax (util_NaN())
59 , mIsSetMax (false)
60 , mGrid (false)
61 , mIsSetGrid (false)
62 , mReverse (false)
63 , mIsSetReverse (false)
64 , mStyle ("")
65 , mElementName("axis")
66 {
67 setSedNamespacesAndOwn(new SedNamespaces(level, version));
68 }
69
70
71 /*
72 * Creates a new SedAxis using the given SedNamespaces object @p sedmlns.
73 */
SedAxis(SedNamespaces * sedmlns)74 SedAxis::SedAxis(SedNamespaces *sedmlns)
75 : SedBase(sedmlns)
76 , mType (SEDML_AXISTYPE_INVALID)
77 , mMin (util_NaN())
78 , mIsSetMin (false)
79 , mMax (util_NaN())
80 , mIsSetMax (false)
81 , mGrid (false)
82 , mIsSetGrid (false)
83 , mReverse (false)
84 , mIsSetReverse (false)
85 , mStyle ("")
86 , mElementName("axis")
87 {
88 setElementNamespace(sedmlns->getURI());
89 }
90
91
92 /*
93 * Copy constructor for SedAxis.
94 */
SedAxis(const SedAxis & orig)95 SedAxis::SedAxis(const SedAxis& orig)
96 : SedBase( orig )
97 , mType ( orig.mType )
98 , mMin ( orig.mMin )
99 , mIsSetMin ( orig.mIsSetMin )
100 , mMax ( orig.mMax )
101 , mIsSetMax ( orig.mIsSetMax )
102 , mGrid ( orig.mGrid )
103 , mIsSetGrid ( orig.mIsSetGrid )
104 , mReverse ( orig.mReverse )
105 , mIsSetReverse ( orig.mIsSetReverse )
106 , mStyle ( orig.mStyle )
107 , mElementName ( orig.mElementName )
108 {
109 }
110
111
112 /*
113 * Assignment operator for SedAxis.
114 */
115 SedAxis&
operator =(const SedAxis & rhs)116 SedAxis::operator=(const SedAxis& rhs)
117 {
118 if (&rhs != this)
119 {
120 SedBase::operator=(rhs);
121 mType = rhs.mType;
122 mMin = rhs.mMin;
123 mIsSetMin = rhs.mIsSetMin;
124 mMax = rhs.mMax;
125 mIsSetMax = rhs.mIsSetMax;
126 mGrid = rhs.mGrid;
127 mIsSetGrid = rhs.mIsSetGrid;
128 mReverse = rhs.mReverse;
129 mIsSetReverse = rhs.mIsSetReverse;
130 mStyle = rhs.mStyle;
131 mElementName = rhs.mElementName;
132 }
133
134 return *this;
135 }
136
137
138 /*
139 * Creates and returns a deep copy of this SedAxis object.
140 */
141 SedAxis*
clone() const142 SedAxis::clone() const
143 {
144 return new SedAxis(*this);
145 }
146
147
148 /*
149 * Destructor for SedAxis.
150 */
~SedAxis()151 SedAxis::~SedAxis()
152 {
153 }
154
155
156 /*
157 * Returns the value of the "type" attribute of this SedAxis.
158 */
159 AxisType_t
getType() const160 SedAxis::getType() const
161 {
162 return mType;
163 }
164
165
166 /*
167 * Returns the value of the "type" attribute of this SedAxis.
168 */
169 std::string
getTypeAsString() const170 SedAxis::getTypeAsString() const
171 {
172 std::string code_str = AxisType_toString(mType);
173 return code_str;
174 }
175
176
177 /*
178 * Returns the value of the "min" attribute of this SedAxis.
179 */
180 double
getMin() const181 SedAxis::getMin() const
182 {
183 return mMin;
184 }
185
186
187 /*
188 * Returns the value of the "max" attribute of this SedAxis.
189 */
190 double
getMax() const191 SedAxis::getMax() const
192 {
193 return mMax;
194 }
195
196
197 /*
198 * Returns the value of the "grid" attribute of this SedAxis.
199 */
200 bool
getGrid() const201 SedAxis::getGrid() const
202 {
203 return mGrid;
204 }
205
206
207 /*
208 * Returns the value of the "reverse" attribute of this SedAxis.
209 */
210 bool
getReverse() const211 SedAxis::getReverse() const
212 {
213 return mReverse;
214 }
215
216
217 /*
218 * Returns the value of the "style" attribute of this SedAxis.
219 */
220 const std::string&
getStyle() const221 SedAxis::getStyle() const
222 {
223 return mStyle;
224 }
225
226
227 /*
228 * Predicate returning @c true if this SedAxis's "type" attribute is set.
229 */
230 bool
isSetType() const231 SedAxis::isSetType() const
232 {
233 return (mType != SEDML_AXISTYPE_INVALID);
234 }
235
236
237 /*
238 * Predicate returning @c true if this SedAxis's "min" attribute is set.
239 */
240 bool
isSetMin() const241 SedAxis::isSetMin() const
242 {
243 return mIsSetMin;
244 }
245
246
247 /*
248 * Predicate returning @c true if this SedAxis's "max" attribute is set.
249 */
250 bool
isSetMax() const251 SedAxis::isSetMax() const
252 {
253 return mIsSetMax;
254 }
255
256
257 /*
258 * Predicate returning @c true if this SedAxis's "grid" attribute is set.
259 */
260 bool
isSetGrid() const261 SedAxis::isSetGrid() const
262 {
263 return mIsSetGrid;
264 }
265
266
267 /*
268 * Predicate returning @c true if this SedAxis's "reverse" attribute is set.
269 */
270 bool
isSetReverse() const271 SedAxis::isSetReverse() const
272 {
273 return mIsSetReverse;
274 }
275
276
277 /*
278 * Predicate returning @c true if this SedAxis's "style" attribute is set.
279 */
280 bool
isSetStyle() const281 SedAxis::isSetStyle() const
282 {
283 return (mStyle.empty() == false);
284 }
285
286
287 /*
288 * Sets the value of the "type" attribute of this SedAxis.
289 */
290 int
setType(const AxisType_t type)291 SedAxis::setType(const AxisType_t type)
292 {
293 if (AxisType_isValid(type) == 0)
294 {
295 mType = SEDML_AXISTYPE_INVALID;
296 return LIBSEDML_INVALID_ATTRIBUTE_VALUE;
297 }
298 else
299 {
300 mType = type;
301 return LIBSEDML_OPERATION_SUCCESS;
302 }
303 }
304
305
306 /*
307 * Sets the value of the "type" attribute of this SedAxis.
308 */
309 int
setType(const std::string & type)310 SedAxis::setType(const std::string& type)
311 {
312 mType = AxisType_fromString(type.c_str());
313
314 if (mType == SEDML_AXISTYPE_INVALID)
315 {
316 return LIBSEDML_INVALID_ATTRIBUTE_VALUE;
317 }
318
319 return LIBSEDML_OPERATION_SUCCESS;
320 }
321
322
323 /*
324 * Sets the value of the "min" attribute of this SedAxis.
325 */
326 int
setMin(double min)327 SedAxis::setMin(double min)
328 {
329 mMin = min;
330 mIsSetMin = true;
331 return LIBSEDML_OPERATION_SUCCESS;
332 }
333
334
335 /*
336 * Sets the value of the "max" attribute of this SedAxis.
337 */
338 int
setMax(double max)339 SedAxis::setMax(double max)
340 {
341 mMax = max;
342 mIsSetMax = true;
343 return LIBSEDML_OPERATION_SUCCESS;
344 }
345
346
347 /*
348 * Sets the value of the "grid" attribute of this SedAxis.
349 */
350 int
setGrid(bool grid)351 SedAxis::setGrid(bool grid)
352 {
353 mGrid = grid;
354 mIsSetGrid = true;
355 return LIBSEDML_OPERATION_SUCCESS;
356 }
357
358
359 /*
360 * Sets the value of the "reverse" attribute of this SedAxis.
361 */
362 int
setReverse(bool reverse)363 SedAxis::setReverse(bool reverse)
364 {
365 mReverse = reverse;
366 mIsSetReverse = true;
367 return LIBSEDML_OPERATION_SUCCESS;
368 }
369
370
371 /*
372 * Sets the value of the "style" attribute of this SedAxis.
373 */
374 int
setStyle(const std::string & style)375 SedAxis::setStyle(const std::string& style)
376 {
377 if (!(SyntaxChecker::isValidInternalSId(style)))
378 {
379 return LIBSEDML_INVALID_ATTRIBUTE_VALUE;
380 }
381 else
382 {
383 mStyle = style;
384 return LIBSEDML_OPERATION_SUCCESS;
385 }
386 }
387
388
389 /*
390 * Unsets the value of the "type" attribute of this SedAxis.
391 */
392 int
unsetType()393 SedAxis::unsetType()
394 {
395 mType = SEDML_AXISTYPE_INVALID;
396 return LIBSEDML_OPERATION_SUCCESS;
397 }
398
399
400 /*
401 * Unsets the value of the "min" attribute of this SedAxis.
402 */
403 int
unsetMin()404 SedAxis::unsetMin()
405 {
406 mMin = util_NaN();
407 mIsSetMin = false;
408
409 if (isSetMin() == false)
410 {
411 return LIBSEDML_OPERATION_SUCCESS;
412 }
413 else
414 {
415 return LIBSEDML_OPERATION_FAILED;
416 }
417 }
418
419
420 /*
421 * Unsets the value of the "max" attribute of this SedAxis.
422 */
423 int
unsetMax()424 SedAxis::unsetMax()
425 {
426 mMax = util_NaN();
427 mIsSetMax = false;
428
429 if (isSetMax() == false)
430 {
431 return LIBSEDML_OPERATION_SUCCESS;
432 }
433 else
434 {
435 return LIBSEDML_OPERATION_FAILED;
436 }
437 }
438
439
440 /*
441 * Unsets the value of the "grid" attribute of this SedAxis.
442 */
443 int
unsetGrid()444 SedAxis::unsetGrid()
445 {
446 mGrid = false;
447 mIsSetGrid = false;
448
449 if (isSetGrid() == false)
450 {
451 return LIBSEDML_OPERATION_SUCCESS;
452 }
453 else
454 {
455 return LIBSEDML_OPERATION_FAILED;
456 }
457 }
458
459
460 /*
461 * Unsets the value of the "reverse" attribute of this SedAxis.
462 */
463 int
unsetReverse()464 SedAxis::unsetReverse()
465 {
466 mReverse = false;
467 mIsSetReverse = false;
468
469 if (isSetReverse() == false)
470 {
471 return LIBSEDML_OPERATION_SUCCESS;
472 }
473 else
474 {
475 return LIBSEDML_OPERATION_FAILED;
476 }
477 }
478
479
480 /*
481 * Unsets the value of the "style" attribute of this SedAxis.
482 */
483 int
unsetStyle()484 SedAxis::unsetStyle()
485 {
486 mStyle.erase();
487
488 if (mStyle.empty() == true)
489 {
490 return LIBSEDML_OPERATION_SUCCESS;
491 }
492 else
493 {
494 return LIBSEDML_OPERATION_FAILED;
495 }
496 }
497
498
499 /*
500 * @copydoc doc_renamesidref_common
501 */
502 void
renameSIdRefs(const std::string & oldid,const std::string & newid)503 SedAxis::renameSIdRefs(const std::string& oldid, const std::string& newid)
504 {
505 if (isSetStyle() && mStyle == oldid)
506 {
507 setStyle(newid);
508 }
509 }
510
511
512 /*
513 * Returns the XML element name of this SedAxis object.
514 */
515 const std::string&
getElementName() const516 SedAxis::getElementName() const
517 {
518 return mElementName;
519 }
520
521
522
523 /** @cond doxygenLibSEDMLInternal */
524
525 /*
526 * Sets the XML name of this SedAxis object.
527 */
528 void
setElementName(const std::string & name)529 SedAxis::setElementName(const std::string& name)
530 {
531 mElementName = name;
532 }
533
534 /** @endcond */
535
536
537 /*
538 * Returns the libSEDML type code for this SedAxis object.
539 */
540 int
getTypeCode() const541 SedAxis::getTypeCode() const
542 {
543 return SEDML_AXIS;
544 }
545
546
547 /*
548 * Predicate returning @c true if all the required attributes for this SedAxis
549 * object have been set.
550 */
551 bool
hasRequiredAttributes() const552 SedAxis::hasRequiredAttributes() const
553 {
554 bool allPresent = true;
555
556 if (isSetType() == false)
557 {
558 allPresent = false;
559 }
560
561 return allPresent;
562 }
563
564
565
566 /** @cond doxygenLibSEDMLInternal */
567
568 /*
569 * Write any contained elements
570 */
571 void
writeElements(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream & stream) const572 SedAxis::writeElements(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream& stream)
573 const
574 {
575 SedBase::writeElements(stream);
576 }
577
578 /** @endcond */
579
580
581
582 /** @cond doxygenLibSEDMLInternal */
583
584 /*
585 * Accepts the given SedVisitor
586 */
587 bool
accept(SedVisitor & v) const588 SedAxis::accept(SedVisitor& v) const
589 {
590 return false;
591 }
592
593 /** @endcond */
594
595
596
597 /** @cond doxygenLibSEDMLInternal */
598
599 /*
600 * Sets the parent SedDocument
601 */
602 void
setSedDocument(SedDocument * d)603 SedAxis::setSedDocument(SedDocument* d)
604 {
605 SedBase::setSedDocument(d);
606 }
607
608 /** @endcond */
609
610
611
612 /** @cond doxygenLibSEDMLInternal */
613
614 /*
615 * Gets the value of the "attributeName" attribute of this SedAxis.
616 */
617 int
getAttribute(const std::string & attributeName,bool & value) const618 SedAxis::getAttribute(const std::string& attributeName, bool& value) const
619 {
620 int return_value = SedBase::getAttribute(attributeName, value);
621
622 if (return_value == LIBSEDML_OPERATION_SUCCESS)
623 {
624 return return_value;
625 }
626
627 if (attributeName == "grid")
628 {
629 value = getGrid();
630 return_value = LIBSEDML_OPERATION_SUCCESS;
631 }
632
633 if (attributeName == "reverse")
634 {
635 value = getReverse();
636 return_value = LIBSEDML_OPERATION_SUCCESS;
637 }
638
639 return return_value;
640 }
641
642 /** @endcond */
643
644
645
646 /** @cond doxygenLibSEDMLInternal */
647
648 /*
649 * Gets the value of the "attributeName" attribute of this SedAxis.
650 */
651 int
getAttribute(const std::string & attributeName,int & value) const652 SedAxis::getAttribute(const std::string& attributeName, int& value) const
653 {
654 int return_value = SedBase::getAttribute(attributeName, value);
655
656 return return_value;
657 }
658
659 /** @endcond */
660
661
662
663 /** @cond doxygenLibSEDMLInternal */
664
665 /*
666 * Gets the value of the "attributeName" attribute of this SedAxis.
667 */
668 int
getAttribute(const std::string & attributeName,double & value) const669 SedAxis::getAttribute(const std::string& attributeName, double& value) const
670 {
671 int return_value = SedBase::getAttribute(attributeName, value);
672
673 if (return_value == LIBSEDML_OPERATION_SUCCESS)
674 {
675 return return_value;
676 }
677
678 if (attributeName == "min")
679 {
680 value = getMin();
681 return_value = LIBSEDML_OPERATION_SUCCESS;
682 }
683 else if (attributeName == "max")
684 {
685 value = getMax();
686 return_value = LIBSEDML_OPERATION_SUCCESS;
687 }
688
689 return return_value;
690 }
691
692 /** @endcond */
693
694
695
696 /** @cond doxygenLibSEDMLInternal */
697
698 /*
699 * Gets the value of the "attributeName" attribute of this SedAxis.
700 */
701 int
getAttribute(const std::string & attributeName,unsigned int & value) const702 SedAxis::getAttribute(const std::string& attributeName,
703 unsigned int& value) const
704 {
705 int return_value = SedBase::getAttribute(attributeName, value);
706
707 return return_value;
708 }
709
710 /** @endcond */
711
712
713
714 /** @cond doxygenLibSEDMLInternal */
715
716 /*
717 * Gets the value of the "attributeName" attribute of this SedAxis.
718 */
719 int
getAttribute(const std::string & attributeName,std::string & value) const720 SedAxis::getAttribute(const std::string& attributeName,
721 std::string& value) const
722 {
723 int return_value = SedBase::getAttribute(attributeName, value);
724
725 if (return_value == LIBSEDML_OPERATION_SUCCESS)
726 {
727 return return_value;
728 }
729
730 if (attributeName == "type")
731 {
732 value = getTypeAsString();
733 return_value = LIBSEDML_OPERATION_SUCCESS;
734 }
735 else if (attributeName == "style")
736 {
737 value = getStyle();
738 return_value = LIBSEDML_OPERATION_SUCCESS;
739 }
740
741 return return_value;
742 }
743
744 /** @endcond */
745
746
747
748 /** @cond doxygenLibSEDMLInternal */
749
750 /*
751 * Predicate returning @c true if this SedAxis's attribute "attributeName" is
752 * set.
753 */
754 bool
isSetAttribute(const std::string & attributeName) const755 SedAxis::isSetAttribute(const std::string& attributeName) const
756 {
757 bool value = SedBase::isSetAttribute(attributeName);
758
759 if (attributeName == "type")
760 {
761 value = isSetType();
762 }
763 else if (attributeName == "min")
764 {
765 value = isSetMin();
766 }
767 else if (attributeName == "max")
768 {
769 value = isSetMax();
770 }
771 else if (attributeName == "grid")
772 {
773 value = isSetGrid();
774 }
775 else if (attributeName == "reverse")
776 {
777 value = isSetReverse();
778 }
779 else if (attributeName == "style")
780 {
781 value = isSetStyle();
782 }
783
784 return value;
785 }
786
787 /** @endcond */
788
789
790
791 /** @cond doxygenLibSEDMLInternal */
792
793 /*
794 * Sets the value of the "attributeName" attribute of this SedAxis.
795 */
796 int
setAttribute(const std::string & attributeName,bool value)797 SedAxis::setAttribute(const std::string& attributeName, bool value)
798 {
799 int return_value = SedBase::setAttribute(attributeName, value);
800
801 if (attributeName == "grid")
802 {
803 return_value = setGrid(value);
804 }
805 else if (attributeName == "reverse")
806 {
807 return_value = setReverse(value);
808 }
809
810 return return_value;
811 }
812
813 /** @endcond */
814
815
816
817 /** @cond doxygenLibSEDMLInternal */
818
819 /*
820 * Sets the value of the "attributeName" attribute of this SedAxis.
821 */
822 int
setAttribute(const std::string & attributeName,int value)823 SedAxis::setAttribute(const std::string& attributeName, int value)
824 {
825 int return_value = SedBase::setAttribute(attributeName, value);
826
827 return return_value;
828 }
829
830 /** @endcond */
831
832
833
834 /** @cond doxygenLibSEDMLInternal */
835
836 /*
837 * Sets the value of the "attributeName" attribute of this SedAxis.
838 */
839 int
setAttribute(const std::string & attributeName,double value)840 SedAxis::setAttribute(const std::string& attributeName, double value)
841 {
842 int return_value = SedBase::setAttribute(attributeName, value);
843
844 if (attributeName == "min")
845 {
846 return_value = setMin(value);
847 }
848 else if (attributeName == "max")
849 {
850 return_value = setMax(value);
851 }
852
853 return return_value;
854 }
855
856 /** @endcond */
857
858
859
860 /** @cond doxygenLibSEDMLInternal */
861
862 /*
863 * Sets the value of the "attributeName" attribute of this SedAxis.
864 */
865 int
setAttribute(const std::string & attributeName,unsigned int value)866 SedAxis::setAttribute(const std::string& attributeName, unsigned int value)
867 {
868 int return_value = SedBase::setAttribute(attributeName, value);
869
870 return return_value;
871 }
872
873 /** @endcond */
874
875
876
877 /** @cond doxygenLibSEDMLInternal */
878
879 /*
880 * Sets the value of the "attributeName" attribute of this SedAxis.
881 */
882 int
setAttribute(const std::string & attributeName,const std::string & value)883 SedAxis::setAttribute(const std::string& attributeName,
884 const std::string& value)
885 {
886 int return_value = SedBase::setAttribute(attributeName, value);
887
888 if (attributeName == "type")
889 {
890 return_value = setType(value);
891 }
892 else if (attributeName == "style")
893 {
894 return_value = setStyle(value);
895 }
896
897 return return_value;
898 }
899
900 /** @endcond */
901
902
903
904 /** @cond doxygenLibSEDMLInternal */
905
906 /*
907 * Unsets the value of the "attributeName" attribute of this SedAxis.
908 */
909 int
unsetAttribute(const std::string & attributeName)910 SedAxis::unsetAttribute(const std::string& attributeName)
911 {
912 int value = SedBase::unsetAttribute(attributeName);
913
914 if (attributeName == "type")
915 {
916 value = unsetType();
917 }
918 else if (attributeName == "min")
919 {
920 value = unsetMin();
921 }
922 else if (attributeName == "max")
923 {
924 value = unsetMax();
925 }
926 else if (attributeName == "grid")
927 {
928 value = unsetGrid();
929 }
930 else if (attributeName == "reverse")
931 {
932 value = unsetReverse();
933 }
934 else if (attributeName == "style")
935 {
936 value = unsetStyle();
937 }
938
939 return value;
940 }
941
942 /** @endcond */
943
944
945
946 /** @cond doxygenLibSEDMLInternal */
947
948 /*
949 * Adds the expected attributes for this element
950 */
951 void
addExpectedAttributes(LIBSBML_CPP_NAMESPACE_QUALIFIER ExpectedAttributes & attributes)952 SedAxis::addExpectedAttributes(LIBSBML_CPP_NAMESPACE_QUALIFIER
953 ExpectedAttributes& attributes)
954 {
955 SedBase::addExpectedAttributes(attributes);
956
957 attributes.add("type");
958
959 attributes.add("min");
960
961 attributes.add("max");
962
963 attributes.add("grid");
964
965 attributes.add("reverse");
966
967 attributes.add("style");
968 }
969
970 /** @endcond */
971
972
973
974 /** @cond doxygenLibSEDMLInternal */
975
976 /*
977 * Reads the expected attributes into the member data variables
978 */
979 void
readAttributes(const LIBSBML_CPP_NAMESPACE_QUALIFIER XMLAttributes & attributes,const LIBSBML_CPP_NAMESPACE_QUALIFIER ExpectedAttributes & expectedAttributes)980 SedAxis::readAttributes(
981 const LIBSBML_CPP_NAMESPACE_QUALIFIER XMLAttributes&
982 attributes,
983 const LIBSBML_CPP_NAMESPACE_QUALIFIER
984 ExpectedAttributes& expectedAttributes)
985 {
986 unsigned int level = getLevel();
987 unsigned int version = getVersion();
988 unsigned int numErrs;
989 bool assigned = false;
990 SedErrorLog* log = getErrorLog();
991
992 SedBase::readAttributes(attributes, expectedAttributes);
993
994 if (log)
995 {
996 numErrs = log->getNumErrors();
997
998 for (int n = numErrs-1; n >= 0; n--)
999 {
1000 if (log->getError(n)->getErrorId() == SedUnknownCoreAttribute)
1001 {
1002 const std::string details = log->getError(n)->getMessage();
1003 log->remove(SedUnknownCoreAttribute);
1004 log->logError(SedmlAxisAllowedAttributes, level, version, details,
1005 getLine(), getColumn());
1006 }
1007 }
1008 }
1009
1010 //
1011 // type enum (use = "required" )
1012 //
1013
1014 std::string type;
1015 assigned = attributes.readInto("type", type);
1016
1017 if (assigned == true)
1018 {
1019 if (type.empty() == true)
1020 {
1021 logEmptyString(type, level, version, "<SedAxis>");
1022 }
1023 else
1024 {
1025 mType = AxisType_fromString(type.c_str());
1026
1027 if (log && AxisType_isValid(mType) == 0)
1028 {
1029 std::string msg = "The type on the <SedAxis> ";
1030
1031 if (isSetId())
1032 {
1033 msg += "with id '" + getId() + "'";
1034 }
1035
1036 msg += "is '" + type + "', which is not a valid option.";
1037
1038 log->logError(SedmlAxisTypeMustBeAxisTypeEnum, level, version, msg,
1039 getLine(), getColumn());
1040 }
1041 }
1042 }
1043 else
1044 {
1045 if (log)
1046 {
1047 std::string message = "Sedml attribute 'type' is missing.";
1048 log->logError(SedmlAxisAllowedAttributes, level, version, message,
1049 getLine(), getColumn());
1050 }
1051 }
1052
1053 //
1054 // min double (use = "optional" )
1055 //
1056
1057 numErrs = log ? log->getNumErrors() : 0;
1058 mIsSetMin = attributes.readInto("min", mMin);
1059
1060 if ( mIsSetMin == false && log)
1061 {
1062 if (log && log->getNumErrors() == numErrs + 1 &&
1063 log->contains(XMLAttributeTypeMismatch))
1064 {
1065 log->remove(XMLAttributeTypeMismatch);
1066 std::string message = "Sedml attribute 'min' from the <SedAxis> element "
1067 "must be an integer.";
1068 log->logError(SedmlAxisMinMustBeDouble, level, version, message,
1069 getLine(), getColumn());
1070 }
1071 }
1072
1073 //
1074 // max double (use = "optional" )
1075 //
1076
1077 numErrs = log ? log->getNumErrors() : 0;
1078 mIsSetMax = attributes.readInto("max", mMax);
1079
1080 if ( mIsSetMax == false && log)
1081 {
1082 if (log && log->getNumErrors() == numErrs + 1 &&
1083 log->contains(XMLAttributeTypeMismatch))
1084 {
1085 log->remove(XMLAttributeTypeMismatch);
1086 std::string message = "Sedml attribute 'max' from the <SedAxis> element "
1087 "must be an integer.";
1088 log->logError(SedmlAxisMaxMustBeDouble, level, version, message,
1089 getLine(), getColumn());
1090 }
1091 }
1092
1093 //
1094 // grid bool (use = "optional" )
1095 //
1096
1097 numErrs = log ? log->getNumErrors() : 0;
1098 mIsSetGrid = attributes.readInto("grid", mGrid);
1099
1100 if (mIsSetGrid == false)
1101 {
1102 if (log && log->getNumErrors() == numErrs + 1 &&
1103 log->contains(XMLAttributeTypeMismatch))
1104 {
1105 log->remove(XMLAttributeTypeMismatch);
1106 log->logError(SedmlAxisGridMustBeBoolean, level, version);
1107 }
1108 }
1109
1110 //
1111 // reverse bool (use = "optional" )
1112 //
1113
1114 numErrs = log ? log->getNumErrors() : 0;
1115 mIsSetReverse = attributes.readInto("reverse", mReverse);
1116
1117 if (mIsSetReverse == false)
1118 {
1119 if (log && log->getNumErrors() == numErrs + 1 &&
1120 log->contains(XMLAttributeTypeMismatch))
1121 {
1122 log->remove(XMLAttributeTypeMismatch);
1123 log->logError(SedmlAxisReverseMustBeBoolean, level, version);
1124 }
1125 }
1126
1127 //
1128 // style SIdRef (use = "optional" )
1129 //
1130
1131 assigned = attributes.readInto("style", mStyle);
1132
1133 if (assigned == true)
1134 {
1135 if (mStyle.empty() == true)
1136 {
1137 logEmptyString(mStyle, level, version, "<SedAxis>");
1138 }
1139 else if (SyntaxChecker::isValidSBMLSId(mStyle) == false)
1140 {
1141 std::string msg = "The style attribute on the <" + getElementName() +
1142 ">";
1143 if (isSetId())
1144 {
1145 msg += " with id '" + getId() + "'";
1146 }
1147
1148 msg += " is '" + mStyle + "', which does not conform to the syntax.";
1149 logError(SedmlAxisStyleMustBeStyle, level, version, msg, getLine(),
1150 getColumn());
1151 }
1152 }
1153 }
1154
1155 /** @endcond */
1156
1157
1158
1159 /** @cond doxygenLibSEDMLInternal */
1160
1161 /*
1162 * Writes the attributes to the stream
1163 */
1164 void
writeAttributes(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream & stream) const1165 SedAxis::writeAttributes(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream&
1166 stream) const
1167 {
1168 SedBase::writeAttributes(stream);
1169
1170 if (isSetType() == true)
1171 {
1172 stream.writeAttribute("type", getPrefix(), AxisType_toString(mType));
1173 }
1174
1175 if (isSetMin() == true)
1176 {
1177 stream.writeAttribute("min", getPrefix(), mMin);
1178 }
1179
1180 if (isSetMax() == true)
1181 {
1182 stream.writeAttribute("max", getPrefix(), mMax);
1183 }
1184
1185 if (isSetGrid() == true)
1186 {
1187 stream.writeAttribute("grid", getPrefix(), mGrid);
1188 }
1189
1190 if (isSetReverse() == true)
1191 {
1192 stream.writeAttribute("reverse", getPrefix(), mReverse);
1193 }
1194
1195 if (isSetStyle() == true)
1196 {
1197 stream.writeAttribute("style", getPrefix(), mStyle);
1198 }
1199 }
1200
1201 /** @endcond */
1202
1203
1204
1205
1206 #endif /* __cplusplus */
1207
1208
1209 /*
1210 * Creates a new SedAxis_t using the given SED-ML Level and @ p version values.
1211 */
1212 LIBSEDML_EXTERN
1213 SedAxis_t *
SedAxis_create(unsigned int level,unsigned int version)1214 SedAxis_create(unsigned int level, unsigned int version)
1215 {
1216 return new SedAxis(level, version);
1217 }
1218
1219
1220 /*
1221 * Creates and returns a deep copy of this SedAxis_t object.
1222 */
1223 LIBSEDML_EXTERN
1224 SedAxis_t*
SedAxis_clone(const SedAxis_t * sa)1225 SedAxis_clone(const SedAxis_t* sa)
1226 {
1227 if (sa != NULL)
1228 {
1229 return static_cast<SedAxis_t*>(sa->clone());
1230 }
1231 else
1232 {
1233 return NULL;
1234 }
1235 }
1236
1237
1238 /*
1239 * Frees this SedAxis_t object.
1240 */
1241 LIBSEDML_EXTERN
1242 void
SedAxis_free(SedAxis_t * sa)1243 SedAxis_free(SedAxis_t* sa)
1244 {
1245 if (sa != NULL)
1246 {
1247 delete sa;
1248 }
1249 }
1250
1251
1252 /*
1253 * Returns the value of the "type" attribute of this SedAxis_t.
1254 */
1255 LIBSEDML_EXTERN
1256 AxisType_t
SedAxis_getType(const SedAxis_t * sa)1257 SedAxis_getType(const SedAxis_t * sa)
1258 {
1259 if (sa == NULL)
1260 {
1261 return SEDML_AXISTYPE_INVALID;
1262 }
1263
1264 return sa->getType();
1265 }
1266
1267
1268 /*
1269 * Returns the value of the "type" attribute of this SedAxis_t.
1270 */
1271 LIBSEDML_EXTERN
1272 char *
SedAxis_getTypeAsString(const SedAxis_t * sa)1273 SedAxis_getTypeAsString(const SedAxis_t * sa)
1274 {
1275 return (char*)(AxisType_toString(sa->getType()));
1276 }
1277
1278
1279 /*
1280 * Returns the value of the "min" attribute of this SedAxis_t.
1281 */
1282 LIBSEDML_EXTERN
1283 double
SedAxis_getMin(const SedAxis_t * sa)1284 SedAxis_getMin(const SedAxis_t * sa)
1285 {
1286 return (sa != NULL) ? sa->getMin() : util_NaN();
1287 }
1288
1289
1290 /*
1291 * Returns the value of the "max" attribute of this SedAxis_t.
1292 */
1293 LIBSEDML_EXTERN
1294 double
SedAxis_getMax(const SedAxis_t * sa)1295 SedAxis_getMax(const SedAxis_t * sa)
1296 {
1297 return (sa != NULL) ? sa->getMax() : util_NaN();
1298 }
1299
1300
1301 /*
1302 * Returns the value of the "grid" attribute of this SedAxis_t.
1303 */
1304 LIBSEDML_EXTERN
1305 int
SedAxis_getGrid(const SedAxis_t * sa)1306 SedAxis_getGrid(const SedAxis_t * sa)
1307 {
1308 return (sa != NULL) ? static_cast<int>(sa->getGrid()) : 0;
1309 }
1310
1311
1312 /*
1313 * Returns the value of the "reverse" attribute of this SedAxis_t.
1314 */
1315 LIBSEDML_EXTERN
1316 int
SedAxis_getReverse(const SedAxis_t * sa)1317 SedAxis_getReverse(const SedAxis_t* sa)
1318 {
1319 return (sa != NULL) ? static_cast<int>(sa->getReverse()) : 0;
1320 }
1321
1322
1323 /*
1324 * Returns the value of the "style" attribute of this SedAxis_t.
1325 */
1326 LIBSEDML_EXTERN
1327 char *
SedAxis_getStyle(const SedAxis_t * sa)1328 SedAxis_getStyle(const SedAxis_t * sa)
1329 {
1330 if (sa == NULL)
1331 {
1332 return NULL;
1333 }
1334
1335 return sa->getStyle().empty() ? NULL : safe_strdup(sa->getStyle().c_str());
1336 }
1337
1338
1339 /*
1340 * Predicate returning @c 1 (true) if this SedAxis_t's "type" attribute is set.
1341 */
1342 LIBSEDML_EXTERN
1343 int
SedAxis_isSetType(const SedAxis_t * sa)1344 SedAxis_isSetType(const SedAxis_t * sa)
1345 {
1346 return (sa != NULL) ? static_cast<int>(sa->isSetType()) : 0;
1347 }
1348
1349
1350 /*
1351 * Predicate returning @c 1 (true) if this SedAxis_t's "min" attribute is set.
1352 */
1353 LIBSEDML_EXTERN
1354 int
SedAxis_isSetMin(const SedAxis_t * sa)1355 SedAxis_isSetMin(const SedAxis_t * sa)
1356 {
1357 return (sa != NULL) ? static_cast<int>(sa->isSetMin()) : 0;
1358 }
1359
1360
1361 /*
1362 * Predicate returning @c 1 (true) if this SedAxis_t's "max" attribute is set.
1363 */
1364 LIBSEDML_EXTERN
1365 int
SedAxis_isSetMax(const SedAxis_t * sa)1366 SedAxis_isSetMax(const SedAxis_t * sa)
1367 {
1368 return (sa != NULL) ? static_cast<int>(sa->isSetMax()) : 0;
1369 }
1370
1371
1372 /*
1373 * Predicate returning @c 1 (true) if this SedAxis_t's "grid" attribute is set.
1374 */
1375 LIBSEDML_EXTERN
1376 int
SedAxis_isSetGrid(const SedAxis_t * sa)1377 SedAxis_isSetGrid(const SedAxis_t * sa)
1378 {
1379 return (sa != NULL) ? static_cast<int>(sa->isSetGrid()) : 0;
1380 }
1381
1382
1383 /*
1384 * Predicate returning @c 1 (true) if this SedAxis_t's "reverse" attribute is set.
1385 */
1386 LIBSEDML_EXTERN
1387 int
SedAxis_isSetReverse(const SedAxis_t * sa)1388 SedAxis_isSetReverse(const SedAxis_t* sa)
1389 {
1390 return (sa != NULL) ? static_cast<int>(sa->isSetReverse()) : 0;
1391 }
1392
1393
1394 /*
1395 * Predicate returning @c 1 (true) if this SedAxis_t's "style" attribute is
1396 * set.
1397 */
1398 LIBSEDML_EXTERN
1399 int
SedAxis_isSetStyle(const SedAxis_t * sa)1400 SedAxis_isSetStyle(const SedAxis_t * sa)
1401 {
1402 return (sa != NULL) ? static_cast<int>(sa->isSetStyle()) : 0;
1403 }
1404
1405
1406 /*
1407 * Sets the value of the "type" attribute of this SedAxis_t.
1408 */
1409 LIBSEDML_EXTERN
1410 int
SedAxis_setType(SedAxis_t * sa,AxisType_t type)1411 SedAxis_setType(SedAxis_t * sa, AxisType_t type)
1412 {
1413 return (sa != NULL) ? sa->setType(type) : LIBSEDML_INVALID_OBJECT;
1414 }
1415
1416
1417 /*
1418 * Sets the value of the "type" attribute of this SedAxis_t.
1419 */
1420 LIBSEDML_EXTERN
1421 int
SedAxis_setTypeAsString(SedAxis_t * sa,const char * type)1422 SedAxis_setTypeAsString(SedAxis_t * sa, const char * type)
1423 {
1424 return (sa != NULL) ? sa->setType(type): LIBSEDML_INVALID_OBJECT;
1425 }
1426
1427
1428 /*
1429 * Sets the value of the "min" attribute of this SedAxis_t.
1430 */
1431 LIBSEDML_EXTERN
1432 int
SedAxis_setMin(SedAxis_t * sa,double min)1433 SedAxis_setMin(SedAxis_t * sa, double min)
1434 {
1435 return (sa != NULL) ? sa->setMin(min) : LIBSEDML_INVALID_OBJECT;
1436 }
1437
1438
1439 /*
1440 * Sets the value of the "max" attribute of this SedAxis_t.
1441 */
1442 LIBSEDML_EXTERN
1443 int
SedAxis_setMax(SedAxis_t * sa,double max)1444 SedAxis_setMax(SedAxis_t * sa, double max)
1445 {
1446 return (sa != NULL) ? sa->setMax(max) : LIBSEDML_INVALID_OBJECT;
1447 }
1448
1449
1450 /*
1451 * Sets the value of the "grid" attribute of this SedAxis_t.
1452 */
1453 LIBSEDML_EXTERN
1454 int
SedAxis_setGrid(SedAxis_t * sa,int grid)1455 SedAxis_setGrid(SedAxis_t * sa, int grid)
1456 {
1457 return (sa != NULL) ? sa->setGrid(grid) : LIBSEDML_INVALID_OBJECT;
1458 }
1459
1460
1461 /*
1462 * Sets the value of the "reverse" attribute of this SedAxis_t.
1463 */
1464 LIBSEDML_EXTERN
1465 int
SedAxis_setReverse(SedAxis_t * sa,int reverse)1466 SedAxis_setReverse(SedAxis_t* sa, int reverse)
1467 {
1468 return (sa != NULL) ? sa->setReverse(reverse) : LIBSEDML_INVALID_OBJECT;
1469 }
1470
1471
1472 /*
1473 * Sets the value of the "style" attribute of this SedAxis_t.
1474 */
1475 LIBSEDML_EXTERN
1476 int
SedAxis_setStyle(SedAxis_t * sa,const char * style)1477 SedAxis_setStyle(SedAxis_t * sa, const char * style)
1478 {
1479 return (sa != NULL) ? sa->setStyle(style) : LIBSEDML_INVALID_OBJECT;
1480 }
1481
1482
1483 /*
1484 * Unsets the value of the "type" attribute of this SedAxis_t.
1485 */
1486 LIBSEDML_EXTERN
1487 int
SedAxis_unsetType(SedAxis_t * sa)1488 SedAxis_unsetType(SedAxis_t * sa)
1489 {
1490 return (sa != NULL) ? sa->unsetType() : LIBSEDML_INVALID_OBJECT;
1491 }
1492
1493
1494 /*
1495 * Unsets the value of the "min" attribute of this SedAxis_t.
1496 */
1497 LIBSEDML_EXTERN
1498 int
SedAxis_unsetMin(SedAxis_t * sa)1499 SedAxis_unsetMin(SedAxis_t * sa)
1500 {
1501 return (sa != NULL) ? sa->unsetMin() : LIBSEDML_INVALID_OBJECT;
1502 }
1503
1504
1505 /*
1506 * Unsets the value of the "max" attribute of this SedAxis_t.
1507 */
1508 LIBSEDML_EXTERN
1509 int
SedAxis_unsetMax(SedAxis_t * sa)1510 SedAxis_unsetMax(SedAxis_t * sa)
1511 {
1512 return (sa != NULL) ? sa->unsetMax() : LIBSEDML_INVALID_OBJECT;
1513 }
1514
1515
1516 /*
1517 * Unsets the value of the "grid" attribute of this SedAxis_t.
1518 */
1519 LIBSEDML_EXTERN
1520 int
SedAxis_unsetGrid(SedAxis_t * sa)1521 SedAxis_unsetGrid(SedAxis_t * sa)
1522 {
1523 return (sa != NULL) ? sa->unsetGrid() : LIBSEDML_INVALID_OBJECT;
1524 }
1525
1526
1527 /*
1528 * Unsets the value of the "reverse" attribute of this SedAxis_t.
1529 */
1530 LIBSEDML_EXTERN
1531 int
SedAxis_unsetReverse(SedAxis_t * sa)1532 SedAxis_unsetReverse(SedAxis_t* sa)
1533 {
1534 return (sa != NULL) ? sa->unsetReverse() : LIBSEDML_INVALID_OBJECT;
1535 }
1536
1537
1538 /*
1539 * Unsets the value of the "style" attribute of this SedAxis_t.
1540 */
1541 LIBSEDML_EXTERN
1542 int
SedAxis_unsetStyle(SedAxis_t * sa)1543 SedAxis_unsetStyle(SedAxis_t * sa)
1544 {
1545 return (sa != NULL) ? sa->unsetStyle() : LIBSEDML_INVALID_OBJECT;
1546 }
1547
1548
1549 /*
1550 * Predicate returning @c 1 (true) if all the required attributes for this
1551 * SedAxis_t object have been set.
1552 */
1553 LIBSEDML_EXTERN
1554 int
SedAxis_hasRequiredAttributes(const SedAxis_t * sa)1555 SedAxis_hasRequiredAttributes(const SedAxis_t * sa)
1556 {
1557 return (sa != NULL) ? static_cast<int>(sa->hasRequiredAttributes()) : 0;
1558 }
1559
1560
1561
1562
1563 LIBSEDML_CPP_NAMESPACE_END
1564
1565
1566