1 /**
2 * @file CSGObject.cpp
3 * @brief Implementation of the CSGObject class.
4 * @author SBMLTeam
5 *
6 * <!--------------------------------------------------------------------------
7 * This file is part of libSBML. Please visit http://sbml.org for more
8 * information about SBML, and the latest version of libSBML.
9 *
10 * Copyright (C) 2020 jointly by the following organizations:
11 * 1. California Institute of Technology, Pasadena, CA, USA
12 * 2. University of Heidelberg, Heidelberg, Germany
13 * 3. University College London, London, UK
14 *
15 * Copyright (C) 2019 jointly by the following organizations:
16 * 1. California Institute of Technology, Pasadena, CA, USA
17 * 2. University of Heidelberg, Heidelberg, Germany
18 *
19 * Copyright (C) 2013-2018 jointly by the following organizations:
20 * 1. California Institute of Technology, Pasadena, CA, USA
21 * 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
22 * 3. University of Heidelberg, Heidelberg, Germany
23 *
24 * Copyright (C) 2009-2013 jointly by the following organizations:
25 * 1. California Institute of Technology, Pasadena, CA, USA
26 * 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
27 *
28 * Copyright (C) 2006-2008 by the California Institute of Technology,
29 * Pasadena, CA, USA
30 *
31 * Copyright (C) 2002-2005 jointly by the following organizations:
32 * 1. California Institute of Technology, Pasadena, CA, USA
33 * 2. Japan Science and Technology Agency, Japan
34 *
35 * This library is free software; you can redistribute it and/or modify it
36 * under the terms of the GNU Lesser General Public License as published by the
37 * Free Software Foundation. A copy of the license agreement is provided in the
38 * file named "LICENSE.txt" included with this software distribution and also
39 * available online as http://sbml.org/software/libsbml/license.html
40 * ------------------------------------------------------------------------ -->
41 */
42 #include <sbml/packages/spatial/sbml/CSGObject.h>
43 #include <sbml/packages/spatial/sbml/ListOfCSGObjects.h>
44 #include <sbml/packages/spatial/validator/SpatialSBMLError.h>
45 #include <sbml/util/ElementFilter.h>
46
47 #include <sbml/packages/spatial/sbml/CSGPrimitive.h>
48 #include <sbml/packages/spatial/sbml/CSGTranslation.h>
49 #include <sbml/packages/spatial/sbml/CSGRotation.h>
50 #include <sbml/packages/spatial/sbml/CSGScale.h>
51 #include <sbml/packages/spatial/sbml/CSGHomogeneousTransformation.h>
52 #include <sbml/packages/spatial/sbml/CSGSetOperator.h>
53
54
55 using namespace std;
56
57
58
59 LIBSBML_CPP_NAMESPACE_BEGIN
60
61
62
63
64 #ifdef __cplusplus
65
66
67 /*
68 * Creates a new CSGObject using the given SBML Level, Version and
69 * “spatial” package version.
70 */
CSGObject(unsigned int level,unsigned int version,unsigned int pkgVersion)71 CSGObject::CSGObject(unsigned int level,
72 unsigned int version,
73 unsigned int pkgVersion)
74 : SBase(level, version)
75 , mDomainType ("")
76 , mOrdinal (SBML_INT_MAX)
77 , mIsSetOrdinal (false)
78 , mCSGNode (NULL)
79 {
80 setSBMLNamespacesAndOwn(new SpatialPkgNamespaces(level, version,
81 pkgVersion));
82 connectToChild();
83 }
84
85
86 /*
87 * Creates a new CSGObject using the given SpatialPkgNamespaces object.
88 */
CSGObject(SpatialPkgNamespaces * spatialns)89 CSGObject::CSGObject(SpatialPkgNamespaces *spatialns)
90 : SBase(spatialns)
91 , mDomainType ("")
92 , mOrdinal (SBML_INT_MAX)
93 , mIsSetOrdinal (false)
94 , mCSGNode (NULL)
95 {
96 setElementNamespace(spatialns->getURI());
97 connectToChild();
98 loadPlugins(spatialns);
99 }
100
101
102 /*
103 * Copy constructor for CSGObject.
104 */
CSGObject(const CSGObject & orig)105 CSGObject::CSGObject(const CSGObject& orig)
106 : SBase( orig )
107 , mDomainType ( orig.mDomainType )
108 , mOrdinal ( orig.mOrdinal )
109 , mIsSetOrdinal ( orig.mIsSetOrdinal )
110 , mCSGNode ( NULL )
111 {
112 if (orig.mCSGNode != NULL)
113 {
114 mCSGNode = orig.mCSGNode->clone();
115 }
116
117 connectToChild();
118 }
119
120
121 /*
122 * Assignment operator for CSGObject.
123 */
124 CSGObject&
operator =(const CSGObject & rhs)125 CSGObject::operator=(const CSGObject& rhs)
126 {
127 if (&rhs != this)
128 {
129 SBase::operator=(rhs);
130 mDomainType = rhs.mDomainType;
131 mOrdinal = rhs.mOrdinal;
132 mIsSetOrdinal = rhs.mIsSetOrdinal;
133 delete mCSGNode;
134 if (rhs.mCSGNode != NULL)
135 {
136 mCSGNode = rhs.mCSGNode->clone();
137 }
138 else
139 {
140 mCSGNode = NULL;
141 }
142
143 connectToChild();
144 }
145
146 return *this;
147 }
148
149
150 /*
151 * Creates and returns a deep copy of this CSGObject object.
152 */
153 CSGObject*
clone() const154 CSGObject::clone() const
155 {
156 return new CSGObject(*this);
157 }
158
159
160 /*
161 * Destructor for CSGObject.
162 */
~CSGObject()163 CSGObject::~CSGObject()
164 {
165 delete mCSGNode;
166 mCSGNode = NULL;
167 }
168
169
170 /*
171 * Returns the value of the "id" attribute of this CSGObject.
172 */
173 const std::string&
getId() const174 CSGObject::getId() const
175 {
176 return mId;
177 }
178
179
180 /*
181 * Returns the value of the "name" attribute of this CSGObject.
182 */
183 const std::string&
getName() const184 CSGObject::getName() const
185 {
186 return mName;
187 }
188
189
190 /*
191 * Returns the value of the "domainType" attribute of this CSGObject.
192 */
193 const std::string&
getDomainType() const194 CSGObject::getDomainType() const
195 {
196 return mDomainType;
197 }
198
199
200 /*
201 * Returns the value of the "ordinal" attribute of this CSGObject.
202 */
203 int
getOrdinal() const204 CSGObject::getOrdinal() const
205 {
206 return mOrdinal;
207 }
208
209
210 /*
211 * Predicate returning @c true if this CSGObject's "id" attribute is set.
212 */
213 bool
isSetId() const214 CSGObject::isSetId() const
215 {
216 return (mId.empty() == false);
217 }
218
219
220 /*
221 * Predicate returning @c true if this CSGObject's "name" attribute is set.
222 */
223 bool
isSetName() const224 CSGObject::isSetName() const
225 {
226 return (mName.empty() == false);
227 }
228
229
230 /*
231 * Predicate returning @c true if this CSGObject's "domainType" attribute is
232 * set.
233 */
234 bool
isSetDomainType() const235 CSGObject::isSetDomainType() const
236 {
237 return (mDomainType.empty() == false);
238 }
239
240
241 /*
242 * Predicate returning @c true if this CSGObject's "ordinal" attribute is set.
243 */
244 bool
isSetOrdinal() const245 CSGObject::isSetOrdinal() const
246 {
247 return mIsSetOrdinal;
248 }
249
250
251 /*
252 * Sets the value of the "id" attribute of this CSGObject.
253 */
254 int
setId(const std::string & id)255 CSGObject::setId(const std::string& id)
256 {
257 return SyntaxChecker::checkAndSetSId(id, mId);
258 }
259
260
261 /*
262 * Sets the value of the "name" attribute of this CSGObject.
263 */
264 int
setName(const std::string & name)265 CSGObject::setName(const std::string& name)
266 {
267 mName = name;
268 return LIBSBML_OPERATION_SUCCESS;
269 }
270
271
272 /*
273 * Sets the value of the "domainType" attribute of this CSGObject.
274 */
275 int
setDomainType(const std::string & domainType)276 CSGObject::setDomainType(const std::string& domainType)
277 {
278 if (!(SyntaxChecker::isValidInternalSId(domainType)))
279 {
280 return LIBSBML_INVALID_ATTRIBUTE_VALUE;
281 }
282 else
283 {
284 mDomainType = domainType;
285 return LIBSBML_OPERATION_SUCCESS;
286 }
287 }
288
289
290 /*
291 * Sets the value of the "ordinal" attribute of this CSGObject.
292 */
293 int
setOrdinal(int ordinal)294 CSGObject::setOrdinal(int ordinal)
295 {
296 mOrdinal = ordinal;
297 mIsSetOrdinal = true;
298 return LIBSBML_OPERATION_SUCCESS;
299 }
300
301
302 /*
303 * Unsets the value of the "id" attribute of this CSGObject.
304 */
305 int
unsetId()306 CSGObject::unsetId()
307 {
308 mId.erase();
309
310 if (mId.empty() == true)
311 {
312 return LIBSBML_OPERATION_SUCCESS;
313 }
314 else
315 {
316 return LIBSBML_OPERATION_FAILED;
317 }
318 }
319
320
321 /*
322 * Unsets the value of the "name" attribute of this CSGObject.
323 */
324 int
unsetName()325 CSGObject::unsetName()
326 {
327 mName.erase();
328
329 if (mName.empty() == true)
330 {
331 return LIBSBML_OPERATION_SUCCESS;
332 }
333 else
334 {
335 return LIBSBML_OPERATION_FAILED;
336 }
337 }
338
339
340 /*
341 * Unsets the value of the "domainType" attribute of this CSGObject.
342 */
343 int
unsetDomainType()344 CSGObject::unsetDomainType()
345 {
346 mDomainType.erase();
347
348 if (mDomainType.empty() == true)
349 {
350 return LIBSBML_OPERATION_SUCCESS;
351 }
352 else
353 {
354 return LIBSBML_OPERATION_FAILED;
355 }
356 }
357
358
359 /*
360 * Unsets the value of the "ordinal" attribute of this CSGObject.
361 */
362 int
unsetOrdinal()363 CSGObject::unsetOrdinal()
364 {
365 mOrdinal = SBML_INT_MAX;
366 mIsSetOrdinal = false;
367
368 if (isSetOrdinal() == false)
369 {
370 return LIBSBML_OPERATION_SUCCESS;
371 }
372 else
373 {
374 return LIBSBML_OPERATION_FAILED;
375 }
376 }
377
378
379 /*
380 * Returns the value of the "csgNode" element of this CSGObject.
381 */
382 const CSGNode*
getCSGNode() const383 CSGObject::getCSGNode() const
384 {
385 return mCSGNode;
386 }
387
388
389 /*
390 * Returns the value of the "csgNode" element of this CSGObject.
391 */
392 CSGNode*
getCSGNode()393 CSGObject::getCSGNode()
394 {
395 return mCSGNode;
396 }
397
398
399 /*
400 * Predicate returning @c true if this CSGObject's "csgNode" element is set.
401 */
402 bool
isSetCSGNode() const403 CSGObject::isSetCSGNode() const
404 {
405 return (mCSGNode != NULL);
406 }
407
408
409 /*
410 * Sets the value of the "csgNode" element of this CSGObject.
411 */
412 int
setCSGNode(const CSGNode * csgNode)413 CSGObject::setCSGNode(const CSGNode* csgNode)
414 {
415 if (mCSGNode == csgNode)
416 {
417 return LIBSBML_OPERATION_SUCCESS;
418 }
419 else if (csgNode == NULL)
420 {
421 delete mCSGNode;
422 mCSGNode = NULL;
423 return LIBSBML_OPERATION_SUCCESS;
424 }
425 else
426 {
427 delete mCSGNode;
428 mCSGNode = (csgNode != NULL) ? csgNode->clone() : NULL;
429 if (mCSGNode != NULL)
430 {
431 mCSGNode->connectToParent(this);
432 }
433
434 return LIBSBML_OPERATION_SUCCESS;
435 }
436 }
437
438
439 /*
440 * Creates a new CSGPrimitive object, adds it to this CSGObject object and
441 * returns the CSGPrimitive object created.
442 */
443 CSGPrimitive*
createCSGPrimitive()444 CSGObject::createCSGPrimitive()
445 {
446 if (mCSGNode != NULL)
447 {
448 delete mCSGNode;
449 }
450
451 SPATIAL_CREATE_NS(spatialns, getSBMLNamespaces());
452 mCSGNode = new CSGPrimitive(spatialns);
453
454 delete spatialns;
455
456 connectToChild();
457
458 return static_cast<CSGPrimitive*>(mCSGNode);
459 }
460
461
462 /*
463 * Creates a new CSGTranslation object, adds it to this CSGObject object and
464 * returns the CSGTranslation object created.
465 */
466 CSGTranslation*
createCSGTranslation()467 CSGObject::createCSGTranslation()
468 {
469 if (mCSGNode != NULL)
470 {
471 delete mCSGNode;
472 }
473
474 SPATIAL_CREATE_NS(spatialns, getSBMLNamespaces());
475 mCSGNode = new CSGTranslation(spatialns);
476
477 delete spatialns;
478
479 connectToChild();
480
481 return static_cast<CSGTranslation*>(mCSGNode);
482 }
483
484
485 /*
486 * Creates a new CSGRotation object, adds it to this CSGObject object and
487 * returns the CSGRotation object created.
488 */
489 CSGRotation*
createCSGRotation()490 CSGObject::createCSGRotation()
491 {
492 if (mCSGNode != NULL)
493 {
494 delete mCSGNode;
495 }
496
497 SPATIAL_CREATE_NS(spatialns, getSBMLNamespaces());
498 mCSGNode = new CSGRotation(spatialns);
499
500 delete spatialns;
501
502 connectToChild();
503
504 return static_cast<CSGRotation*>(mCSGNode);
505 }
506
507
508 /*
509 * Creates a new CSGScale object, adds it to this CSGObject object and returns
510 * the CSGScale object created.
511 */
512 CSGScale*
createCSGScale()513 CSGObject::createCSGScale()
514 {
515 if (mCSGNode != NULL)
516 {
517 delete mCSGNode;
518 }
519
520 SPATIAL_CREATE_NS(spatialns, getSBMLNamespaces());
521 mCSGNode = new CSGScale(spatialns);
522
523 delete spatialns;
524
525 connectToChild();
526
527 return static_cast<CSGScale*>(mCSGNode);
528 }
529
530
531 /*
532 * Creates a new CSGHomogeneousTransformation object, adds it to this CSGObject
533 * object and returns the CSGHomogeneousTransformation object created.
534 */
535 CSGHomogeneousTransformation*
createCSGHomogeneousTransformation()536 CSGObject::createCSGHomogeneousTransformation()
537 {
538 if (mCSGNode != NULL)
539 {
540 delete mCSGNode;
541 }
542
543 SPATIAL_CREATE_NS(spatialns, getSBMLNamespaces());
544 mCSGNode = new CSGHomogeneousTransformation(spatialns);
545
546 delete spatialns;
547
548 connectToChild();
549
550 return static_cast<CSGHomogeneousTransformation*>(mCSGNode);
551 }
552
553
554 /*
555 * Creates a new CSGSetOperator object, adds it to this CSGObject object and
556 * returns the CSGSetOperator object created.
557 */
558 CSGSetOperator*
createCSGSetOperator()559 CSGObject::createCSGSetOperator()
560 {
561 if (mCSGNode != NULL)
562 {
563 delete mCSGNode;
564 }
565
566 SPATIAL_CREATE_NS(spatialns, getSBMLNamespaces());
567 mCSGNode = new CSGSetOperator(spatialns);
568
569 delete spatialns;
570
571 connectToChild();
572
573 return static_cast<CSGSetOperator*>(mCSGNode);
574 }
575
576
577 /*
578 * Unsets the value of the "csgNode" element of this CSGObject.
579 */
580 int
unsetCSGNode()581 CSGObject::unsetCSGNode()
582 {
583 delete mCSGNode;
584 mCSGNode = NULL;
585 return LIBSBML_OPERATION_SUCCESS;
586 }
587
588
589 /*
590 * @copydoc doc_renamesidref_common
591 */
592 void
renameSIdRefs(const std::string & oldid,const std::string & newid)593 CSGObject::renameSIdRefs(const std::string& oldid, const std::string& newid)
594 {
595 if (isSetDomainType() && mDomainType == oldid)
596 {
597 setDomainType(newid);
598 }
599 }
600
601
602 /*
603 * Returns the XML element name of this CSGObject object.
604 */
605 const std::string&
getElementName() const606 CSGObject::getElementName() const
607 {
608 static const string name = "csgObject";
609 return name;
610 }
611
612
613 /*
614 * Returns the libSBML type code for this CSGObject object.
615 */
616 int
getTypeCode() const617 CSGObject::getTypeCode() const
618 {
619 return SBML_SPATIAL_CSGOBJECT;
620 }
621
622
623 /*
624 * Predicate returning @c true if all the required attributes for this
625 * CSGObject object have been set.
626 */
627 bool
hasRequiredAttributes() const628 CSGObject::hasRequiredAttributes() const
629 {
630 bool allPresent = true;
631
632 if (isSetId() == false)
633 {
634 allPresent = false;
635 }
636
637 if (isSetDomainType() == false)
638 {
639 allPresent = false;
640 }
641
642 return allPresent;
643 }
644
645
646 /*
647 * Predicate returning @c true if all the required elements for this CSGObject
648 * object have been set.
649 */
650 bool
hasRequiredElements() const651 CSGObject::hasRequiredElements() const
652 {
653 bool allPresent = true;
654
655 if (isSetCSGNode() == false)
656 {
657 allPresent = false;
658 }
659
660 return allPresent;
661 }
662
663
664
665 /** @cond doxygenLibsbmlInternal */
666
667 /*
668 * Write any contained elements
669 */
670 void
writeElements(XMLOutputStream & stream) const671 CSGObject::writeElements(XMLOutputStream& stream) const
672 {
673 SBase::writeElements(stream);
674
675 if (isSetCSGNode() == true)
676 {
677 mCSGNode->write(stream);
678 }
679
680 SBase::writeExtensionElements(stream);
681 }
682
683 /** @endcond */
684
685
686
687 /** @cond doxygenLibsbmlInternal */
688
689 /*
690 * Accepts the given SBMLVisitor
691 */
692 bool
accept(SBMLVisitor & v) const693 CSGObject::accept(SBMLVisitor& v) const
694 {
695 v.visit(*this);
696
697 if (mCSGNode != NULL)
698 {
699 mCSGNode->accept(v);
700 }
701
702 v.leave(*this);
703 return true;
704 }
705
706 /** @endcond */
707
708
709
710 /** @cond doxygenLibsbmlInternal */
711
712 /*
713 * Sets the parent SBMLDocument
714 */
715 void
setSBMLDocument(SBMLDocument * d)716 CSGObject::setSBMLDocument(SBMLDocument* d)
717 {
718 SBase::setSBMLDocument(d);
719
720 if (mCSGNode != NULL)
721 {
722 mCSGNode->setSBMLDocument(d);
723 }
724 }
725
726 /** @endcond */
727
728
729
730 /** @cond doxygenLibsbmlInternal */
731
732 /*
733 * Connects to child elements
734 */
735 void
connectToChild()736 CSGObject::connectToChild()
737 {
738 SBase::connectToChild();
739
740 if (mCSGNode != NULL)
741 {
742 mCSGNode->connectToParent(this);
743 }
744 }
745
746 /** @endcond */
747
748
749
750 /** @cond doxygenLibsbmlInternal */
751
752 /*
753 * Enables/disables the given package with this element
754 */
755 void
enablePackageInternal(const std::string & pkgURI,const std::string & pkgPrefix,bool flag)756 CSGObject::enablePackageInternal(const std::string& pkgURI,
757 const std::string& pkgPrefix,
758 bool flag)
759 {
760 SBase::enablePackageInternal(pkgURI, pkgPrefix, flag);
761
762 if (isSetCSGNode())
763 {
764 mCSGNode->enablePackageInternal(pkgURI, pkgPrefix, flag);
765 }
766 }
767
768 /** @endcond */
769
770
771
772 /** @cond doxygenLibsbmlInternal */
773
774 /*
775 * Updates the namespaces when setLevelVersion is used
776 */
777 void
updateSBMLNamespace(const std::string & package,unsigned int level,unsigned int version)778 CSGObject::updateSBMLNamespace(const std::string& package,
779 unsigned int level,
780 unsigned int version)
781 {
782 SBase::updateSBMLNamespace(package, level, version);
783
784 if (mCSGNode != NULL)
785 {
786 mCSGNode->updateSBMLNamespace(package, level, version);
787 }
788 }
789
790 /** @endcond */
791
792
793
794 /** @cond doxygenLibsbmlInternal */
795
796 /*
797 * Gets the value of the "attributeName" attribute of this CSGObject.
798 */
799 int
getAttribute(const std::string & attributeName,bool & value) const800 CSGObject::getAttribute(const std::string& attributeName, bool& value) const
801 {
802 int return_value = SBase::getAttribute(attributeName, value);
803
804 return return_value;
805 }
806
807 /** @endcond */
808
809
810
811 /** @cond doxygenLibsbmlInternal */
812
813 /*
814 * Gets the value of the "attributeName" attribute of this CSGObject.
815 */
816 int
getAttribute(const std::string & attributeName,int & value) const817 CSGObject::getAttribute(const std::string& attributeName, int& value) const
818 {
819 int return_value = SBase::getAttribute(attributeName, value);
820
821 if (return_value == LIBSBML_OPERATION_SUCCESS)
822 {
823 return return_value;
824 }
825
826 if (attributeName == "ordinal")
827 {
828 value = getOrdinal();
829 return_value = LIBSBML_OPERATION_SUCCESS;
830 }
831
832 return return_value;
833 }
834
835 /** @endcond */
836
837
838
839 /** @cond doxygenLibsbmlInternal */
840
841 /*
842 * Gets the value of the "attributeName" attribute of this CSGObject.
843 */
844 int
getAttribute(const std::string & attributeName,double & value) const845 CSGObject::getAttribute(const std::string& attributeName, double& value) const
846 {
847 int return_value = SBase::getAttribute(attributeName, value);
848
849 return return_value;
850 }
851
852 /** @endcond */
853
854
855
856 /** @cond doxygenLibsbmlInternal */
857
858 /*
859 * Gets the value of the "attributeName" attribute of this CSGObject.
860 */
861 int
getAttribute(const std::string & attributeName,unsigned int & value) const862 CSGObject::getAttribute(const std::string& attributeName,
863 unsigned int& value) const
864 {
865 int return_value = SBase::getAttribute(attributeName, value);
866
867 return return_value;
868 }
869
870 /** @endcond */
871
872
873
874 /** @cond doxygenLibsbmlInternal */
875
876 /*
877 * Gets the value of the "attributeName" attribute of this CSGObject.
878 */
879 int
getAttribute(const std::string & attributeName,std::string & value) const880 CSGObject::getAttribute(const std::string& attributeName,
881 std::string& value) const
882 {
883 int return_value = SBase::getAttribute(attributeName, value);
884
885 if (return_value == LIBSBML_OPERATION_SUCCESS)
886 {
887 return return_value;
888 }
889
890 if (attributeName == "id")
891 {
892 value = getId();
893 return_value = LIBSBML_OPERATION_SUCCESS;
894 }
895 else if (attributeName == "name")
896 {
897 value = getName();
898 return_value = LIBSBML_OPERATION_SUCCESS;
899 }
900 else if (attributeName == "domainType")
901 {
902 value = getDomainType();
903 return_value = LIBSBML_OPERATION_SUCCESS;
904 }
905
906 return return_value;
907 }
908
909 /** @endcond */
910
911
912
913 /** @cond doxygenLibsbmlInternal */
914
915 /*
916 * Predicate returning @c true if this CSGObject's attribute "attributeName" is
917 * set.
918 */
919 bool
isSetAttribute(const std::string & attributeName) const920 CSGObject::isSetAttribute(const std::string& attributeName) const
921 {
922 bool value = SBase::isSetAttribute(attributeName);
923
924 if (attributeName == "id")
925 {
926 value = isSetId();
927 }
928 else if (attributeName == "name")
929 {
930 value = isSetName();
931 }
932 else if (attributeName == "domainType")
933 {
934 value = isSetDomainType();
935 }
936 else if (attributeName == "ordinal")
937 {
938 value = isSetOrdinal();
939 }
940
941 return value;
942 }
943
944 /** @endcond */
945
946
947
948 /** @cond doxygenLibsbmlInternal */
949
950 /*
951 * Sets the value of the "attributeName" attribute of this CSGObject.
952 */
953 int
setAttribute(const std::string & attributeName,bool value)954 CSGObject::setAttribute(const std::string& attributeName, bool value)
955 {
956 int return_value = SBase::setAttribute(attributeName, value);
957
958 return return_value;
959 }
960
961 /** @endcond */
962
963
964
965 /** @cond doxygenLibsbmlInternal */
966
967 /*
968 * Sets the value of the "attributeName" attribute of this CSGObject.
969 */
970 int
setAttribute(const std::string & attributeName,int value)971 CSGObject::setAttribute(const std::string& attributeName, int value)
972 {
973 int return_value = SBase::setAttribute(attributeName, value);
974
975 if (attributeName == "ordinal")
976 {
977 return_value = setOrdinal(value);
978 }
979
980 return return_value;
981 }
982
983 /** @endcond */
984
985
986
987 /** @cond doxygenLibsbmlInternal */
988
989 /*
990 * Sets the value of the "attributeName" attribute of this CSGObject.
991 */
992 int
setAttribute(const std::string & attributeName,double value)993 CSGObject::setAttribute(const std::string& attributeName, double value)
994 {
995 int return_value = SBase::setAttribute(attributeName, value);
996
997 return return_value;
998 }
999
1000 /** @endcond */
1001
1002
1003
1004 /** @cond doxygenLibsbmlInternal */
1005
1006 /*
1007 * Sets the value of the "attributeName" attribute of this CSGObject.
1008 */
1009 int
setAttribute(const std::string & attributeName,unsigned int value)1010 CSGObject::setAttribute(const std::string& attributeName, unsigned int value)
1011 {
1012 int return_value = SBase::setAttribute(attributeName, value);
1013
1014 return return_value;
1015 }
1016
1017 /** @endcond */
1018
1019
1020
1021 /** @cond doxygenLibsbmlInternal */
1022
1023 /*
1024 * Sets the value of the "attributeName" attribute of this CSGObject.
1025 */
1026 int
setAttribute(const std::string & attributeName,const std::string & value)1027 CSGObject::setAttribute(const std::string& attributeName,
1028 const std::string& value)
1029 {
1030 int return_value = SBase::setAttribute(attributeName, value);
1031
1032 if (attributeName == "id")
1033 {
1034 return_value = setId(value);
1035 }
1036 else if (attributeName == "name")
1037 {
1038 return_value = setName(value);
1039 }
1040 else if (attributeName == "domainType")
1041 {
1042 return_value = setDomainType(value);
1043 }
1044
1045 return return_value;
1046 }
1047
1048 /** @endcond */
1049
1050
1051
1052 /** @cond doxygenLibsbmlInternal */
1053
1054 /*
1055 * Unsets the value of the "attributeName" attribute of this CSGObject.
1056 */
1057 int
unsetAttribute(const std::string & attributeName)1058 CSGObject::unsetAttribute(const std::string& attributeName)
1059 {
1060 int value = SBase::unsetAttribute(attributeName);
1061
1062 if (attributeName == "id")
1063 {
1064 value = unsetId();
1065 }
1066 else if (attributeName == "name")
1067 {
1068 value = unsetName();
1069 }
1070 else if (attributeName == "domainType")
1071 {
1072 value = unsetDomainType();
1073 }
1074 else if (attributeName == "ordinal")
1075 {
1076 value = unsetOrdinal();
1077 }
1078
1079 return value;
1080 }
1081
1082 /** @endcond */
1083
1084
1085
1086 /** @cond doxygenLibsbmlInternal */
1087
1088 /*
1089 * Creates and returns an new "elementName" object in this CSGObject.
1090 */
1091 SBase*
createChildObject(const std::string & elementName)1092 CSGObject::createChildObject(const std::string& elementName)
1093 {
1094 SBase* obj = NULL;
1095
1096 if (elementName == "csgPrimitive")
1097 {
1098 return createCSGPrimitive();
1099 }
1100 else if (elementName == "csgTranslation")
1101 {
1102 return createCSGTranslation();
1103 }
1104 else if (elementName == "csgRotation")
1105 {
1106 return createCSGRotation();
1107 }
1108 else if (elementName == "csgScale")
1109 {
1110 return createCSGScale();
1111 }
1112 else if (elementName == "csgHomogeneousTransformation")
1113 {
1114 return createCSGHomogeneousTransformation();
1115 }
1116 else if (elementName == "csgSetOperator")
1117 {
1118 return createCSGSetOperator();
1119 }
1120
1121 return obj;
1122 }
1123
1124 /** @endcond */
1125
1126
1127
1128 /** @cond doxygenLibsbmlInternal */
1129
1130 /*
1131 * Adds a new "elementName" object to this CSGObject.
1132 */
1133 int
addChildObject(const std::string & elementName,const SBase * element)1134 CSGObject::addChildObject(const std::string& elementName,
1135 const SBase* element)
1136 {
1137 if (elementName == "csgPrimitive" && element->getTypeCode() ==
1138 SBML_SPATIAL_CSGPRIMITIVE)
1139 {
1140 return setCSGNode((const CSGNode*)(element));
1141 }
1142 else if (elementName == "csgTranslation" && element->getTypeCode() ==
1143 SBML_SPATIAL_CSGTRANSLATION)
1144 {
1145 return setCSGNode((const CSGNode*)(element));
1146 }
1147 else if (elementName == "csgRotation" && element->getTypeCode() ==
1148 SBML_SPATIAL_CSGROTATION)
1149 {
1150 return setCSGNode((const CSGNode*)(element));
1151 }
1152 else if (elementName == "csgScale" && element->getTypeCode() ==
1153 SBML_SPATIAL_CSGSCALE)
1154 {
1155 return setCSGNode((const CSGNode*)(element));
1156 }
1157 else if (elementName == "csgHomogeneousTransformation" &&
1158 element->getTypeCode() == SBML_SPATIAL_CSGHOMOGENEOUSTRANSFORMATION)
1159 {
1160 return setCSGNode((const CSGNode*)(element));
1161 }
1162 else if (elementName == "csgSetOperator" && element->getTypeCode() ==
1163 SBML_SPATIAL_CSGSETOPERATOR)
1164 {
1165 return setCSGNode((const CSGNode*)(element));
1166 }
1167
1168 return LIBSBML_OPERATION_FAILED;
1169 }
1170
1171 /** @endcond */
1172
1173
1174
1175 /** @cond doxygenLibsbmlInternal */
1176
1177 /*
1178 * Removes and returns the new "elementName" object with the given id in this
1179 * CSGObject.
1180 */
1181 SBase*
removeChildObject(const std::string & elementName,const std::string & id)1182 CSGObject::removeChildObject(const std::string& elementName,
1183 const std::string& id)
1184 {
1185 if (elementName == "csgPrimitive")
1186 {
1187 CSGNode * obj = getCSGNode();
1188 if (unsetCSGNode() == LIBSBML_OPERATION_SUCCESS) return obj;
1189 }
1190 else if (elementName == "csgTranslation")
1191 {
1192 CSGNode * obj = getCSGNode();
1193 if (unsetCSGNode() == LIBSBML_OPERATION_SUCCESS) return obj;
1194 }
1195 else if (elementName == "csgRotation")
1196 {
1197 CSGNode * obj = getCSGNode();
1198 if (unsetCSGNode() == LIBSBML_OPERATION_SUCCESS) return obj;
1199 }
1200 else if (elementName == "csgScale")
1201 {
1202 CSGNode * obj = getCSGNode();
1203 if (unsetCSGNode() == LIBSBML_OPERATION_SUCCESS) return obj;
1204 }
1205 else if (elementName == "csgHomogeneousTransformation")
1206 {
1207 CSGNode * obj = getCSGNode();
1208 if (unsetCSGNode() == LIBSBML_OPERATION_SUCCESS) return obj;
1209 }
1210 else if (elementName == "csgSetOperator")
1211 {
1212 CSGNode * obj = getCSGNode();
1213 if (unsetCSGNode() == LIBSBML_OPERATION_SUCCESS) return obj;
1214 }
1215
1216 return NULL;
1217 }
1218
1219 /** @endcond */
1220
1221
1222
1223 /** @cond doxygenLibsbmlInternal */
1224
1225 /*
1226 * Returns the number of "elementName" in this CSGObject.
1227 */
1228 unsigned int
getNumObjects(const std::string & elementName)1229 CSGObject::getNumObjects(const std::string& elementName)
1230 {
1231 unsigned int n = 0;
1232
1233 if (elementName == "csgNode")
1234 {
1235 if (isSetCSGNode())
1236 {
1237 return 1;
1238 }
1239 }
1240
1241 return n;
1242 }
1243
1244 /** @endcond */
1245
1246
1247
1248 /** @cond doxygenLibsbmlInternal */
1249
1250 /*
1251 * Returns the nth object of "objectName" in this CSGObject.
1252 */
1253 SBase*
getObject(const std::string & elementName,unsigned int index)1254 CSGObject::getObject(const std::string& elementName, unsigned int index)
1255 {
1256 SBase* obj = NULL;
1257
1258 if (elementName == "csgNode")
1259 {
1260 return getCSGNode();
1261 }
1262
1263 return obj;
1264 }
1265
1266 /** @endcond */
1267
1268
1269 /*
1270 * Returns the first child element that has the given @p id in the model-wide
1271 * SId namespace, or @c NULL if no such object is found.
1272 */
1273 SBase*
getElementBySId(const std::string & id)1274 CSGObject::getElementBySId(const std::string& id)
1275 {
1276 if (id.empty())
1277 {
1278 return NULL;
1279 }
1280
1281 SBase* obj = NULL;
1282
1283 if (mCSGNode != NULL)
1284 {
1285 if (mCSGNode->getId() == id)
1286 {
1287 return mCSGNode;
1288 }
1289
1290 obj = mCSGNode->getElementBySId(id);
1291 if (obj != NULL)
1292 {
1293 return obj;
1294 }
1295 }
1296
1297 return obj;
1298 }
1299
1300
1301 /*
1302 * Returns the first child element that has the given @p metaid, or @c NULL if
1303 * no such object is found.
1304 */
1305 SBase*
getElementByMetaId(const std::string & metaid)1306 CSGObject::getElementByMetaId(const std::string& metaid)
1307 {
1308 if (metaid.empty())
1309 {
1310 return NULL;
1311 }
1312
1313 SBase* obj = NULL;
1314
1315 if (mCSGNode != NULL)
1316 {
1317 if (mCSGNode->getMetaId() == metaid)
1318 {
1319 return mCSGNode;
1320 }
1321
1322 obj = mCSGNode->getElementByMetaId(metaid);
1323 if (obj != NULL)
1324 {
1325 return obj;
1326 }
1327 }
1328
1329 return obj;
1330 }
1331
1332
1333 /*
1334 * Returns a List of all child SBase objects, including those nested to an
1335 * arbitrary depth.
1336 */
1337 List*
getAllElements(ElementFilter * filter)1338 CSGObject::getAllElements(ElementFilter* filter)
1339 {
1340 List* ret = new List();
1341 List* sublist = NULL;
1342
1343 ADD_FILTERED_POINTER(ret, sublist, mCSGNode, filter);
1344
1345
1346 ADD_FILTERED_FROM_PLUGIN(ret, sublist, filter);
1347
1348 return ret;
1349 }
1350
1351
1352
1353 /** @cond doxygenLibsbmlInternal */
1354
1355 /*
1356 * Creates a new object from the next XMLToken on the XMLInputStream
1357 */
1358 SBase*
createObject(XMLInputStream & stream)1359 CSGObject::createObject(XMLInputStream& stream)
1360 {
1361 SBase* obj = NULL;
1362
1363 const std::string& name = stream.peek().getName();
1364
1365 SPATIAL_CREATE_NS(spatialns, getSBMLNamespaces());
1366
1367 if (name == "csgPrimitive")
1368 {
1369 if (isSetCSGNode())
1370 {
1371 getErrorLog()->logPackageError("spatial",
1372 SpatialCSGObjectAllowedElements, getPackageVersion(), getLevel(),
1373 getVersion(), "", getLine(), getColumn());
1374 }
1375
1376 delete mCSGNode;
1377 mCSGNode = NULL;
1378 mCSGNode = new CSGPrimitive(spatialns);
1379 obj = mCSGNode;
1380 }
1381 else if (name == "csgTranslation")
1382 {
1383 if (isSetCSGNode())
1384 {
1385 getErrorLog()->logPackageError("spatial",
1386 SpatialCSGObjectAllowedElements, getPackageVersion(), getLevel(),
1387 getVersion(), "", getLine(), getColumn());
1388 }
1389
1390 delete mCSGNode;
1391 mCSGNode = NULL;
1392 mCSGNode = new CSGTranslation(spatialns);
1393 obj = mCSGNode;
1394 }
1395 else if (name == "csgRotation")
1396 {
1397 if (isSetCSGNode())
1398 {
1399 getErrorLog()->logPackageError("spatial",
1400 SpatialCSGObjectAllowedElements, getPackageVersion(), getLevel(),
1401 getVersion(), "", getLine(), getColumn());
1402 }
1403
1404 delete mCSGNode;
1405 mCSGNode = NULL;
1406 mCSGNode = new CSGRotation(spatialns);
1407 obj = mCSGNode;
1408 }
1409 else if (name == "csgScale")
1410 {
1411 if (isSetCSGNode())
1412 {
1413 getErrorLog()->logPackageError("spatial",
1414 SpatialCSGObjectAllowedElements, getPackageVersion(), getLevel(),
1415 getVersion(), "", getLine(), getColumn());
1416 }
1417
1418 delete mCSGNode;
1419 mCSGNode = NULL;
1420 mCSGNode = new CSGScale(spatialns);
1421 obj = mCSGNode;
1422 }
1423 else if (name == "csgHomogeneousTransformation")
1424 {
1425 if (isSetCSGNode())
1426 {
1427 getErrorLog()->logPackageError("spatial",
1428 SpatialCSGObjectAllowedElements, getPackageVersion(), getLevel(),
1429 getVersion(), "", getLine(), getColumn());
1430 }
1431
1432 delete mCSGNode;
1433 mCSGNode = NULL;
1434 mCSGNode = new CSGHomogeneousTransformation(spatialns);
1435 obj = mCSGNode;
1436 }
1437 else if (name == "csgSetOperator")
1438 {
1439 if (isSetCSGNode())
1440 {
1441 getErrorLog()->logPackageError("spatial",
1442 SpatialCSGObjectAllowedElements, getPackageVersion(), getLevel(),
1443 getVersion(), "", getLine(), getColumn());
1444 }
1445
1446 delete mCSGNode;
1447 mCSGNode = NULL;
1448 mCSGNode = new CSGSetOperator(spatialns);
1449 obj = mCSGNode;
1450 }
1451
1452 delete spatialns;
1453
1454 connectToChild();
1455
1456 return obj;
1457 }
1458
1459 /** @endcond */
1460
1461
1462
1463 /** @cond doxygenLibsbmlInternal */
1464
1465 /*
1466 * Adds the expected attributes for this element
1467 */
1468 void
addExpectedAttributes(ExpectedAttributes & attributes)1469 CSGObject::addExpectedAttributes(ExpectedAttributes& attributes)
1470 {
1471 SBase::addExpectedAttributes(attributes);
1472
1473 attributes.add("id");
1474
1475 attributes.add("name");
1476
1477 attributes.add("domainType");
1478
1479 attributes.add("ordinal");
1480 }
1481
1482 /** @endcond */
1483
1484
1485
1486 /** @cond doxygenLibsbmlInternal */
1487
1488 /*
1489 * Reads the expected attributes into the member data variables
1490 */
1491 void
readAttributes(const XMLAttributes & attributes,const ExpectedAttributes & expectedAttributes)1492 CSGObject::readAttributes(const XMLAttributes& attributes,
1493 const ExpectedAttributes& expectedAttributes)
1494 {
1495 unsigned int level = getLevel();
1496 unsigned int version = getVersion();
1497 unsigned int pkgVersion = getPackageVersion();
1498 unsigned int numErrs;
1499 bool assigned = false;
1500 SBMLErrorLog* log = getErrorLog();
1501
1502 if (log && getParentSBMLObject() &&
1503 static_cast<ListOfCSGObjects*>(getParentSBMLObject())->size() < 2)
1504 {
1505 numErrs = log->getNumErrors();
1506 for (int n = numErrs-1; n >= 0; n--)
1507 {
1508 if (log->getError(n)->getErrorId() == UnknownPackageAttribute)
1509 {
1510 const std::string details = log->getError(n)->getMessage();
1511 log->remove(UnknownPackageAttribute);
1512 log->logPackageError("spatial", SpatialCSGObjectAllowedAttributes,
1513 pkgVersion, level, version, details, getLine(), getColumn());
1514 }
1515 else if (log->getError(n)->getErrorId() == UnknownCoreAttribute)
1516 {
1517 const std::string details = log->getError(n)->getMessage();
1518 log->remove(UnknownCoreAttribute);
1519 log->logPackageError("spatial",
1520 SpatialCSGeometryLOCSGObjectsAllowedCoreAttributes, pkgVersion, level,
1521 version, details, getLine(), getColumn());
1522 }
1523 }
1524 }
1525
1526 SBase::readAttributes(attributes, expectedAttributes);
1527
1528 if (log)
1529 {
1530 numErrs = log->getNumErrors();
1531
1532 for (int n = numErrs-1; n >= 0; n--)
1533 {
1534 if (log->getError(n)->getErrorId() == UnknownPackageAttribute)
1535 {
1536 const std::string details = log->getError(n)->getMessage();
1537 log->remove(UnknownPackageAttribute);
1538 log->logPackageError("spatial", SpatialCSGObjectAllowedAttributes,
1539 pkgVersion, level, version, details, getLine(), getColumn());
1540 }
1541 else if (log->getError(n)->getErrorId() == UnknownCoreAttribute)
1542 {
1543 const std::string details = log->getError(n)->getMessage();
1544 log->remove(UnknownCoreAttribute);
1545 log->logPackageError("spatial", SpatialCSGObjectAllowedCoreAttributes,
1546 pkgVersion, level, version, details, getLine(), getColumn());
1547 }
1548 }
1549 }
1550
1551 //
1552 // id SId (use = "required" )
1553 //
1554
1555 assigned = attributes.readInto("id", mId);
1556
1557 if (assigned == true)
1558 {
1559 if (mId.empty() == true)
1560 {
1561 logEmptyString(mId, level, version, "<csgObject>");
1562 }
1563 else if (SyntaxChecker::isValidSBMLSId(mId) == false)
1564 {
1565 log->logPackageError("spatial", SpatialIdSyntaxRule, pkgVersion, level,
1566 version, "The id on the <" + getElementName() + "> is '" + mId + "', "
1567 "which does not conform to the syntax.", getLine(), getColumn());
1568 }
1569 }
1570 else
1571 {
1572 std::string message = "Spatial attribute 'id' is missing from the "
1573 "<csgObject> element.";
1574 log->logPackageError("spatial", SpatialCSGObjectAllowedAttributes,
1575 pkgVersion, level, version, message, getLine(), getColumn());
1576 }
1577
1578 //
1579 // name string (use = "optional" )
1580 //
1581
1582 assigned = attributes.readInto("name", mName);
1583
1584 if (assigned == true)
1585 {
1586 if (mName.empty() == true)
1587 {
1588 logEmptyString(mName, level, version, "<csgObject>");
1589 }
1590 }
1591
1592 //
1593 // domainType SIdRef (use = "required" )
1594 //
1595
1596 assigned = attributes.readInto("domainType", mDomainType);
1597
1598 if (assigned == true)
1599 {
1600 if (mDomainType.empty() == true)
1601 {
1602 logEmptyString(mDomainType, level, version, "<csgObject>");
1603 }
1604 else if (SyntaxChecker::isValidSBMLSId(mDomainType) == false)
1605 {
1606 std::string msg = "The domainType attribute on the <" + getElementName()
1607 + ">";
1608 if (isSetId())
1609 {
1610 msg += " with id '" + getId() + "'";
1611 }
1612
1613 msg += " is '" + mDomainType + "', which does not conform to the "
1614 "syntax.";
1615 log->logPackageError("spatial",
1616 SpatialCSGObjectDomainTypeMustBeDomainType, pkgVersion, level, version,
1617 msg, getLine(), getColumn());
1618 }
1619 }
1620 else
1621 {
1622 std::string message = "Spatial attribute 'domainType' is missing from the "
1623 "<csgObject> element.";
1624 log->logPackageError("spatial", SpatialCSGObjectAllowedAttributes,
1625 pkgVersion, level, version, message, getLine(), getColumn());
1626 }
1627
1628 //
1629 // ordinal int (use = "optional" )
1630 //
1631
1632 numErrs = log->getNumErrors();
1633 mIsSetOrdinal = attributes.readInto("ordinal", mOrdinal);
1634
1635 if ( mIsSetOrdinal == false)
1636 {
1637 if (log->getNumErrors() == numErrs + 1 &&
1638 log->contains(XMLAttributeTypeMismatch))
1639 {
1640 log->remove(XMLAttributeTypeMismatch);
1641 std::string message = "Spatial attribute 'ordinal' from the <csgObject> "
1642 "element must be an integer.";
1643 log->logPackageError("spatial", SpatialCSGObjectOrdinalMustBeInteger,
1644 pkgVersion, level, version, message, getLine(), getColumn());
1645 }
1646 }
1647 }
1648
1649 /** @endcond */
1650
1651
1652
1653 /** @cond doxygenLibsbmlInternal */
1654
1655 /*
1656 * Writes the attributes to the stream
1657 */
1658 void
writeAttributes(XMLOutputStream & stream) const1659 CSGObject::writeAttributes(XMLOutputStream& stream) const
1660 {
1661 SBase::writeAttributes(stream);
1662
1663 if (isSetId() == true)
1664 {
1665 stream.writeAttribute("id", getPrefix(), mId);
1666 }
1667
1668 if (isSetName() == true)
1669 {
1670 stream.writeAttribute("name", getPrefix(), mName);
1671 }
1672
1673 if (isSetDomainType() == true)
1674 {
1675 stream.writeAttribute("domainType", getPrefix(), mDomainType);
1676 }
1677
1678 if (isSetOrdinal() == true)
1679 {
1680 stream.writeAttribute("ordinal", getPrefix(), mOrdinal);
1681 }
1682
1683 SBase::writeExtensionAttributes(stream);
1684 }
1685
1686 /** @endcond */
1687
1688
1689
1690
1691 #endif /* __cplusplus */
1692
1693
1694 /*
1695 * Creates a new CSGObject_t using the given SBML Level, Version and
1696 * “spatial” package version.
1697 */
1698 LIBSBML_EXTERN
1699 CSGObject_t *
CSGObject_create(unsigned int level,unsigned int version,unsigned int pkgVersion)1700 CSGObject_create(unsigned int level,
1701 unsigned int version,
1702 unsigned int pkgVersion)
1703 {
1704 return new CSGObject(level, version, pkgVersion);
1705 }
1706
1707
1708 /*
1709 * Creates and returns a deep copy of this CSGObject_t object.
1710 */
1711 LIBSBML_EXTERN
1712 CSGObject_t*
CSGObject_clone(const CSGObject_t * csgo)1713 CSGObject_clone(const CSGObject_t* csgo)
1714 {
1715 if (csgo != NULL)
1716 {
1717 return static_cast<CSGObject_t*>(csgo->clone());
1718 }
1719 else
1720 {
1721 return NULL;
1722 }
1723 }
1724
1725
1726 /*
1727 * Frees this CSGObject_t object.
1728 */
1729 LIBSBML_EXTERN
1730 void
CSGObject_free(CSGObject_t * csgo)1731 CSGObject_free(CSGObject_t* csgo)
1732 {
1733 if (csgo != NULL)
1734 {
1735 delete csgo;
1736 }
1737 }
1738
1739
1740 /*
1741 * Returns the value of the "id" attribute of this CSGObject_t.
1742 */
1743 LIBSBML_EXTERN
1744 char *
CSGObject_getId(const CSGObject_t * csgo)1745 CSGObject_getId(const CSGObject_t * csgo)
1746 {
1747 if (csgo == NULL)
1748 {
1749 return NULL;
1750 }
1751
1752 return csgo->getId().empty() ? NULL : safe_strdup(csgo->getId().c_str());
1753 }
1754
1755
1756 /*
1757 * Returns the value of the "name" attribute of this CSGObject_t.
1758 */
1759 LIBSBML_EXTERN
1760 char *
CSGObject_getName(const CSGObject_t * csgo)1761 CSGObject_getName(const CSGObject_t * csgo)
1762 {
1763 if (csgo == NULL)
1764 {
1765 return NULL;
1766 }
1767
1768 return csgo->getName().empty() ? NULL : safe_strdup(csgo->getName().c_str());
1769 }
1770
1771
1772 /*
1773 * Returns the value of the "domainType" attribute of this CSGObject_t.
1774 */
1775 LIBSBML_EXTERN
1776 char *
CSGObject_getDomainType(const CSGObject_t * csgo)1777 CSGObject_getDomainType(const CSGObject_t * csgo)
1778 {
1779 if (csgo == NULL)
1780 {
1781 return NULL;
1782 }
1783
1784 return csgo->getDomainType().empty() ? NULL :
1785 safe_strdup(csgo->getDomainType().c_str());
1786 }
1787
1788
1789 /*
1790 * Returns the value of the "ordinal" attribute of this CSGObject_t.
1791 */
1792 LIBSBML_EXTERN
1793 int
CSGObject_getOrdinal(const CSGObject_t * csgo)1794 CSGObject_getOrdinal(const CSGObject_t * csgo)
1795 {
1796 return (csgo != NULL) ? csgo->getOrdinal() : SBML_INT_MAX;
1797 }
1798
1799
1800 /*
1801 * Predicate returning @c 1 (true) if this CSGObject_t's "id" attribute is set.
1802 */
1803 LIBSBML_EXTERN
1804 int
CSGObject_isSetId(const CSGObject_t * csgo)1805 CSGObject_isSetId(const CSGObject_t * csgo)
1806 {
1807 return (csgo != NULL) ? static_cast<int>(csgo->isSetId()) : 0;
1808 }
1809
1810
1811 /*
1812 * Predicate returning @c 1 (true) if this CSGObject_t's "name" attribute is
1813 * set.
1814 */
1815 LIBSBML_EXTERN
1816 int
CSGObject_isSetName(const CSGObject_t * csgo)1817 CSGObject_isSetName(const CSGObject_t * csgo)
1818 {
1819 return (csgo != NULL) ? static_cast<int>(csgo->isSetName()) : 0;
1820 }
1821
1822
1823 /*
1824 * Predicate returning @c 1 (true) if this CSGObject_t's "domainType" attribute
1825 * is set.
1826 */
1827 LIBSBML_EXTERN
1828 int
CSGObject_isSetDomainType(const CSGObject_t * csgo)1829 CSGObject_isSetDomainType(const CSGObject_t * csgo)
1830 {
1831 return (csgo != NULL) ? static_cast<int>(csgo->isSetDomainType()) : 0;
1832 }
1833
1834
1835 /*
1836 * Predicate returning @c 1 (true) if this CSGObject_t's "ordinal" attribute is
1837 * set.
1838 */
1839 LIBSBML_EXTERN
1840 int
CSGObject_isSetOrdinal(const CSGObject_t * csgo)1841 CSGObject_isSetOrdinal(const CSGObject_t * csgo)
1842 {
1843 return (csgo != NULL) ? static_cast<int>(csgo->isSetOrdinal()) : 0;
1844 }
1845
1846
1847 /*
1848 * Sets the value of the "id" attribute of this CSGObject_t.
1849 */
1850 LIBSBML_EXTERN
1851 int
CSGObject_setId(CSGObject_t * csgo,const char * id)1852 CSGObject_setId(CSGObject_t * csgo, const char * id)
1853 {
1854 return (csgo != NULL) ? csgo->setId(id) : LIBSBML_INVALID_OBJECT;
1855 }
1856
1857
1858 /*
1859 * Sets the value of the "name" attribute of this CSGObject_t.
1860 */
1861 LIBSBML_EXTERN
1862 int
CSGObject_setName(CSGObject_t * csgo,const char * name)1863 CSGObject_setName(CSGObject_t * csgo, const char * name)
1864 {
1865 return (csgo != NULL) ? csgo->setName(name) : LIBSBML_INVALID_OBJECT;
1866 }
1867
1868
1869 /*
1870 * Sets the value of the "domainType" attribute of this CSGObject_t.
1871 */
1872 LIBSBML_EXTERN
1873 int
CSGObject_setDomainType(CSGObject_t * csgo,const char * domainType)1874 CSGObject_setDomainType(CSGObject_t * csgo, const char * domainType)
1875 {
1876 return (csgo != NULL) ? csgo->setDomainType(domainType) :
1877 LIBSBML_INVALID_OBJECT;
1878 }
1879
1880
1881 /*
1882 * Sets the value of the "ordinal" attribute of this CSGObject_t.
1883 */
1884 LIBSBML_EXTERN
1885 int
CSGObject_setOrdinal(CSGObject_t * csgo,int ordinal)1886 CSGObject_setOrdinal(CSGObject_t * csgo, int ordinal)
1887 {
1888 return (csgo != NULL) ? csgo->setOrdinal(ordinal) : LIBSBML_INVALID_OBJECT;
1889 }
1890
1891
1892 /*
1893 * Unsets the value of the "id" attribute of this CSGObject_t.
1894 */
1895 LIBSBML_EXTERN
1896 int
CSGObject_unsetId(CSGObject_t * csgo)1897 CSGObject_unsetId(CSGObject_t * csgo)
1898 {
1899 return (csgo != NULL) ? csgo->unsetId() : LIBSBML_INVALID_OBJECT;
1900 }
1901
1902
1903 /*
1904 * Unsets the value of the "name" attribute of this CSGObject_t.
1905 */
1906 LIBSBML_EXTERN
1907 int
CSGObject_unsetName(CSGObject_t * csgo)1908 CSGObject_unsetName(CSGObject_t * csgo)
1909 {
1910 return (csgo != NULL) ? csgo->unsetName() : LIBSBML_INVALID_OBJECT;
1911 }
1912
1913
1914 /*
1915 * Unsets the value of the "domainType" attribute of this CSGObject_t.
1916 */
1917 LIBSBML_EXTERN
1918 int
CSGObject_unsetDomainType(CSGObject_t * csgo)1919 CSGObject_unsetDomainType(CSGObject_t * csgo)
1920 {
1921 return (csgo != NULL) ? csgo->unsetDomainType() : LIBSBML_INVALID_OBJECT;
1922 }
1923
1924
1925 /*
1926 * Unsets the value of the "ordinal" attribute of this CSGObject_t.
1927 */
1928 LIBSBML_EXTERN
1929 int
CSGObject_unsetOrdinal(CSGObject_t * csgo)1930 CSGObject_unsetOrdinal(CSGObject_t * csgo)
1931 {
1932 return (csgo != NULL) ? csgo->unsetOrdinal() : LIBSBML_INVALID_OBJECT;
1933 }
1934
1935
1936 /*
1937 * Returns the value of the "csgNode" element of this CSGObject_t.
1938 */
1939 LIBSBML_EXTERN
1940 const CSGNode_t*
CSGObject_getCSGNode(const CSGObject_t * csgo)1941 CSGObject_getCSGNode(const CSGObject_t * csgo)
1942 {
1943 if (csgo == NULL)
1944 {
1945 return NULL;
1946 }
1947
1948 return (CSGNode_t*)(csgo->getCSGNode());
1949 }
1950
1951
1952 /*
1953 * Predicate returning @c 1 (true) if this CSGObject_t's "csgNode" element is
1954 * set.
1955 */
1956 LIBSBML_EXTERN
1957 int
CSGObject_isSetCSGNode(const CSGObject_t * csgo)1958 CSGObject_isSetCSGNode(const CSGObject_t * csgo)
1959 {
1960 return (csgo != NULL) ? static_cast<int>(csgo->isSetCSGNode()) : 0;
1961 }
1962
1963
1964 /*
1965 * Sets the value of the "csgNode" element of this CSGObject_t.
1966 */
1967 LIBSBML_EXTERN
1968 int
CSGObject_setCSGNode(CSGObject_t * csgo,const CSGNode_t * csgNode)1969 CSGObject_setCSGNode(CSGObject_t * csgo, const CSGNode_t* csgNode)
1970 {
1971 return (csgo != NULL) ? csgo->setCSGNode(csgNode) : LIBSBML_INVALID_OBJECT;
1972 }
1973
1974
1975 /*
1976 * Creates a new CSGPrimitive_t object, adds it to this CSGObject_t object and
1977 * returns the CSGPrimitive_t object created.
1978 */
1979 LIBSBML_EXTERN
1980 CSGPrimitive_t*
CSGObject_createCSGPrimitive(CSGObject_t * csgo)1981 CSGObject_createCSGPrimitive(CSGObject_t* csgo)
1982 {
1983 return (csgo != NULL) ? csgo->createCSGPrimitive() : NULL;
1984 }
1985
1986
1987 /*
1988 * Creates a new CSGTranslation_t object, adds it to this CSGObject_t object
1989 * and returns the CSGTranslation_t object created.
1990 */
1991 LIBSBML_EXTERN
1992 CSGTranslation_t*
CSGObject_createCSGTranslation(CSGObject_t * csgo)1993 CSGObject_createCSGTranslation(CSGObject_t* csgo)
1994 {
1995 return (csgo != NULL) ? csgo->createCSGTranslation() : NULL;
1996 }
1997
1998
1999 /*
2000 * Creates a new CSGRotation_t object, adds it to this CSGObject_t object and
2001 * returns the CSGRotation_t object created.
2002 */
2003 LIBSBML_EXTERN
2004 CSGRotation_t*
CSGObject_createCSGRotation(CSGObject_t * csgo)2005 CSGObject_createCSGRotation(CSGObject_t* csgo)
2006 {
2007 return (csgo != NULL) ? csgo->createCSGRotation() : NULL;
2008 }
2009
2010
2011 /*
2012 * Creates a new CSGScale_t object, adds it to this CSGObject_t object and
2013 * returns the CSGScale_t object created.
2014 */
2015 LIBSBML_EXTERN
2016 CSGScale_t*
CSGObject_createCSGScale(CSGObject_t * csgo)2017 CSGObject_createCSGScale(CSGObject_t* csgo)
2018 {
2019 return (csgo != NULL) ? csgo->createCSGScale() : NULL;
2020 }
2021
2022
2023 /*
2024 * Creates a new CSGHomogeneousTransformation_t object, adds it to this
2025 * CSGObject_t object and returns the CSGHomogeneousTransformation_t object
2026 * created.
2027 */
2028 LIBSBML_EXTERN
2029 CSGHomogeneousTransformation_t*
CSGObject_createCSGHomogeneousTransformation(CSGObject_t * csgo)2030 CSGObject_createCSGHomogeneousTransformation(CSGObject_t* csgo)
2031 {
2032 return (csgo != NULL) ? csgo->createCSGHomogeneousTransformation() : NULL;
2033 }
2034
2035
2036 /*
2037 * Creates a new CSGSetOperator_t object, adds it to this CSGObject_t object
2038 * and returns the CSGSetOperator_t object created.
2039 */
2040 LIBSBML_EXTERN
2041 CSGSetOperator_t*
CSGObject_createCSGSetOperator(CSGObject_t * csgo)2042 CSGObject_createCSGSetOperator(CSGObject_t* csgo)
2043 {
2044 return (csgo != NULL) ? csgo->createCSGSetOperator() : NULL;
2045 }
2046
2047
2048 /*
2049 * Unsets the value of the "csgNode" element of this CSGObject_t.
2050 */
2051 LIBSBML_EXTERN
2052 int
CSGObject_unsetCSGNode(CSGObject_t * csgo)2053 CSGObject_unsetCSGNode(CSGObject_t * csgo)
2054 {
2055 return (csgo != NULL) ? csgo->unsetCSGNode() : LIBSBML_INVALID_OBJECT;
2056 }
2057
2058
2059 /*
2060 * Predicate returning @c 1 (true) if all the required attributes for this
2061 * CSGObject_t object have been set.
2062 */
2063 LIBSBML_EXTERN
2064 int
CSGObject_hasRequiredAttributes(const CSGObject_t * csgo)2065 CSGObject_hasRequiredAttributes(const CSGObject_t * csgo)
2066 {
2067 return (csgo != NULL) ? static_cast<int>(csgo->hasRequiredAttributes()) : 0;
2068 }
2069
2070
2071 /*
2072 * Predicate returning @c 1 (true) if all the required elements for this
2073 * CSGObject_t object have been set.
2074 */
2075 LIBSBML_EXTERN
2076 int
CSGObject_hasRequiredElements(const CSGObject_t * csgo)2077 CSGObject_hasRequiredElements(const CSGObject_t * csgo)
2078 {
2079 return (csgo != NULL) ? static_cast<int>(csgo->hasRequiredElements()) : 0;
2080 }
2081
2082
2083
2084
2085 LIBSBML_CPP_NAMESPACE_END
2086
2087
2088