1 /**
2  * @file AdjacentDomains.cpp
3  * @brief Implementation of the AdjacentDomains 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/AdjacentDomains.h>
43 #include <sbml/packages/spatial/sbml/ListOfAdjacentDomains.h>
44 #include <sbml/packages/spatial/validator/SpatialSBMLError.h>
45 
46 
47 using namespace std;
48 
49 
50 
51 LIBSBML_CPP_NAMESPACE_BEGIN
52 
53 
54 
55 
56 #ifdef __cplusplus
57 
58 
59 /*
60  * Creates a new AdjacentDomains using the given SBML Level, Version and
61  * &ldquo;spatial&rdquo; package version.
62  */
AdjacentDomains(unsigned int level,unsigned int version,unsigned int pkgVersion)63 AdjacentDomains::AdjacentDomains(unsigned int level,
64                                  unsigned int version,
65                                  unsigned int pkgVersion)
66   : SBase(level, version)
67   , mDomain1 ("")
68   , mDomain2 ("")
69 {
70   setSBMLNamespacesAndOwn(new SpatialPkgNamespaces(level, version,
71     pkgVersion));
72 }
73 
74 
75 /*
76  * Creates a new AdjacentDomains using the given SpatialPkgNamespaces object.
77  */
AdjacentDomains(SpatialPkgNamespaces * spatialns)78 AdjacentDomains::AdjacentDomains(SpatialPkgNamespaces *spatialns)
79   : SBase(spatialns)
80   , mDomain1 ("")
81   , mDomain2 ("")
82 {
83   setElementNamespace(spatialns->getURI());
84   loadPlugins(spatialns);
85 }
86 
87 
88 /*
89  * Copy constructor for AdjacentDomains.
90  */
AdjacentDomains(const AdjacentDomains & orig)91 AdjacentDomains::AdjacentDomains(const AdjacentDomains& orig)
92   : SBase( orig )
93   , mDomain1 ( orig.mDomain1 )
94   , mDomain2 ( orig.mDomain2 )
95 {
96 }
97 
98 
99 /*
100  * Assignment operator for AdjacentDomains.
101  */
102 AdjacentDomains&
operator =(const AdjacentDomains & rhs)103 AdjacentDomains::operator=(const AdjacentDomains& rhs)
104 {
105   if (&rhs != this)
106   {
107     SBase::operator=(rhs);
108     mDomain1 = rhs.mDomain1;
109     mDomain2 = rhs.mDomain2;
110   }
111 
112   return *this;
113 }
114 
115 
116 /*
117  * Creates and returns a deep copy of this AdjacentDomains object.
118  */
119 AdjacentDomains*
clone() const120 AdjacentDomains::clone() const
121 {
122   return new AdjacentDomains(*this);
123 }
124 
125 
126 /*
127  * Destructor for AdjacentDomains.
128  */
~AdjacentDomains()129 AdjacentDomains::~AdjacentDomains()
130 {
131 }
132 
133 
134 /*
135  * Returns the value of the "id" attribute of this AdjacentDomains.
136  */
137 const std::string&
getId() const138 AdjacentDomains::getId() const
139 {
140   return mId;
141 }
142 
143 
144 /*
145  * Returns the value of the "name" attribute of this AdjacentDomains.
146  */
147 const std::string&
getName() const148 AdjacentDomains::getName() const
149 {
150   return mName;
151 }
152 
153 
154 /*
155  * Returns the value of the "domain1" attribute of this AdjacentDomains.
156  */
157 const std::string&
getDomain1() const158 AdjacentDomains::getDomain1() const
159 {
160   return mDomain1;
161 }
162 
163 
164 /*
165  * Returns the value of the "domain2" attribute of this AdjacentDomains.
166  */
167 const std::string&
getDomain2() const168 AdjacentDomains::getDomain2() const
169 {
170   return mDomain2;
171 }
172 
173 
174 /*
175  * Predicate returning @c true if this AdjacentDomains's "id" attribute is set.
176  */
177 bool
isSetId() const178 AdjacentDomains::isSetId() const
179 {
180   return (mId.empty() == false);
181 }
182 
183 
184 /*
185  * Predicate returning @c true if this AdjacentDomains's "name" attribute is
186  * set.
187  */
188 bool
isSetName() const189 AdjacentDomains::isSetName() const
190 {
191   return (mName.empty() == false);
192 }
193 
194 
195 /*
196  * Predicate returning @c true if this AdjacentDomains's "domain1" attribute is
197  * set.
198  */
199 bool
isSetDomain1() const200 AdjacentDomains::isSetDomain1() const
201 {
202   return (mDomain1.empty() == false);
203 }
204 
205 
206 /*
207  * Predicate returning @c true if this AdjacentDomains's "domain2" attribute is
208  * set.
209  */
210 bool
isSetDomain2() const211 AdjacentDomains::isSetDomain2() const
212 {
213   return (mDomain2.empty() == false);
214 }
215 
216 
217 /*
218  * Sets the value of the "id" attribute of this AdjacentDomains.
219  */
220 int
setId(const std::string & id)221 AdjacentDomains::setId(const std::string& id)
222 {
223   return SyntaxChecker::checkAndSetSId(id, mId);
224 }
225 
226 
227 /*
228  * Sets the value of the "name" attribute of this AdjacentDomains.
229  */
230 int
setName(const std::string & name)231 AdjacentDomains::setName(const std::string& name)
232 {
233   mName = name;
234   return LIBSBML_OPERATION_SUCCESS;
235 }
236 
237 
238 /*
239  * Sets the value of the "domain1" attribute of this AdjacentDomains.
240  */
241 int
setDomain1(const std::string & domain1)242 AdjacentDomains::setDomain1(const std::string& domain1)
243 {
244   if (!(SyntaxChecker::isValidInternalSId(domain1)))
245   {
246     return LIBSBML_INVALID_ATTRIBUTE_VALUE;
247   }
248   else
249   {
250     mDomain1 = domain1;
251     return LIBSBML_OPERATION_SUCCESS;
252   }
253 }
254 
255 
256 /*
257  * Sets the value of the "domain2" attribute of this AdjacentDomains.
258  */
259 int
setDomain2(const std::string & domain2)260 AdjacentDomains::setDomain2(const std::string& domain2)
261 {
262   if (!(SyntaxChecker::isValidInternalSId(domain2)))
263   {
264     return LIBSBML_INVALID_ATTRIBUTE_VALUE;
265   }
266   else
267   {
268     mDomain2 = domain2;
269     return LIBSBML_OPERATION_SUCCESS;
270   }
271 }
272 
273 
274 /*
275  * Unsets the value of the "id" attribute of this AdjacentDomains.
276  */
277 int
unsetId()278 AdjacentDomains::unsetId()
279 {
280   mId.erase();
281 
282   if (mId.empty() == true)
283   {
284     return LIBSBML_OPERATION_SUCCESS;
285   }
286   else
287   {
288     return LIBSBML_OPERATION_FAILED;
289   }
290 }
291 
292 
293 /*
294  * Unsets the value of the "name" attribute of this AdjacentDomains.
295  */
296 int
unsetName()297 AdjacentDomains::unsetName()
298 {
299   mName.erase();
300 
301   if (mName.empty() == true)
302   {
303     return LIBSBML_OPERATION_SUCCESS;
304   }
305   else
306   {
307     return LIBSBML_OPERATION_FAILED;
308   }
309 }
310 
311 
312 /*
313  * Unsets the value of the "domain1" attribute of this AdjacentDomains.
314  */
315 int
unsetDomain1()316 AdjacentDomains::unsetDomain1()
317 {
318   mDomain1.erase();
319 
320   if (mDomain1.empty() == true)
321   {
322     return LIBSBML_OPERATION_SUCCESS;
323   }
324   else
325   {
326     return LIBSBML_OPERATION_FAILED;
327   }
328 }
329 
330 
331 /*
332  * Unsets the value of the "domain2" attribute of this AdjacentDomains.
333  */
334 int
unsetDomain2()335 AdjacentDomains::unsetDomain2()
336 {
337   mDomain2.erase();
338 
339   if (mDomain2.empty() == true)
340   {
341     return LIBSBML_OPERATION_SUCCESS;
342   }
343   else
344   {
345     return LIBSBML_OPERATION_FAILED;
346   }
347 }
348 
349 
350 /*
351  * @copydoc doc_renamesidref_common
352  */
353 void
renameSIdRefs(const std::string & oldid,const std::string & newid)354 AdjacentDomains::renameSIdRefs(const std::string& oldid,
355                                const std::string& newid)
356 {
357   if (isSetDomain1() && mDomain1 == oldid)
358   {
359     setDomain1(newid);
360   }
361 
362   if (isSetDomain2() && mDomain2 == oldid)
363   {
364     setDomain2(newid);
365   }
366 }
367 
368 
369 /*
370  * Returns the XML element name of this AdjacentDomains object.
371  */
372 const std::string&
getElementName() const373 AdjacentDomains::getElementName() const
374 {
375   static const string name = "adjacentDomains";
376   return name;
377 }
378 
379 
380 /*
381  * Returns the libSBML type code for this AdjacentDomains object.
382  */
383 int
getTypeCode() const384 AdjacentDomains::getTypeCode() const
385 {
386   return SBML_SPATIAL_ADJACENTDOMAINS;
387 }
388 
389 
390 /*
391  * Predicate returning @c true if all the required attributes for this
392  * AdjacentDomains object have been set.
393  */
394 bool
hasRequiredAttributes() const395 AdjacentDomains::hasRequiredAttributes() const
396 {
397   bool allPresent = true;
398 
399   if (isSetId() == false)
400   {
401     allPresent = false;
402   }
403 
404   if (isSetDomain1() == false)
405   {
406     allPresent = false;
407   }
408 
409   if (isSetDomain2() == false)
410   {
411     allPresent = false;
412   }
413 
414   return allPresent;
415 }
416 
417 
418 
419 /** @cond doxygenLibsbmlInternal */
420 
421 /*
422  * Write any contained elements
423  */
424 void
writeElements(XMLOutputStream & stream) const425 AdjacentDomains::writeElements(XMLOutputStream& stream) const
426 {
427   SBase::writeElements(stream);
428 
429   SBase::writeExtensionElements(stream);
430 }
431 
432 /** @endcond */
433 
434 
435 
436 /** @cond doxygenLibsbmlInternal */
437 
438 /*
439  * Accepts the given SBMLVisitor
440  */
441 bool
accept(SBMLVisitor & v) const442 AdjacentDomains::accept(SBMLVisitor& v) const
443 {
444   return v.visit(*this);
445 }
446 
447 /** @endcond */
448 
449 
450 
451 /** @cond doxygenLibsbmlInternal */
452 
453 /*
454  * Sets the parent SBMLDocument
455  */
456 void
setSBMLDocument(SBMLDocument * d)457 AdjacentDomains::setSBMLDocument(SBMLDocument* d)
458 {
459   SBase::setSBMLDocument(d);
460 }
461 
462 /** @endcond */
463 
464 
465 
466 /** @cond doxygenLibsbmlInternal */
467 
468 /*
469  * Enables/disables the given package with this element
470  */
471 void
enablePackageInternal(const std::string & pkgURI,const std::string & pkgPrefix,bool flag)472 AdjacentDomains::enablePackageInternal(const std::string& pkgURI,
473                                        const std::string& pkgPrefix,
474                                        bool flag)
475 {
476   SBase::enablePackageInternal(pkgURI, pkgPrefix, flag);
477 }
478 
479 /** @endcond */
480 
481 
482 
483 /** @cond doxygenLibsbmlInternal */
484 
485 /*
486  * Gets the value of the "attributeName" attribute of this AdjacentDomains.
487  */
488 int
getAttribute(const std::string & attributeName,bool & value) const489 AdjacentDomains::getAttribute(const std::string& attributeName,
490                               bool& value) const
491 {
492   int return_value = SBase::getAttribute(attributeName, value);
493 
494   return return_value;
495 }
496 
497 /** @endcond */
498 
499 
500 
501 /** @cond doxygenLibsbmlInternal */
502 
503 /*
504  * Gets the value of the "attributeName" attribute of this AdjacentDomains.
505  */
506 int
getAttribute(const std::string & attributeName,int & value) const507 AdjacentDomains::getAttribute(const std::string& attributeName,
508                               int& value) const
509 {
510   int return_value = SBase::getAttribute(attributeName, value);
511 
512   return return_value;
513 }
514 
515 /** @endcond */
516 
517 
518 
519 /** @cond doxygenLibsbmlInternal */
520 
521 /*
522  * Gets the value of the "attributeName" attribute of this AdjacentDomains.
523  */
524 int
getAttribute(const std::string & attributeName,double & value) const525 AdjacentDomains::getAttribute(const std::string& attributeName,
526                               double& value) const
527 {
528   int return_value = SBase::getAttribute(attributeName, value);
529 
530   return return_value;
531 }
532 
533 /** @endcond */
534 
535 
536 
537 /** @cond doxygenLibsbmlInternal */
538 
539 /*
540  * Gets the value of the "attributeName" attribute of this AdjacentDomains.
541  */
542 int
getAttribute(const std::string & attributeName,unsigned int & value) const543 AdjacentDomains::getAttribute(const std::string& attributeName,
544                               unsigned int& value) const
545 {
546   int return_value = SBase::getAttribute(attributeName, value);
547 
548   return return_value;
549 }
550 
551 /** @endcond */
552 
553 
554 
555 /** @cond doxygenLibsbmlInternal */
556 
557 /*
558  * Gets the value of the "attributeName" attribute of this AdjacentDomains.
559  */
560 int
getAttribute(const std::string & attributeName,std::string & value) const561 AdjacentDomains::getAttribute(const std::string& attributeName,
562                               std::string& value) const
563 {
564   int return_value = SBase::getAttribute(attributeName, value);
565 
566   if (return_value == LIBSBML_OPERATION_SUCCESS)
567   {
568     return return_value;
569   }
570 
571   if (attributeName == "id")
572   {
573     value = getId();
574     return_value = LIBSBML_OPERATION_SUCCESS;
575   }
576   else if (attributeName == "name")
577   {
578     value = getName();
579     return_value = LIBSBML_OPERATION_SUCCESS;
580   }
581   else if (attributeName == "domain1")
582   {
583     value = getDomain1();
584     return_value = LIBSBML_OPERATION_SUCCESS;
585   }
586   else if (attributeName == "domain2")
587   {
588     value = getDomain2();
589     return_value = LIBSBML_OPERATION_SUCCESS;
590   }
591 
592   return return_value;
593 }
594 
595 /** @endcond */
596 
597 
598 
599 /** @cond doxygenLibsbmlInternal */
600 
601 /*
602  * Predicate returning @c true if this AdjacentDomains's attribute
603  * "attributeName" is set.
604  */
605 bool
isSetAttribute(const std::string & attributeName) const606 AdjacentDomains::isSetAttribute(const std::string& attributeName) const
607 {
608   bool value = SBase::isSetAttribute(attributeName);
609 
610   if (attributeName == "id")
611   {
612     value = isSetId();
613   }
614   else if (attributeName == "name")
615   {
616     value = isSetName();
617   }
618   else if (attributeName == "domain1")
619   {
620     value = isSetDomain1();
621   }
622   else if (attributeName == "domain2")
623   {
624     value = isSetDomain2();
625   }
626 
627   return value;
628 }
629 
630 /** @endcond */
631 
632 
633 
634 /** @cond doxygenLibsbmlInternal */
635 
636 /*
637  * Sets the value of the "attributeName" attribute of this AdjacentDomains.
638  */
639 int
setAttribute(const std::string & attributeName,bool value)640 AdjacentDomains::setAttribute(const std::string& attributeName, bool value)
641 {
642   int return_value = SBase::setAttribute(attributeName, value);
643 
644   return return_value;
645 }
646 
647 /** @endcond */
648 
649 
650 
651 /** @cond doxygenLibsbmlInternal */
652 
653 /*
654  * Sets the value of the "attributeName" attribute of this AdjacentDomains.
655  */
656 int
setAttribute(const std::string & attributeName,int value)657 AdjacentDomains::setAttribute(const std::string& attributeName, int value)
658 {
659   int return_value = SBase::setAttribute(attributeName, value);
660 
661   return return_value;
662 }
663 
664 /** @endcond */
665 
666 
667 
668 /** @cond doxygenLibsbmlInternal */
669 
670 /*
671  * Sets the value of the "attributeName" attribute of this AdjacentDomains.
672  */
673 int
setAttribute(const std::string & attributeName,double value)674 AdjacentDomains::setAttribute(const std::string& attributeName, double value)
675 {
676   int return_value = SBase::setAttribute(attributeName, value);
677 
678   return return_value;
679 }
680 
681 /** @endcond */
682 
683 
684 
685 /** @cond doxygenLibsbmlInternal */
686 
687 /*
688  * Sets the value of the "attributeName" attribute of this AdjacentDomains.
689  */
690 int
setAttribute(const std::string & attributeName,unsigned int value)691 AdjacentDomains::setAttribute(const std::string& attributeName,
692                               unsigned int value)
693 {
694   int return_value = SBase::setAttribute(attributeName, value);
695 
696   return return_value;
697 }
698 
699 /** @endcond */
700 
701 
702 
703 /** @cond doxygenLibsbmlInternal */
704 
705 /*
706  * Sets the value of the "attributeName" attribute of this AdjacentDomains.
707  */
708 int
setAttribute(const std::string & attributeName,const std::string & value)709 AdjacentDomains::setAttribute(const std::string& attributeName,
710                               const std::string& value)
711 {
712   int return_value = SBase::setAttribute(attributeName, value);
713 
714   if (attributeName == "id")
715   {
716     return_value = setId(value);
717   }
718   else if (attributeName == "name")
719   {
720     return_value = setName(value);
721   }
722   else if (attributeName == "domain1")
723   {
724     return_value = setDomain1(value);
725   }
726   else if (attributeName == "domain2")
727   {
728     return_value = setDomain2(value);
729   }
730 
731   return return_value;
732 }
733 
734 /** @endcond */
735 
736 
737 
738 /** @cond doxygenLibsbmlInternal */
739 
740 /*
741  * Unsets the value of the "attributeName" attribute of this AdjacentDomains.
742  */
743 int
unsetAttribute(const std::string & attributeName)744 AdjacentDomains::unsetAttribute(const std::string& attributeName)
745 {
746   int value = SBase::unsetAttribute(attributeName);
747 
748   if (attributeName == "id")
749   {
750     value = unsetId();
751   }
752   else if (attributeName == "name")
753   {
754     value = unsetName();
755   }
756   else if (attributeName == "domain1")
757   {
758     value = unsetDomain1();
759   }
760   else if (attributeName == "domain2")
761   {
762     value = unsetDomain2();
763   }
764 
765   return value;
766 }
767 
768 /** @endcond */
769 
770 
771 
772 /** @cond doxygenLibsbmlInternal */
773 
774 /*
775  * Adds the expected attributes for this element
776  */
777 void
addExpectedAttributes(ExpectedAttributes & attributes)778 AdjacentDomains::addExpectedAttributes(ExpectedAttributes& attributes)
779 {
780   SBase::addExpectedAttributes(attributes);
781 
782   attributes.add("id");
783 
784   attributes.add("name");
785 
786   attributes.add("domain1");
787 
788   attributes.add("domain2");
789 }
790 
791 /** @endcond */
792 
793 
794 
795 /** @cond doxygenLibsbmlInternal */
796 
797 /*
798  * Reads the expected attributes into the member data variables
799  */
800 void
readAttributes(const XMLAttributes & attributes,const ExpectedAttributes & expectedAttributes)801 AdjacentDomains::readAttributes(const XMLAttributes& attributes,
802                                 const ExpectedAttributes& expectedAttributes)
803 {
804   unsigned int level = getLevel();
805   unsigned int version = getVersion();
806   unsigned int pkgVersion = getPackageVersion();
807   unsigned int numErrs;
808   bool assigned = false;
809   SBMLErrorLog* log = getErrorLog();
810 
811   if (log && getParentSBMLObject() &&
812     static_cast<ListOfAdjacentDomains*>(getParentSBMLObject())->size() < 2)
813   {
814     numErrs = log->getNumErrors();
815     for (int n = numErrs-1; n >= 0; n--)
816     {
817       if (log->getError(n)->getErrorId() == UnknownPackageAttribute)
818       {
819         const std::string details = log->getError(n)->getMessage();
820         log->remove(UnknownPackageAttribute);
821         log->logPackageError("spatial",
822           SpatialAdjacentDomainsAllowedAttributes, pkgVersion, level, version,
823             details, getLine(), getColumn());
824       }
825       else if (log->getError(n)->getErrorId() == UnknownCoreAttribute)
826       {
827         const std::string details = log->getError(n)->getMessage();
828         log->remove(UnknownCoreAttribute);
829         log->logPackageError("spatial",
830           SpatialGeometryLOAdjacentDomainsAllowedCoreAttributes, pkgVersion,
831             level, version, details, getLine(), getColumn());
832       }
833     }
834   }
835 
836   SBase::readAttributes(attributes, expectedAttributes);
837 
838   if (log)
839   {
840     numErrs = log->getNumErrors();
841 
842     for (int n = numErrs-1; n >= 0; n--)
843     {
844       if (log->getError(n)->getErrorId() == UnknownPackageAttribute)
845       {
846         const std::string details = log->getError(n)->getMessage();
847         log->remove(UnknownPackageAttribute);
848         log->logPackageError("spatial",
849           SpatialAdjacentDomainsAllowedAttributes, pkgVersion, level, version,
850             details, getLine(), getColumn());
851       }
852       else if (log->getError(n)->getErrorId() == UnknownCoreAttribute)
853       {
854         const std::string details = log->getError(n)->getMessage();
855         log->remove(UnknownCoreAttribute);
856         log->logPackageError("spatial",
857           SpatialAdjacentDomainsAllowedCoreAttributes, pkgVersion, level,
858             version, details, getLine(), getColumn());
859       }
860     }
861   }
862 
863   //
864   // id SId (use = "required" )
865   //
866 
867   assigned = attributes.readInto("id", mId);
868 
869   if (assigned == true)
870   {
871     if (mId.empty() == true)
872     {
873       logEmptyString(mId, level, version, "<AdjacentDomains>");
874     }
875     else if (SyntaxChecker::isValidSBMLSId(mId) == false)
876     {
877       log->logPackageError("spatial", SpatialIdSyntaxRule, pkgVersion, level,
878         version, "The id on the <" + getElementName() + "> is '" + mId + "', "
879           "which does not conform to the syntax.", getLine(), getColumn());
880     }
881   }
882   else
883   {
884     std::string message = "Spatial attribute 'id' is missing from the "
885       "<AdjacentDomains> element.";
886     log->logPackageError("spatial", SpatialAdjacentDomainsAllowedAttributes,
887       pkgVersion, level, version, message, getLine(), getColumn());
888   }
889 
890   //
891   // name string (use = "optional" )
892   //
893 
894   assigned = attributes.readInto("name", mName);
895 
896   if (assigned == true)
897   {
898     if (mName.empty() == true)
899     {
900       logEmptyString(mName, level, version, "<AdjacentDomains>");
901     }
902   }
903 
904   //
905   // domain1 SIdRef (use = "required" )
906   //
907 
908   assigned = attributes.readInto("domain1", mDomain1);
909 
910   if (assigned == true)
911   {
912     if (mDomain1.empty() == true)
913     {
914       logEmptyString(mDomain1, level, version, "<AdjacentDomains>");
915     }
916     else if (SyntaxChecker::isValidSBMLSId(mDomain1) == false)
917     {
918       std::string msg = "The domain1 attribute on the <" + getElementName() +
919         ">";
920       if (isSetId())
921       {
922         msg += " with id '" + getId() + "'";
923       }
924 
925       msg += " is '" + mDomain1 + "', which does not conform to the syntax.";
926       log->logPackageError("spatial",
927         SpatialAdjacentDomainsDomain1MustBeDomain, pkgVersion, level, version,
928           msg, getLine(), getColumn());
929     }
930   }
931   else
932   {
933     std::string message = "Spatial attribute 'domain1' is missing from the "
934       "<AdjacentDomains> element.";
935     log->logPackageError("spatial", SpatialAdjacentDomainsAllowedAttributes,
936       pkgVersion, level, version, message, getLine(), getColumn());
937   }
938 
939   //
940   // domain2 SIdRef (use = "required" )
941   //
942 
943   assigned = attributes.readInto("domain2", mDomain2);
944 
945   if (assigned == true)
946   {
947     if (mDomain2.empty() == true)
948     {
949       logEmptyString(mDomain2, level, version, "<AdjacentDomains>");
950     }
951     else if (SyntaxChecker::isValidSBMLSId(mDomain2) == false)
952     {
953       std::string msg = "The domain2 attribute on the <" + getElementName() +
954         ">";
955       if (isSetId())
956       {
957         msg += " with id '" + getId() + "'";
958       }
959 
960       msg += " is '" + mDomain2 + "', which does not conform to the syntax.";
961       log->logPackageError("spatial",
962         SpatialAdjacentDomainsDomain2MustBeDomain, pkgVersion, level, version,
963           msg, getLine(), getColumn());
964     }
965   }
966   else
967   {
968     std::string message = "Spatial attribute 'domain2' is missing from the "
969       "<AdjacentDomains> element.";
970     log->logPackageError("spatial", SpatialAdjacentDomainsAllowedAttributes,
971       pkgVersion, level, version, message, getLine(), getColumn());
972   }
973 }
974 
975 /** @endcond */
976 
977 
978 
979 /** @cond doxygenLibsbmlInternal */
980 
981 /*
982  * Writes the attributes to the stream
983  */
984 void
writeAttributes(XMLOutputStream & stream) const985 AdjacentDomains::writeAttributes(XMLOutputStream& stream) const
986 {
987   SBase::writeAttributes(stream);
988 
989   if (isSetId() == true)
990   {
991     stream.writeAttribute("id", getPrefix(), mId);
992   }
993 
994   if (isSetName() == true)
995   {
996     stream.writeAttribute("name", getPrefix(), mName);
997   }
998 
999   if (isSetDomain1() == true)
1000   {
1001     stream.writeAttribute("domain1", getPrefix(), mDomain1);
1002   }
1003 
1004   if (isSetDomain2() == true)
1005   {
1006     stream.writeAttribute("domain2", getPrefix(), mDomain2);
1007   }
1008 
1009   SBase::writeExtensionAttributes(stream);
1010 }
1011 
1012 /** @endcond */
1013 
1014 
1015 
1016 
1017 #endif /* __cplusplus */
1018 
1019 
1020 /*
1021  * Creates a new AdjacentDomains_t using the given SBML Level, Version and
1022  * &ldquo;spatial&rdquo; package version.
1023  */
1024 LIBSBML_EXTERN
1025 AdjacentDomains_t *
AdjacentDomains_create(unsigned int level,unsigned int version,unsigned int pkgVersion)1026 AdjacentDomains_create(unsigned int level,
1027                        unsigned int version,
1028                        unsigned int pkgVersion)
1029 {
1030   return new AdjacentDomains(level, version, pkgVersion);
1031 }
1032 
1033 
1034 /*
1035  * Creates and returns a deep copy of this AdjacentDomains_t object.
1036  */
1037 LIBSBML_EXTERN
1038 AdjacentDomains_t*
AdjacentDomains_clone(const AdjacentDomains_t * ad)1039 AdjacentDomains_clone(const AdjacentDomains_t* ad)
1040 {
1041   if (ad != NULL)
1042   {
1043     return static_cast<AdjacentDomains_t*>(ad->clone());
1044   }
1045   else
1046   {
1047     return NULL;
1048   }
1049 }
1050 
1051 
1052 /*
1053  * Frees this AdjacentDomains_t object.
1054  */
1055 LIBSBML_EXTERN
1056 void
AdjacentDomains_free(AdjacentDomains_t * ad)1057 AdjacentDomains_free(AdjacentDomains_t* ad)
1058 {
1059   if (ad != NULL)
1060   {
1061     delete ad;
1062   }
1063 }
1064 
1065 
1066 /*
1067  * Returns the value of the "id" attribute of this AdjacentDomains_t.
1068  */
1069 LIBSBML_EXTERN
1070 char *
AdjacentDomains_getId(const AdjacentDomains_t * ad)1071 AdjacentDomains_getId(const AdjacentDomains_t * ad)
1072 {
1073   if (ad == NULL)
1074   {
1075     return NULL;
1076   }
1077 
1078   return ad->getId().empty() ? NULL : safe_strdup(ad->getId().c_str());
1079 }
1080 
1081 
1082 /*
1083  * Returns the value of the "name" attribute of this AdjacentDomains_t.
1084  */
1085 LIBSBML_EXTERN
1086 char *
AdjacentDomains_getName(const AdjacentDomains_t * ad)1087 AdjacentDomains_getName(const AdjacentDomains_t * ad)
1088 {
1089   if (ad == NULL)
1090   {
1091     return NULL;
1092   }
1093 
1094   return ad->getName().empty() ? NULL : safe_strdup(ad->getName().c_str());
1095 }
1096 
1097 
1098 /*
1099  * Returns the value of the "domain1" attribute of this AdjacentDomains_t.
1100  */
1101 LIBSBML_EXTERN
1102 char *
AdjacentDomains_getDomain1(const AdjacentDomains_t * ad)1103 AdjacentDomains_getDomain1(const AdjacentDomains_t * ad)
1104 {
1105   if (ad == NULL)
1106   {
1107     return NULL;
1108   }
1109 
1110   return ad->getDomain1().empty() ? NULL :
1111     safe_strdup(ad->getDomain1().c_str());
1112 }
1113 
1114 
1115 /*
1116  * Returns the value of the "domain2" attribute of this AdjacentDomains_t.
1117  */
1118 LIBSBML_EXTERN
1119 char *
AdjacentDomains_getDomain2(const AdjacentDomains_t * ad)1120 AdjacentDomains_getDomain2(const AdjacentDomains_t * ad)
1121 {
1122   if (ad == NULL)
1123   {
1124     return NULL;
1125   }
1126 
1127   return ad->getDomain2().empty() ? NULL :
1128     safe_strdup(ad->getDomain2().c_str());
1129 }
1130 
1131 
1132 /*
1133  * Predicate returning @c 1 (true) if this AdjacentDomains_t's "id" attribute
1134  * is set.
1135  */
1136 LIBSBML_EXTERN
1137 int
AdjacentDomains_isSetId(const AdjacentDomains_t * ad)1138 AdjacentDomains_isSetId(const AdjacentDomains_t * ad)
1139 {
1140   return (ad != NULL) ? static_cast<int>(ad->isSetId()) : 0;
1141 }
1142 
1143 
1144 /*
1145  * Predicate returning @c 1 (true) if this AdjacentDomains_t's "name" attribute
1146  * is set.
1147  */
1148 LIBSBML_EXTERN
1149 int
AdjacentDomains_isSetName(const AdjacentDomains_t * ad)1150 AdjacentDomains_isSetName(const AdjacentDomains_t * ad)
1151 {
1152   return (ad != NULL) ? static_cast<int>(ad->isSetName()) : 0;
1153 }
1154 
1155 
1156 /*
1157  * Predicate returning @c 1 (true) if this AdjacentDomains_t's "domain1"
1158  * attribute is set.
1159  */
1160 LIBSBML_EXTERN
1161 int
AdjacentDomains_isSetDomain1(const AdjacentDomains_t * ad)1162 AdjacentDomains_isSetDomain1(const AdjacentDomains_t * ad)
1163 {
1164   return (ad != NULL) ? static_cast<int>(ad->isSetDomain1()) : 0;
1165 }
1166 
1167 
1168 /*
1169  * Predicate returning @c 1 (true) if this AdjacentDomains_t's "domain2"
1170  * attribute is set.
1171  */
1172 LIBSBML_EXTERN
1173 int
AdjacentDomains_isSetDomain2(const AdjacentDomains_t * ad)1174 AdjacentDomains_isSetDomain2(const AdjacentDomains_t * ad)
1175 {
1176   return (ad != NULL) ? static_cast<int>(ad->isSetDomain2()) : 0;
1177 }
1178 
1179 
1180 /*
1181  * Sets the value of the "id" attribute of this AdjacentDomains_t.
1182  */
1183 LIBSBML_EXTERN
1184 int
AdjacentDomains_setId(AdjacentDomains_t * ad,const char * id)1185 AdjacentDomains_setId(AdjacentDomains_t * ad, const char * id)
1186 {
1187   return (ad != NULL) ? ad->setId(id) : LIBSBML_INVALID_OBJECT;
1188 }
1189 
1190 
1191 /*
1192  * Sets the value of the "name" attribute of this AdjacentDomains_t.
1193  */
1194 LIBSBML_EXTERN
1195 int
AdjacentDomains_setName(AdjacentDomains_t * ad,const char * name)1196 AdjacentDomains_setName(AdjacentDomains_t * ad, const char * name)
1197 {
1198   return (ad != NULL) ? ad->setName(name) : LIBSBML_INVALID_OBJECT;
1199 }
1200 
1201 
1202 /*
1203  * Sets the value of the "domain1" attribute of this AdjacentDomains_t.
1204  */
1205 LIBSBML_EXTERN
1206 int
AdjacentDomains_setDomain1(AdjacentDomains_t * ad,const char * domain1)1207 AdjacentDomains_setDomain1(AdjacentDomains_t * ad, const char * domain1)
1208 {
1209   return (ad != NULL) ? ad->setDomain1(domain1) : LIBSBML_INVALID_OBJECT;
1210 }
1211 
1212 
1213 /*
1214  * Sets the value of the "domain2" attribute of this AdjacentDomains_t.
1215  */
1216 LIBSBML_EXTERN
1217 int
AdjacentDomains_setDomain2(AdjacentDomains_t * ad,const char * domain2)1218 AdjacentDomains_setDomain2(AdjacentDomains_t * ad, const char * domain2)
1219 {
1220   return (ad != NULL) ? ad->setDomain2(domain2) : LIBSBML_INVALID_OBJECT;
1221 }
1222 
1223 
1224 /*
1225  * Unsets the value of the "id" attribute of this AdjacentDomains_t.
1226  */
1227 LIBSBML_EXTERN
1228 int
AdjacentDomains_unsetId(AdjacentDomains_t * ad)1229 AdjacentDomains_unsetId(AdjacentDomains_t * ad)
1230 {
1231   return (ad != NULL) ? ad->unsetId() : LIBSBML_INVALID_OBJECT;
1232 }
1233 
1234 
1235 /*
1236  * Unsets the value of the "name" attribute of this AdjacentDomains_t.
1237  */
1238 LIBSBML_EXTERN
1239 int
AdjacentDomains_unsetName(AdjacentDomains_t * ad)1240 AdjacentDomains_unsetName(AdjacentDomains_t * ad)
1241 {
1242   return (ad != NULL) ? ad->unsetName() : LIBSBML_INVALID_OBJECT;
1243 }
1244 
1245 
1246 /*
1247  * Unsets the value of the "domain1" attribute of this AdjacentDomains_t.
1248  */
1249 LIBSBML_EXTERN
1250 int
AdjacentDomains_unsetDomain1(AdjacentDomains_t * ad)1251 AdjacentDomains_unsetDomain1(AdjacentDomains_t * ad)
1252 {
1253   return (ad != NULL) ? ad->unsetDomain1() : LIBSBML_INVALID_OBJECT;
1254 }
1255 
1256 
1257 /*
1258  * Unsets the value of the "domain2" attribute of this AdjacentDomains_t.
1259  */
1260 LIBSBML_EXTERN
1261 int
AdjacentDomains_unsetDomain2(AdjacentDomains_t * ad)1262 AdjacentDomains_unsetDomain2(AdjacentDomains_t * ad)
1263 {
1264   return (ad != NULL) ? ad->unsetDomain2() : LIBSBML_INVALID_OBJECT;
1265 }
1266 
1267 
1268 /*
1269  * Predicate returning @c 1 (true) if all the required attributes for this
1270  * AdjacentDomains_t object have been set.
1271  */
1272 LIBSBML_EXTERN
1273 int
AdjacentDomains_hasRequiredAttributes(const AdjacentDomains_t * ad)1274 AdjacentDomains_hasRequiredAttributes(const AdjacentDomains_t * ad)
1275 {
1276   return (ad != NULL) ? static_cast<int>(ad->hasRequiredAttributes()) : 0;
1277 }
1278 
1279 
1280 
1281 
1282 LIBSBML_CPP_NAMESPACE_END
1283 
1284 
1285