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