1 /**
2 * @file: SpeciesTypeComponentMapInProduct.cpp
3 * @brief: Implementation of the SpeciesTypeComponentMapInProduct 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) 2009-2013 jointly by the following organizations:
16 * 1. California Institute of Technology, Pasadena, CA, USA
17 * 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
18 *
19 * Copyright (C) 2006-2008 by the California Institute of Technology,
20 * Pasadena, CA, USA
21 *
22 * Copyright (C) 2002-2005 jointly by the following organizations:
23 * 1. California Institute of Technology, Pasadena, CA, USA
24 * 2. Japan Science and Technology Agency, Japan
25 *
26 * This library is free software; you can redistribute it and/or modify it
27 * under the terms of the GNU Lesser General Public License as published by
28 * the Free Software Foundation. A copy of the license agreement is provided
29 * in the file named "LICENSE.txt" included with this software distribution
30 * and also available online as http://sbml.org/software/libsbml/license.html
31 * ------------------------------------------------------------------------ -->
32 */
33
34
35 #include <sbml/packages/multi/sbml/SpeciesTypeComponentMapInProduct.h>
36 #include <sbml/packages/multi/validator/MultiSBMLError.h>
37
38 #include <sbml/util/ElementFilter.h>
39
40
41 using namespace std;
42
43
44 #ifdef __cplusplus
45
46 LIBSBML_CPP_NAMESPACE_BEGIN
47
48
49 /*
50 * Creates a new SpeciesTypeComponentMapInProduct with the given level, version, and package version.
51 */
SpeciesTypeComponentMapInProduct(unsigned int level,unsigned int version,unsigned int pkgVersion)52 SpeciesTypeComponentMapInProduct::SpeciesTypeComponentMapInProduct (unsigned int level, unsigned int version, unsigned int pkgVersion)
53 : SBase(level, version)
54 ,mReactant ("")
55 ,mReactantComponent ("")
56 ,mProductComponent ("")
57 {
58 // set an SBMLNamespaces derived object of this package
59 setSBMLNamespacesAndOwn(new MultiPkgNamespaces(level, version, pkgVersion));
60 }
61
62
63 /*
64 * Creates a new SpeciesTypeComponentMapInProduct with the given MultiPkgNamespaces object.
65 */
SpeciesTypeComponentMapInProduct(MultiPkgNamespaces * multins)66 SpeciesTypeComponentMapInProduct::SpeciesTypeComponentMapInProduct (MultiPkgNamespaces* multins)
67 : SBase(multins)
68 ,mReactant ("")
69 ,mReactantComponent ("")
70 ,mProductComponent ("")
71 {
72 // set the element namespace of this object
73 setElementNamespace(multins->getURI());
74
75 // load package extensions bound with this object (if any)
76 loadPlugins(multins);
77 }
78
79
80 /*
81 * Copy constructor for SpeciesTypeComponentMapInProduct.
82 */
SpeciesTypeComponentMapInProduct(const SpeciesTypeComponentMapInProduct & orig)83 SpeciesTypeComponentMapInProduct::SpeciesTypeComponentMapInProduct (const SpeciesTypeComponentMapInProduct& orig)
84 : SBase(orig)
85 , mReactant ( orig.mReactant)
86 , mReactantComponent ( orig.mReactantComponent)
87 , mProductComponent ( orig.mProductComponent)
88 {
89 }
90
91
92 /*
93 * Assignment for SpeciesTypeComponentMapInProduct.
94 */
95 SpeciesTypeComponentMapInProduct&
operator =(const SpeciesTypeComponentMapInProduct & rhs)96 SpeciesTypeComponentMapInProduct::operator=(const SpeciesTypeComponentMapInProduct& rhs)
97 {
98 if (&rhs != this)
99 {
100 SBase::operator=(rhs);
101 mReactant = rhs.mReactant;
102 mReactantComponent = rhs.mReactantComponent;
103 mProductComponent = rhs.mProductComponent;
104 }
105 return *this;
106 }
107
108
109 /*
110 * Clone for SpeciesTypeComponentMapInProduct.
111 */
112 SpeciesTypeComponentMapInProduct*
clone() const113 SpeciesTypeComponentMapInProduct::clone () const
114 {
115 return new SpeciesTypeComponentMapInProduct(*this);
116 }
117
118
119 /*
120 * Destructor for SpeciesTypeComponentMapInProduct.
121 */
~SpeciesTypeComponentMapInProduct()122 SpeciesTypeComponentMapInProduct::~SpeciesTypeComponentMapInProduct ()
123 {
124 }
125
126
127 /*
128 * Returns the value of the "id" attribute of this SpeciesTypeComponentMapInProduct.
129 */
130 const std::string&
getId() const131 SpeciesTypeComponentMapInProduct::getId() const
132 {
133 return mId;
134 }
135
136
137 /*
138 * Returns the value of the "name" attribute of this SpeciesTypeComponentMapInProduct.
139 */
140 const std::string&
getName() const141 SpeciesTypeComponentMapInProduct::getName() const
142 {
143 return mName;
144 }
145
146
147 /*
148 * Returns the value of the "reactant" attribute of this SpeciesTypeComponentMapInProduct.
149 */
150 const std::string&
getReactant() const151 SpeciesTypeComponentMapInProduct::getReactant() const
152 {
153 return mReactant;
154 }
155
156
157 /*
158 * Returns the value of the "reactantComponent" attribute of this SpeciesTypeComponentMapInProduct.
159 */
160 const std::string&
getReactantComponent() const161 SpeciesTypeComponentMapInProduct::getReactantComponent() const
162 {
163 return mReactantComponent;
164 }
165
166
167 /*
168 * Returns the value of the "productComponent" attribute of this SpeciesTypeComponentMapInProduct.
169 */
170 const std::string&
getProductComponent() const171 SpeciesTypeComponentMapInProduct::getProductComponent() const
172 {
173 return mProductComponent;
174 }
175
176
177 /*
178 * Returns true/false if id is set.
179 */
180 bool
isSetId() const181 SpeciesTypeComponentMapInProduct::isSetId() const
182 {
183 return (mId.empty() == false);
184 }
185
186
187 /*
188 * Returns true/false if name is set.
189 */
190 bool
isSetName() const191 SpeciesTypeComponentMapInProduct::isSetName() const
192 {
193 return (mName.empty() == false);
194 }
195
196
197 /*
198 * Returns true/false if reactant is set.
199 */
200 bool
isSetReactant() const201 SpeciesTypeComponentMapInProduct::isSetReactant() const
202 {
203 return (mReactant.empty() == false);
204 }
205
206
207 /*
208 * Returns true/false if reactantComponent is set.
209 */
210 bool
isSetReactantComponent() const211 SpeciesTypeComponentMapInProduct::isSetReactantComponent() const
212 {
213 return (mReactantComponent.empty() == false);
214 }
215
216
217 /*
218 * Returns true/false if productComponent is set.
219 */
220 bool
isSetProductComponent() const221 SpeciesTypeComponentMapInProduct::isSetProductComponent() const
222 {
223 return (mProductComponent.empty() == false);
224 }
225
226
227 /*
228 * Sets id and returns value indicating success.
229 */
230 int
setId(const std::string & id)231 SpeciesTypeComponentMapInProduct::setId(const std::string& id)
232 {
233 return SyntaxChecker::checkAndSetSId(id, mId);
234 }
235
236
237 /*
238 * Sets name and returns value indicating success.
239 */
240 int
setName(const std::string & name)241 SpeciesTypeComponentMapInProduct::setName(const std::string& name)
242 {
243 mName = name;
244 return LIBSBML_OPERATION_SUCCESS;
245 }
246
247
248 /*
249 * Sets reactant and returns value indicating success.
250 */
251 int
setReactant(const std::string & reactant)252 SpeciesTypeComponentMapInProduct::setReactant(const std::string& reactant)
253 {
254 if (!(SyntaxChecker::isValidInternalSId(reactant)))
255 {
256 return LIBSBML_INVALID_ATTRIBUTE_VALUE;
257 }
258 else
259 {
260 mReactant = reactant;
261 return LIBSBML_OPERATION_SUCCESS;
262 }
263 }
264
265
266 /*
267 * Sets reactantComponent and returns value indicating success.
268 */
269 int
setReactantComponent(const std::string & reactantComponent)270 SpeciesTypeComponentMapInProduct::setReactantComponent(const std::string& reactantComponent)
271 {
272 if (!(SyntaxChecker::isValidInternalSId(reactantComponent)))
273 {
274 return LIBSBML_INVALID_ATTRIBUTE_VALUE;
275 }
276 else
277 {
278 mReactantComponent = reactantComponent;
279 return LIBSBML_OPERATION_SUCCESS;
280 }
281 }
282
283
284 /*
285 * Sets productComponent and returns value indicating success.
286 */
287 int
setProductComponent(const std::string & productComponent)288 SpeciesTypeComponentMapInProduct::setProductComponent(const std::string& productComponent)
289 {
290 if (!(SyntaxChecker::isValidInternalSId(productComponent)))
291 {
292 return LIBSBML_INVALID_ATTRIBUTE_VALUE;
293 }
294 else
295 {
296 mProductComponent = productComponent;
297 return LIBSBML_OPERATION_SUCCESS;
298 }
299 }
300
301
302 /*
303 * Unsets id and returns value indicating success.
304 */
305 int
unsetId()306 SpeciesTypeComponentMapInProduct::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 name and returns value indicating success.
323 */
324 int
unsetName()325 SpeciesTypeComponentMapInProduct::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 reactant and returns value indicating success.
342 */
343 int
unsetReactant()344 SpeciesTypeComponentMapInProduct::unsetReactant()
345 {
346 mReactant.erase();
347
348 if (mReactant.empty() == true)
349 {
350 return LIBSBML_OPERATION_SUCCESS;
351 }
352 else
353 {
354 return LIBSBML_OPERATION_FAILED;
355 }
356 }
357
358
359 /*
360 * Unsets reactantComponent and returns value indicating success.
361 */
362 int
unsetReactantComponent()363 SpeciesTypeComponentMapInProduct::unsetReactantComponent()
364 {
365 mReactantComponent.erase();
366
367 if (mReactantComponent.empty() == true)
368 {
369 return LIBSBML_OPERATION_SUCCESS;
370 }
371 else
372 {
373 return LIBSBML_OPERATION_FAILED;
374 }
375 }
376
377
378 /*
379 * Unsets productComponent and returns value indicating success.
380 */
381 int
unsetProductComponent()382 SpeciesTypeComponentMapInProduct::unsetProductComponent()
383 {
384 mProductComponent.erase();
385
386 if (mProductComponent.empty() == true)
387 {
388 return LIBSBML_OPERATION_SUCCESS;
389 }
390 else
391 {
392 return LIBSBML_OPERATION_FAILED;
393 }
394 }
395
396
397 /*
398 * rename attributes that are SIdRefs or instances in math
399 */
400 void
renameSIdRefs(const std::string & oldid,const std::string & newid)401 SpeciesTypeComponentMapInProduct::renameSIdRefs(const std::string& oldid, const std::string& newid)
402 {
403 SBase::renameSIdRefs(oldid, newid);
404 if (isSetReactant() == true && mReactant == oldid)
405 {
406 setReactant(newid);
407 }
408
409 if (isSetReactantComponent() == true && mReactantComponent == oldid)
410 {
411 setReactantComponent(newid);
412 }
413
414 if (isSetProductComponent() == true && mProductComponent == oldid)
415 {
416 setProductComponent(newid);
417 }
418
419 }
420
421
422
423 /*
424 * Returns the XML element name of this object
425 */
426 const std::string&
getElementName() const427 SpeciesTypeComponentMapInProduct::getElementName () const
428 {
429 static const string name = "speciesTypeComponentMapInProduct";
430 return name;
431 }
432
433
434 /*
435 * Returns the libSBML type code for this SBML object.
436 */
437 int
getTypeCode() const438 SpeciesTypeComponentMapInProduct::getTypeCode () const
439 {
440 return SBML_MULTI_SPECIES_TYPE_COMPONENT_MAP_IN_PRODUCT;
441 }
442
443
444 /*
445 * check if all the required attributes are set
446 */
447 bool
hasRequiredAttributes() const448 SpeciesTypeComponentMapInProduct::hasRequiredAttributes () const
449 {
450 bool allPresent = true;
451
452 if (isSetReactant() == false)
453 allPresent = false;
454
455 if (isSetReactantComponent() == false)
456 allPresent = false;
457
458 if (isSetProductComponent() == false)
459 allPresent = false;
460
461 return allPresent;
462 }
463
464
465
466 /** @cond doxygenLibsbmlInternal */
467
468 /*
469 * write contained elements
470 */
471 void
writeElements(XMLOutputStream & stream) const472 SpeciesTypeComponentMapInProduct::writeElements (XMLOutputStream& stream) const
473 {
474 SBase::writeElements(stream);
475
476 SBase::writeExtensionElements(stream);
477 }
478
479
480 /** @endcond */
481
482
483 /** @cond doxygenLibsbmlInternal */
484
485 /*
486 * Accepts the given SBMLVisitor.
487 */
488 bool
accept(SBMLVisitor & v) const489 SpeciesTypeComponentMapInProduct::accept (SBMLVisitor& v) const
490 {
491 return v.visit(*this);
492 }
493
494
495 /** @endcond */
496
497
498 /** @cond doxygenLibsbmlInternal */
499
500 /*
501 * Sets the parent SBMLDocument.
502 */
503 void
setSBMLDocument(SBMLDocument * d)504 SpeciesTypeComponentMapInProduct::setSBMLDocument (SBMLDocument* d)
505 {
506 SBase::setSBMLDocument(d);
507 }
508
509
510 /** @endcond */
511
512
513 /** @cond doxygenLibsbmlInternal */
514
515 /*
516 * Enables/Disables the given package with this element.
517 */
518 void
enablePackageInternal(const std::string & pkgURI,const std::string & pkgPrefix,bool flag)519 SpeciesTypeComponentMapInProduct::enablePackageInternal(const std::string& pkgURI,
520 const std::string& pkgPrefix, bool flag)
521 {
522 SBase::enablePackageInternal(pkgURI, pkgPrefix, flag);
523 }
524
525
526 /** @endcond */
527
528
529 /** @cond doxygenLibsbmlInternal */
530
531 /*
532 * Get the list of expected attributes for this element.
533 */
534 void
addExpectedAttributes(ExpectedAttributes & attributes)535 SpeciesTypeComponentMapInProduct::addExpectedAttributes(ExpectedAttributes& attributes)
536 {
537 SBase::addExpectedAttributes(attributes);
538
539 attributes.add("reactant");
540 attributes.add("reactantComponent");
541 attributes.add("productComponent");
542 }
543
544
545 /** @endcond */
546
547
548 /** @cond doxygenLibsbmlInternal */
549
550 /*
551 * Read values from the given XMLAttributes set into their specific fields.
552 */
553 void
readAttributes(const XMLAttributes & attributes,const ExpectedAttributes & expectedAttributes)554 SpeciesTypeComponentMapInProduct::readAttributes (const XMLAttributes& attributes,
555 const ExpectedAttributes& expectedAttributes)
556 {
557 const unsigned int sbmlLevel = getLevel ();
558 const unsigned int sbmlVersion = getVersion();
559
560 unsigned int numErrs;
561
562 /* look to see whether an unknown attribute error was logged
563 * during the read of the listOfSpeciesTypeComponentMapInProducts - which will have
564 * happened immediately prior to this read
565 */
566
567 ListOfSpeciesTypeComponentMapInProducts * parentListOf =
568 static_cast<ListOfSpeciesTypeComponentMapInProducts*>(getParentSBMLObject());
569
570 if (getErrorLog() != NULL && parentListOf->size() < 2)
571 {
572 numErrs = getErrorLog()->getNumErrors();
573 for (int n = numErrs-1; n >= 0; n--)
574 {
575 if (getErrorLog()->getError(n)->getErrorId() == UnknownPackageAttribute)
576 {
577 const std::string details =
578 getErrorLog()->getError(n)->getMessage();
579 getErrorLog()->remove(UnknownPackageAttribute);
580 getErrorLog()->logPackageError("multi", MultiLofSptCpoMapsInPro_AllowedAtts,
581 getPackageVersion(), sbmlLevel, sbmlVersion, details,
582 parentListOf->getLine(), parentListOf->getColumn());
583 }
584 else if (getErrorLog()->getError(n)->getErrorId() == UnknownCoreAttribute)
585 {
586 const std::string details =
587 getErrorLog()->getError(n)->getMessage();
588 getErrorLog()->remove(UnknownCoreAttribute);
589 getErrorLog()->logPackageError("multi", MultiLofSptCpoMapsInPro_AllowedAtts,
590 getPackageVersion(), sbmlLevel, sbmlVersion, details,
591 parentListOf->getLine(), parentListOf->getColumn());
592 }
593 }
594 }
595
596 SBase::readAttributes(attributes, expectedAttributes);
597
598 // look to see whether an unknown attribute error was logged
599 if (getErrorLog() != NULL)
600 {
601 numErrs = getErrorLog()->getNumErrors();
602 for (int n = numErrs-1; n >= 0; n--)
603 {
604 if (getErrorLog()->getError(n)->getErrorId() == UnknownPackageAttribute)
605 {
606 const std::string details =
607 getErrorLog()->getError(n)->getMessage();
608 getErrorLog()->remove(UnknownPackageAttribute);
609 getErrorLog()->logPackageError("multi", MultiSptCpoMapInPro_AllowedMultiAtts,
610 getPackageVersion(), sbmlLevel, sbmlVersion, details,
611 getLine(), getColumn());
612 }
613 else if (getErrorLog()->getError(n)->getErrorId() == UnknownCoreAttribute)
614 {
615 const std::string details =
616 getErrorLog()->getError(n)->getMessage();
617 getErrorLog()->remove(UnknownCoreAttribute);
618 getErrorLog()->logPackageError("multi", MultiSptCpoMapInPro_AllowedCoreAtts,
619 getPackageVersion(), sbmlLevel, sbmlVersion, details,
620 getLine(), getColumn());
621 }
622 }
623 }
624
625 bool assigned = false;
626
627 //
628 // id SId ( use = "optional" )
629 //
630 assigned = attributes.readInto("id", mId);
631
632 if (assigned == true)
633 {
634 // check string is not empty and correct syntax
635
636 if (mId.empty() == true)
637 {
638 logEmptyString(mId, getLevel(), getVersion(), "<SpeciesTypeComponentMapInProduct>");
639 }
640 else if (SyntaxChecker::isValidSBMLSId(mId) == false && getErrorLog() != NULL)
641 {
642 std::string details = "The syntax of the attribute id='" + mId + "' does not conform.";
643 getErrorLog()->logPackageError("multi", MultiInvSIdSyn,
644 getPackageVersion(), sbmlLevel, sbmlVersion, details,
645 getLine(), getColumn());
646 }
647 }
648
649 //
650 // name string ( use = "optional" )
651 //
652 assigned = attributes.readInto("name", mName);
653
654 if (assigned == true)
655 {
656 // check string is not empty
657
658 if (mName.empty() == true)
659 {
660 logEmptyString(mName, getLevel(), getVersion(), "<SpeciesTypeComponentMapInProduct>");
661 }
662 }
663
664 //
665 // reactant SIdRef ( use = "required" )
666 //
667 assigned = attributes.readInto("reactant", mReactant);
668
669 if (assigned == true)
670 {
671 // check string is not empty and correct syntax
672
673 if (mReactant.empty() == true)
674 {
675 logEmptyString(mReactant, getLevel(), getVersion(), "<SpeciesTypeComponentMapInProduct>");
676 }
677 else if (SyntaxChecker::isValidSBMLSId(mReactant) == false && getErrorLog() != NULL)
678 {
679 std::string details = "The syntax of the attribute reactant='" + mReactant + "' does not conform.";
680 getErrorLog()->logPackageError("multi", MultiInvSIdSyn,
681 getPackageVersion(), sbmlLevel, sbmlVersion, details,
682 getLine(), getColumn());
683
684 }
685 }
686 else
687 {
688 std::string message = "Multi attribute 'reactant' is missing.";
689 getErrorLog()->logPackageError("multi", MultiSptCpoMapInPro_AllowedMultiAtts,
690 getPackageVersion(), sbmlLevel, sbmlVersion, message, getLine(), getColumn());
691 }
692
693 //
694 // reactantComponent SIdRef ( use = "required" )
695 //
696 assigned = attributes.readInto("reactantComponent", mReactantComponent);
697
698 if (assigned == true)
699 {
700 // check string is not empty and correct syntax
701
702 if (mReactantComponent.empty() == true)
703 {
704 logEmptyString(mReactantComponent, getLevel(), getVersion(), "<SpeciesTypeComponentMapInProduct>");
705 }
706 else if (SyntaxChecker::isValidSBMLSId(mReactantComponent) == false && getErrorLog() != NULL)
707 {
708 std::string details = "The syntax of the attribute reactantComponent='" + mReactantComponent + "' does not conform.";
709 getErrorLog()->logPackageError("multi", MultiInvSIdSyn,
710 getPackageVersion(), sbmlLevel, sbmlVersion, details,
711 getLine(), getColumn());
712
713 }
714 }
715 else
716 {
717 std::string message = "Multi attribute 'reactantComponent' is missing.";
718 getErrorLog()->logPackageError("multi", MultiSptCpoMapInPro_AllowedMultiAtts,
719 getPackageVersion(), sbmlLevel, sbmlVersion, message, getLine(), getColumn());
720 }
721
722 //
723 // productComponent SIdRef ( use = "required" )
724 //
725 assigned = attributes.readInto("productComponent", mProductComponent);
726
727 if (assigned == true)
728 {
729 // check string is not empty and correct syntax
730
731 if (mProductComponent.empty() == true)
732 {
733 logEmptyString(mProductComponent, getLevel(), getVersion(), "<SpeciesTypeComponentMapInProduct>");
734 }
735 else if (SyntaxChecker::isValidSBMLSId(mProductComponent) == false && getErrorLog() != NULL)
736 {
737 std::string details = "The syntax of the attribute productComponent='" + mProductComponent + "' does not conform.";
738 getErrorLog()->logPackageError("multi", MultiInvSIdSyn,
739 getPackageVersion(), sbmlLevel, sbmlVersion, details,
740 getLine(), getColumn());
741 }
742 }
743 else
744 {
745 std::string message = "Multi attribute 'productComponent' is missing.";
746 getErrorLog()->logPackageError("multi", MultiSptCpoMapInPro_AllowedMultiAtts,
747 getPackageVersion(), sbmlLevel, sbmlVersion, message, getLine(), getColumn());
748 }
749
750 }
751
752
753 /** @endcond */
754
755
756 /** @cond doxygenLibsbmlInternal */
757
758 /*
759 * Write values of XMLAttributes to the output stream.
760 */
761 void
writeAttributes(XMLOutputStream & stream) const762 SpeciesTypeComponentMapInProduct::writeAttributes (XMLOutputStream& stream) const
763 {
764 SBase::writeAttributes(stream);
765
766 if (isSetReactant() == true)
767 stream.writeAttribute("reactant", getPrefix(), mReactant);
768
769 if (isSetReactantComponent() == true)
770 stream.writeAttribute("reactantComponent", getPrefix(), mReactantComponent);
771
772 if (isSetProductComponent() == true)
773 stream.writeAttribute("productComponent", getPrefix(), mProductComponent);
774
775 SBase::writeExtensionAttributes(stream);
776
777 }
778
779
780 /** @endcond */
781
782
783 /*
784 * Constructor
785 */
ListOfSpeciesTypeComponentMapInProducts(unsigned int level,unsigned int version,unsigned int pkgVersion)786 ListOfSpeciesTypeComponentMapInProducts::ListOfSpeciesTypeComponentMapInProducts(unsigned int level,
787 unsigned int version,
788 unsigned int pkgVersion)
789 : ListOf(level, version)
790 {
791 setSBMLNamespacesAndOwn(new MultiPkgNamespaces(level, version, pkgVersion));
792 }
793
794
795 /*
796 * Constructor
797 */
ListOfSpeciesTypeComponentMapInProducts(MultiPkgNamespaces * multins)798 ListOfSpeciesTypeComponentMapInProducts::ListOfSpeciesTypeComponentMapInProducts(MultiPkgNamespaces* multins)
799 : ListOf(multins)
800 {
801 setElementNamespace(multins->getURI());
802 }
803
804
805 /*
806 * Returns a deep copy of this ListOfSpeciesTypeComponentMapInProducts
807 */
808 ListOfSpeciesTypeComponentMapInProducts*
clone() const809 ListOfSpeciesTypeComponentMapInProducts::clone () const
810 {
811 return new ListOfSpeciesTypeComponentMapInProducts(*this);
812 }
813
814
815 /*
816 * Get a SpeciesTypeComponentMapInProduct from the ListOfSpeciesTypeComponentMapInProducts by index.
817 */
818 SpeciesTypeComponentMapInProduct*
get(unsigned int n)819 ListOfSpeciesTypeComponentMapInProducts::get(unsigned int n)
820 {
821 return static_cast<SpeciesTypeComponentMapInProduct*>(ListOf::get(n));
822 }
823
824
825 /*
826 * Get a SpeciesTypeComponentMapInProduct from the ListOfSpeciesTypeComponentMapInProducts by index.
827 */
828 const SpeciesTypeComponentMapInProduct*
get(unsigned int n) const829 ListOfSpeciesTypeComponentMapInProducts::get(unsigned int n) const
830 {
831 return static_cast<const SpeciesTypeComponentMapInProduct*>(ListOf::get(n));
832 }
833
834
835 /*
836 * Get a SpeciesTypeComponentMapInProduct from the ListOfSpeciesTypeComponentMapInProducts by id.
837 */
838 SpeciesTypeComponentMapInProduct*
get(const std::string & sid)839 ListOfSpeciesTypeComponentMapInProducts::get(const std::string& sid)
840 {
841 return const_cast<SpeciesTypeComponentMapInProduct*>(
842 static_cast<const ListOfSpeciesTypeComponentMapInProducts&>(*this).get(sid));
843 }
844
845
846 /*
847 * Get a SpeciesTypeComponentMapInProduct from the ListOfSpeciesTypeComponentMapInProducts by id.
848 */
849 const SpeciesTypeComponentMapInProduct*
get(const std::string & sid) const850 ListOfSpeciesTypeComponentMapInProducts::get(const std::string& sid) const
851 {
852 vector<SBase*>::const_iterator result;
853
854 result = find_if( mItems.begin(), mItems.end(), IdEq<SpeciesTypeComponentMapInProduct>(sid) );
855 return (result == mItems.end()) ? 0 : static_cast <SpeciesTypeComponentMapInProduct*> (*result);
856 }
857
858
859 /*
860 * Removes the nth SpeciesTypeComponentMapInProduct from this ListOfSpeciesTypeComponentMapInProducts
861 */
862 SpeciesTypeComponentMapInProduct*
remove(unsigned int n)863 ListOfSpeciesTypeComponentMapInProducts::remove(unsigned int n)
864 {
865 return static_cast<SpeciesTypeComponentMapInProduct*>(ListOf::remove(n));
866 }
867
868
869 /*
870 * Removes the SpeciesTypeComponentMapInProduct from this ListOfSpeciesTypeComponentMapInProducts with the given identifier
871 */
872 SpeciesTypeComponentMapInProduct*
remove(const std::string & sid)873 ListOfSpeciesTypeComponentMapInProducts::remove(const std::string& sid)
874 {
875 SBase* item = NULL;
876 vector<SBase*>::iterator result;
877
878 result = find_if( mItems.begin(), mItems.end(), IdEq<SpeciesTypeComponentMapInProduct>(sid) );
879
880 if (result != mItems.end())
881 {
882 item = *result;
883 mItems.erase(result);
884 }
885
886 return static_cast <SpeciesTypeComponentMapInProduct*> (item);
887 }
888
889
890 /*
891 * Returns the XML element name of this object
892 */
893 const std::string&
getElementName() const894 ListOfSpeciesTypeComponentMapInProducts::getElementName () const
895 {
896 static const string name = "listOfSpeciesTypeComponentMapsInProduct";
897 return name;
898 }
899
900
901 /*
902 * Returns the libSBML type code for this SBML object.
903 */
904 int
getTypeCode() const905 ListOfSpeciesTypeComponentMapInProducts::getTypeCode () const
906 {
907 return SBML_LIST_OF;
908 }
909
910
911 /*
912 * Returns the libSBML type code for the objects in this LIST_OF.
913 */
914 int
getItemTypeCode() const915 ListOfSpeciesTypeComponentMapInProducts::getItemTypeCode () const
916 {
917 return SBML_MULTI_SPECIES_TYPE_COMPONENT_MAP_IN_PRODUCT;
918 }
919
920
921 /** @cond doxygenLibsbmlInternal */
922
923 /*
924 * Creates a new SpeciesTypeComponentMapInProduct in this ListOfSpeciesTypeComponentMapInProducts
925 */
926 SBase*
createObject(XMLInputStream & stream)927 ListOfSpeciesTypeComponentMapInProducts::createObject(XMLInputStream& stream)
928 {
929 const std::string& name = stream.peek().getName();
930 SBase* object = NULL;
931
932 if (name == "speciesTypeComponentMapInProduct")
933 {
934 MULTI_CREATE_NS(multins, getSBMLNamespaces());
935 object = new SpeciesTypeComponentMapInProduct(multins);
936 appendAndOwn(object);
937 delete multins;
938 }
939
940 return object;
941 }
942
943
944 /** @endcond */
945
946
947 /** @cond doxygenLibsbmlInternal */
948
949 /*
950 * Write the namespace for the Multi package.
951 */
952 void
writeXMLNS(XMLOutputStream & stream) const953 ListOfSpeciesTypeComponentMapInProducts::writeXMLNS(XMLOutputStream& stream) const
954 {
955 XMLNamespaces xmlns;
956
957 std::string prefix = getPrefix();
958
959 if (prefix.empty())
960 {
961 XMLNamespaces* thisxmlns = getNamespaces();
962 if (thisxmlns && thisxmlns->hasURI(MultiExtension::getXmlnsL3V1V1()))
963 {
964 xmlns.add(MultiExtension::getXmlnsL3V1V1(),prefix);
965 }
966 }
967
968 stream << xmlns;
969 }
970
971
972 /** @endcond */
973
974
975 LIBSBML_EXTERN
976 SpeciesTypeComponentMapInProduct_t *
SpeciesTypeComponentMapInProduct_create(unsigned int level,unsigned int version,unsigned int pkgVersion)977 SpeciesTypeComponentMapInProduct_create(unsigned int level, unsigned int version,
978 unsigned int pkgVersion)
979 {
980 return new SpeciesTypeComponentMapInProduct(level, version, pkgVersion);
981 }
982
983
984 LIBSBML_EXTERN
985 void
SpeciesTypeComponentMapInProduct_free(SpeciesTypeComponentMapInProduct_t * stcmip)986 SpeciesTypeComponentMapInProduct_free(SpeciesTypeComponentMapInProduct_t * stcmip)
987 {
988 if (stcmip != NULL)
989 delete stcmip;
990 }
991
992
993 LIBSBML_EXTERN
994 SpeciesTypeComponentMapInProduct_t *
SpeciesTypeComponentMapInProduct_clone(SpeciesTypeComponentMapInProduct_t * stcmip)995 SpeciesTypeComponentMapInProduct_clone(SpeciesTypeComponentMapInProduct_t * stcmip)
996 {
997 if (stcmip != NULL)
998 {
999 return static_cast<SpeciesTypeComponentMapInProduct_t*>(stcmip->clone());
1000 }
1001 else
1002 {
1003 return NULL;
1004 }
1005 }
1006
1007
1008 LIBSBML_EXTERN
1009 char *
SpeciesTypeComponentMapInProduct_getId(SpeciesTypeComponentMapInProduct_t * cr)1010 SpeciesTypeComponentMapInProduct_getId(SpeciesTypeComponentMapInProduct_t * cr)
1011 {
1012 if (cr == NULL)
1013 return NULL;
1014
1015 return cr->getId().empty() ? NULL : safe_strdup(cr->getId().c_str());
1016 }
1017
1018
1019 LIBSBML_EXTERN
1020 char *
SpeciesTypeComponentMapInProduct_getName(SpeciesTypeComponentMapInProduct_t * cr)1021 SpeciesTypeComponentMapInProduct_getName(SpeciesTypeComponentMapInProduct_t * cr)
1022 {
1023 if (cr == NULL)
1024 return NULL;
1025
1026 return cr->getName().empty() ? NULL : safe_strdup(cr->getName().c_str());
1027 }
1028
1029
1030 LIBSBML_EXTERN
1031 char *
SpeciesTypeComponentMapInProduct_getReactant(SpeciesTypeComponentMapInProduct_t * stcmip)1032 SpeciesTypeComponentMapInProduct_getReactant(SpeciesTypeComponentMapInProduct_t * stcmip)
1033 {
1034 if (stcmip == NULL)
1035 return NULL;
1036
1037 return stcmip->getReactant().empty() ? NULL : safe_strdup(stcmip->getReactant().c_str());
1038 }
1039
1040
1041 LIBSBML_EXTERN
1042 char *
SpeciesTypeComponentMapInProduct_getReactantComponent(SpeciesTypeComponentMapInProduct_t * stcmip)1043 SpeciesTypeComponentMapInProduct_getReactantComponent(SpeciesTypeComponentMapInProduct_t * stcmip)
1044 {
1045 if (stcmip == NULL)
1046 return NULL;
1047
1048 return stcmip->getReactantComponent().empty() ? NULL : safe_strdup(stcmip->getReactantComponent().c_str());
1049 }
1050
1051
1052 LIBSBML_EXTERN
1053 char *
SpeciesTypeComponentMapInProduct_getProductComponent(SpeciesTypeComponentMapInProduct_t * stcmip)1054 SpeciesTypeComponentMapInProduct_getProductComponent(SpeciesTypeComponentMapInProduct_t * stcmip)
1055 {
1056 if (stcmip == NULL)
1057 return NULL;
1058
1059 return stcmip->getProductComponent().empty() ? NULL : safe_strdup(stcmip->getProductComponent().c_str());
1060 }
1061
1062
1063 LIBSBML_EXTERN
1064 int
SpeciesTypeComponentMapInProduct_isSetId(SpeciesTypeComponentMapInProduct_t * cr)1065 SpeciesTypeComponentMapInProduct_isSetId(SpeciesTypeComponentMapInProduct_t * cr)
1066 {
1067 return (cr != NULL) ? static_cast<int>(cr->isSetId()) : 0;
1068 }
1069
1070
1071 LIBSBML_EXTERN
1072 int
SpeciesTypeComponentMapInProduct_isSetName(SpeciesTypeComponentMapInProduct_t * cr)1073 SpeciesTypeComponentMapInProduct_isSetName(SpeciesTypeComponentMapInProduct_t * cr)
1074 {
1075 return (cr != NULL) ? static_cast<int>(cr->isSetName()) : 0;
1076 }
1077
1078
1079 LIBSBML_EXTERN
1080 int
SpeciesTypeComponentMapInProduct_isSetReactant(SpeciesTypeComponentMapInProduct_t * stcmip)1081 SpeciesTypeComponentMapInProduct_isSetReactant(SpeciesTypeComponentMapInProduct_t * stcmip)
1082 {
1083 return (stcmip != NULL) ? static_cast<int>(stcmip->isSetReactant()) : 0;
1084 }
1085
1086
1087 LIBSBML_EXTERN
1088 int
SpeciesTypeComponentMapInProduct_isSetReactantComponent(SpeciesTypeComponentMapInProduct_t * stcmip)1089 SpeciesTypeComponentMapInProduct_isSetReactantComponent(SpeciesTypeComponentMapInProduct_t * stcmip)
1090 {
1091 return (stcmip != NULL) ? static_cast<int>(stcmip->isSetReactantComponent()) : 0;
1092 }
1093
1094
1095 LIBSBML_EXTERN
1096 int
SpeciesTypeComponentMapInProduct_isSetProductComponent(SpeciesTypeComponentMapInProduct_t * stcmip)1097 SpeciesTypeComponentMapInProduct_isSetProductComponent(SpeciesTypeComponentMapInProduct_t * stcmip)
1098 {
1099 return (stcmip != NULL) ? static_cast<int>(stcmip->isSetProductComponent()) : 0;
1100 }
1101
1102
1103 LIBSBML_EXTERN
1104 int
SpeciesTypeComponentMapInProduct_setId(SpeciesTypeComponentMapInProduct_t * cr,const char * id)1105 SpeciesTypeComponentMapInProduct_setId(SpeciesTypeComponentMapInProduct_t * cr, const char * id)
1106 {
1107 return (cr != NULL) ? cr->setId(id) : LIBSBML_INVALID_OBJECT;
1108 }
1109
1110
1111 LIBSBML_EXTERN
1112 int
SpeciesTypeComponentMapInProduct_setName(SpeciesTypeComponentMapInProduct_t * cr,const char * name)1113 SpeciesTypeComponentMapInProduct_setName(SpeciesTypeComponentMapInProduct_t * cr, const char * name)
1114 {
1115 return (cr != NULL) ? cr->setName(name) : LIBSBML_INVALID_OBJECT;
1116 }
1117
1118
1119 LIBSBML_EXTERN
1120 int
SpeciesTypeComponentMapInProduct_setReactant(SpeciesTypeComponentMapInProduct_t * stcmip,const char * reactant)1121 SpeciesTypeComponentMapInProduct_setReactant(SpeciesTypeComponentMapInProduct_t * stcmip, const char * reactant)
1122 {
1123 return (stcmip != NULL) ? stcmip->setReactant(reactant) : LIBSBML_INVALID_OBJECT;
1124 }
1125
1126
1127 LIBSBML_EXTERN
1128 int
SpeciesTypeComponentMapInProduct_setReactantComponent(SpeciesTypeComponentMapInProduct_t * stcmip,const char * reactantComponent)1129 SpeciesTypeComponentMapInProduct_setReactantComponent(SpeciesTypeComponentMapInProduct_t * stcmip, const char * reactantComponent)
1130 {
1131 return (stcmip != NULL) ? stcmip->setReactantComponent(reactantComponent) : LIBSBML_INVALID_OBJECT;
1132 }
1133
1134
1135 LIBSBML_EXTERN
1136 int
SpeciesTypeComponentMapInProduct_setProductComponent(SpeciesTypeComponentMapInProduct_t * stcmip,const char * productComponent)1137 SpeciesTypeComponentMapInProduct_setProductComponent(SpeciesTypeComponentMapInProduct_t * stcmip, const char * productComponent)
1138 {
1139 return (stcmip != NULL) ? stcmip->setProductComponent(productComponent) : LIBSBML_INVALID_OBJECT;
1140 }
1141
1142
1143 LIBSBML_EXTERN
1144 int
SpeciesTypeComponentMapInProduct_unsetId(SpeciesTypeComponentMapInProduct_t * cr)1145 SpeciesTypeComponentMapInProduct_unsetId(SpeciesTypeComponentMapInProduct_t * cr)
1146 {
1147 return (cr != NULL) ? cr->unsetId() : LIBSBML_INVALID_OBJECT;
1148 }
1149
1150
1151 LIBSBML_EXTERN
1152 int
SpeciesTypeComponentMapInProduct_unsetName(SpeciesTypeComponentMapInProduct_t * cr)1153 SpeciesTypeComponentMapInProduct_unsetName(SpeciesTypeComponentMapInProduct_t * cr)
1154 {
1155 return (cr != NULL) ? cr->unsetName() : LIBSBML_INVALID_OBJECT;
1156 }
1157
1158
1159 LIBSBML_EXTERN
1160 int
SpeciesTypeComponentMapInProduct_unsetReactant(SpeciesTypeComponentMapInProduct_t * stcmip)1161 SpeciesTypeComponentMapInProduct_unsetReactant(SpeciesTypeComponentMapInProduct_t * stcmip)
1162 {
1163 return (stcmip != NULL) ? stcmip->unsetReactant() : LIBSBML_INVALID_OBJECT;
1164 }
1165
1166
1167 LIBSBML_EXTERN
1168 int
SpeciesTypeComponentMapInProduct_unsetReactantComponent(SpeciesTypeComponentMapInProduct_t * stcmip)1169 SpeciesTypeComponentMapInProduct_unsetReactantComponent(SpeciesTypeComponentMapInProduct_t * stcmip)
1170 {
1171 return (stcmip != NULL) ? stcmip->unsetReactantComponent() : LIBSBML_INVALID_OBJECT;
1172 }
1173
1174
1175 LIBSBML_EXTERN
1176 int
SpeciesTypeComponentMapInProduct_unsetProductComponent(SpeciesTypeComponentMapInProduct_t * stcmip)1177 SpeciesTypeComponentMapInProduct_unsetProductComponent(SpeciesTypeComponentMapInProduct_t * stcmip)
1178 {
1179 return (stcmip != NULL) ? stcmip->unsetProductComponent() : LIBSBML_INVALID_OBJECT;
1180 }
1181
1182
1183 LIBSBML_EXTERN
1184 int
SpeciesTypeComponentMapInProduct_hasRequiredAttributes(SpeciesTypeComponentMapInProduct_t * stcmip)1185 SpeciesTypeComponentMapInProduct_hasRequiredAttributes(SpeciesTypeComponentMapInProduct_t * stcmip)
1186 {
1187 return (stcmip != NULL) ? static_cast<int>(stcmip->hasRequiredAttributes()) : 0;
1188 }
1189
1190
1191 LIBSBML_EXTERN
1192 SpeciesTypeComponentMapInProduct_t *
ListOfSpeciesTypeComponentMapInProducts_getById(ListOf_t * lo,const char * sid)1193 ListOfSpeciesTypeComponentMapInProducts_getById(ListOf_t * lo, const char * sid)
1194 {
1195 if (lo == NULL)
1196 return NULL;
1197
1198 return (sid != NULL) ? static_cast <ListOfSpeciesTypeComponentMapInProducts *>(lo)->get(sid) : NULL;
1199 }
1200
1201
1202 LIBSBML_EXTERN
1203 SpeciesTypeComponentMapInProduct_t *
ListOfSpeciesTypeComponentMapInProducts_removeById(ListOf_t * lo,const char * sid)1204 ListOfSpeciesTypeComponentMapInProducts_removeById(ListOf_t * lo, const char * sid)
1205 {
1206 if (lo == NULL)
1207 return NULL;
1208
1209 return (sid != NULL) ? static_cast <ListOfSpeciesTypeComponentMapInProducts *>(lo)->remove(sid) : NULL;
1210 }
1211
1212
1213
1214 LIBSBML_CPP_NAMESPACE_END
1215
1216 #endif /*__cplusplus */
1217
1218
1219