1 /**
2 * @file GroupsModelPlugin.cpp
3 * @brief Implementation of the GroupsModelPlugin 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/groups/extension/GroupsModelPlugin.h>
43 #include <sbml/packages/groups/validator/GroupsSBMLError.h>
44 #include <sbml/util/ElementFilter.h>
45 #include <sbml/Model.h>
46
47
48 using namespace std;
49
50
51
52 LIBSBML_CPP_NAMESPACE_BEGIN
53
54
55
56
57 #ifdef __cplusplus
58
59
60 /*
61 * Creates a new GroupsModelPlugin using the given URI, prefix and package
62 * namespace.
63 */
GroupsModelPlugin(const std::string & uri,const std::string & prefix,GroupsPkgNamespaces * groupsns)64 GroupsModelPlugin::GroupsModelPlugin(const std::string& uri,
65 const std::string& prefix,
66 GroupsPkgNamespaces* groupsns)
67 : SBasePlugin(uri, prefix, groupsns)
68 , mGroups (groupsns)
69 {
70 connectToChild();
71 }
72
73
74 /*
75 * Copy constructor for GroupsModelPlugin.
76 */
GroupsModelPlugin(const GroupsModelPlugin & orig)77 GroupsModelPlugin::GroupsModelPlugin(const GroupsModelPlugin& orig)
78 : SBasePlugin( orig )
79 , mGroups ( orig.mGroups )
80 {
81 connectToChild();
82 }
83
84
85 /*
86 * Assignment operator for GroupsModelPlugin.
87 */
88 GroupsModelPlugin&
operator =(const GroupsModelPlugin & rhs)89 GroupsModelPlugin::operator=(const GroupsModelPlugin& rhs)
90 {
91 if (&rhs != this)
92 {
93 SBasePlugin::operator=(rhs);
94 mGroups = rhs.mGroups;
95 connectToChild();
96 }
97
98 return *this;
99 }
100
101
102 /*
103 * Creates and returns a deep copy of this GroupsModelPlugin object.
104 */
105 GroupsModelPlugin*
clone() const106 GroupsModelPlugin::clone() const
107 {
108 return new GroupsModelPlugin(*this);
109 }
110
111
112 /*
113 * Destructor for GroupsModelPlugin.
114 */
~GroupsModelPlugin()115 GroupsModelPlugin::~GroupsModelPlugin()
116 {
117 }
118
119
120 /*
121 * Returns the ListOfGroups from this GroupsModelPlugin.
122 */
123 const ListOfGroups*
getListOfGroups() const124 GroupsModelPlugin::getListOfGroups() const
125 {
126 return &mGroups;
127 }
128
129
130 /*
131 * Returns the ListOfGroups from this GroupsModelPlugin.
132 */
133 ListOfGroups*
getListOfGroups()134 GroupsModelPlugin::getListOfGroups()
135 {
136 return &mGroups;
137 }
138
139
140 /*
141 * Get a Group from the GroupsModelPlugin.
142 */
143 Group*
getGroup(unsigned int n)144 GroupsModelPlugin::getGroup(unsigned int n)
145 {
146 return static_cast< Group*>(mGroups.get(n));
147 }
148
149
150 /*
151 * Get a Group from the GroupsModelPlugin.
152 */
153 const Group*
getGroup(unsigned int n) const154 GroupsModelPlugin::getGroup(unsigned int n) const
155 {
156 return static_cast<const Group*>(mGroups.get(n));
157 }
158
159
160 /*
161 * Get a Group from the GroupsModelPlugin based on its identifier.
162 */
163 Group*
getGroup(const std::string & sid)164 GroupsModelPlugin::getGroup(const std::string& sid)
165 {
166 return static_cast< Group*>(mGroups.get(sid));
167 }
168
169
170 /*
171 * Get a Group from the GroupsModelPlugin based on its identifier.
172 */
173 const Group*
getGroup(const std::string & sid) const174 GroupsModelPlugin::getGroup(const std::string& sid) const
175 {
176 return static_cast<const Group*>(mGroups.get(sid));
177 }
178
179
180 /*
181 * Adds a copy of the given Group to this GroupsModelPlugin.
182 */
183 int
addGroup(const Group * g)184 GroupsModelPlugin::addGroup(const Group* g)
185 {
186 if (g == NULL)
187 {
188 return LIBSBML_OPERATION_FAILED;
189 }
190 else if (g->hasRequiredAttributes() == false)
191 {
192 return LIBSBML_INVALID_OBJECT;
193 }
194 else if (getLevel() != g->getLevel())
195 {
196 return LIBSBML_LEVEL_MISMATCH;
197 }
198 else if (getVersion() != g->getVersion())
199 {
200 return LIBSBML_VERSION_MISMATCH;
201 }
202 else if (getPackageVersion() != g->getPackageVersion())
203 {
204 return LIBSBML_PKG_VERSION_MISMATCH;
205 }
206 else if (g->isSetId() && (mGroups.get(g->getId())) != NULL)
207 {
208 return LIBSBML_DUPLICATE_OBJECT_ID;
209 }
210 else
211 {
212 return mGroups.append(g);
213 }
214 }
215
216
217 /*
218 * Get the number of Group objects in this GroupsModelPlugin.
219 */
220 unsigned int
getNumGroups() const221 GroupsModelPlugin::getNumGroups() const
222 {
223 return mGroups.size();
224 }
225
226
227 /*
228 * Creates a new Group object, adds it to this GroupsModelPlugin object and
229 * returns the Group object created.
230 */
231 Group*
createGroup()232 GroupsModelPlugin::createGroup()
233 {
234 Group* g = NULL;
235
236 try
237 {
238 GROUPS_CREATE_NS(groupsns, getSBMLNamespaces());
239 g = new Group(groupsns);
240 delete groupsns;
241 }
242 catch (...)
243 {
244 }
245
246 if (g != NULL)
247 {
248 mGroups.appendAndOwn(g);
249 }
250
251 return g;
252 }
253
254
255 /*
256 * Removes the nth Group from this GroupsModelPlugin and returns a pointer to
257 * it.
258 */
259 Group*
removeGroup(unsigned int n)260 GroupsModelPlugin::removeGroup(unsigned int n)
261 {
262 return static_cast<Group*>(mGroups.remove(n));
263 }
264
265
266 /*
267 * Removes the Group from this GroupsModelPlugin based on its identifier and
268 * returns a pointer to it.
269 */
270 Group*
removeGroup(const std::string & sid)271 GroupsModelPlugin::removeGroup(const std::string& sid)
272 {
273 return static_cast<Group*>(mGroups.remove(sid));
274 }
275
276
277
278 /** @cond doxygenLibsbmlInternal */
279
280 /*
281 * Write any contained elements
282 */
283 void
writeElements(XMLOutputStream & stream) const284 GroupsModelPlugin::writeElements(XMLOutputStream& stream) const
285 {
286 if (getNumGroups() > 0)
287 {
288 mGroups.write(stream);
289 }
290 }
291
292 /** @endcond */
293
294
295
296 /** @cond doxygenLibsbmlInternal */
297
298 /*
299 * Accepts the given SBMLVisitor
300 */
301 bool
accept(SBMLVisitor & v) const302 GroupsModelPlugin::accept(SBMLVisitor& v) const
303 {
304 const Model* m = static_cast<const Model*>(this->getParentSBMLObject());
305 v.visit(*m);
306 v.leave(*m);
307
308 mGroups.accept(v);
309
310 return true;
311 }
312
313 /** @endcond */
314
315
316
317 /** @cond doxygenLibsbmlInternal */
318
319 /*
320 * Sets the parent SBMLDocument
321 */
322 void
setSBMLDocument(SBMLDocument * d)323 GroupsModelPlugin::setSBMLDocument(SBMLDocument* d)
324 {
325 SBasePlugin::setSBMLDocument(d);
326
327 mGroups.setSBMLDocument(d);
328 }
329
330 /** @endcond */
331
332
333
334 /** @cond doxygenLibsbmlInternal */
335
336 /*
337 * Connects to child elements
338 */
339 void
connectToChild()340 GroupsModelPlugin::connectToChild()
341 {
342 connectToParent(getParentSBMLObject());
343 }
344
345 /** @endcond */
346
347
348
349 /** @cond doxygenLibsbmlInternal */
350
351 /*
352 * Connects to parent element
353 */
354 void
connectToParent(SBase * base)355 GroupsModelPlugin::connectToParent(SBase* base)
356 {
357 SBasePlugin::connectToParent(base);
358
359 mGroups.connectToParent(base);
360 }
361
362 /** @endcond */
363
364
365
366 /** @cond doxygenLibsbmlInternal */
367
368 /*
369 * Enables/disables the given package with this element
370 */
371 void
enablePackageInternal(const std::string & pkgURI,const std::string & pkgPrefix,bool flag)372 GroupsModelPlugin::enablePackageInternal(const std::string& pkgURI,
373 const std::string& pkgPrefix,
374 bool flag)
375 {
376 mGroups.enablePackageInternal(pkgURI, pkgPrefix, flag);
377 }
378
379 /** @endcond */
380
381
382
383 /** @cond doxygenLibsbmlInternal */
384
385 /*
386 * Updates the namespaces when setLevelVersion is used
387 */
388 void
updateSBMLNamespace(const std::string & package,unsigned int level,unsigned int version)389 GroupsModelPlugin::updateSBMLNamespace(const std::string& package,
390 unsigned int level,
391 unsigned int version)
392 {
393 SBasePlugin::updateSBMLNamespace(package, level, version);
394
395 mGroups.updateSBMLNamespace(package, level, version);
396 }
397
398 /** @endcond */
399
400
401
402 /** @cond doxygenLibsbmlInternal */
403
404 /*
405 * Returns the value of the "attributeName" attribute of this GroupsModelPlugin.
406 */
407 int
getAttribute(const std::string & attributeName,bool & value) const408 GroupsModelPlugin::getAttribute(const std::string& attributeName,
409 bool& value) const
410 {
411 int return_value = SBasePlugin::getAttribute(attributeName, value);
412
413 return return_value;
414 }
415
416 /** @endcond */
417
418
419
420 /** @cond doxygenLibsbmlInternal */
421
422 /*
423 * Returns the value of the "attributeName" attribute of this GroupsModelPlugin.
424 */
425 int
getAttribute(const std::string & attributeName,int & value) const426 GroupsModelPlugin::getAttribute(const std::string& attributeName,
427 int& value) const
428 {
429 int return_value = SBasePlugin::getAttribute(attributeName, value);
430
431 return return_value;
432 }
433
434 /** @endcond */
435
436
437
438 /** @cond doxygenLibsbmlInternal */
439
440 /*
441 * Returns the value of the "attributeName" attribute of this GroupsModelPlugin.
442 */
443 int
getAttribute(const std::string & attributeName,double & value) const444 GroupsModelPlugin::getAttribute(const std::string& attributeName,
445 double& value) const
446 {
447 int return_value = SBasePlugin::getAttribute(attributeName, value);
448
449 return return_value;
450 }
451
452 /** @endcond */
453
454
455
456 /** @cond doxygenLibsbmlInternal */
457
458 /*
459 * Returns the value of the "attributeName" attribute of this GroupsModelPlugin.
460 */
461 int
getAttribute(const std::string & attributeName,unsigned int & value) const462 GroupsModelPlugin::getAttribute(const std::string& attributeName,
463 unsigned int& value) const
464 {
465 int return_value = SBasePlugin::getAttribute(attributeName, value);
466
467 return return_value;
468 }
469
470 /** @endcond */
471
472
473
474 /** @cond doxygenLibsbmlInternal */
475
476 /*
477 * Returns the value of the "attributeName" attribute of this GroupsModelPlugin.
478 */
479 int
getAttribute(const std::string & attributeName,std::string & value) const480 GroupsModelPlugin::getAttribute(const std::string& attributeName,
481 std::string& value) const
482 {
483 int return_value = SBasePlugin::getAttribute(attributeName, value);
484
485 return return_value;
486 }
487
488 /** @endcond */
489
490
491
492 /** @cond doxygenLibsbmlInternal */
493
494 /*
495 * Predicate returning @c true if this GroupsModelPlugin's attribute
496 * "attributeName" is set.
497 */
498 bool
isSetAttribute(const std::string & attributeName) const499 GroupsModelPlugin::isSetAttribute(const std::string& attributeName) const
500 {
501 bool value = SBasePlugin::isSetAttribute(attributeName);
502
503 return value;
504 }
505
506 /** @endcond */
507
508
509
510 /** @cond doxygenLibsbmlInternal */
511
512 /*
513 * Sets the value of the "attributeName" attribute of this GroupsModelPlugin.
514 */
515 int
setAttribute(const std::string & attributeName,bool value)516 GroupsModelPlugin::setAttribute(const std::string& attributeName, bool value)
517 {
518 int return_value = SBasePlugin::setAttribute(attributeName, value);
519
520 return return_value;
521 }
522
523 /** @endcond */
524
525
526
527 /** @cond doxygenLibsbmlInternal */
528
529 /*
530 * Sets the value of the "attributeName" attribute of this GroupsModelPlugin.
531 */
532 int
setAttribute(const std::string & attributeName,int value)533 GroupsModelPlugin::setAttribute(const std::string& attributeName, int value)
534 {
535 int return_value = SBasePlugin::setAttribute(attributeName, value);
536
537 return return_value;
538 }
539
540 /** @endcond */
541
542
543
544 /** @cond doxygenLibsbmlInternal */
545
546 /*
547 * Sets the value of the "attributeName" attribute of this GroupsModelPlugin.
548 */
549 int
setAttribute(const std::string & attributeName,double value)550 GroupsModelPlugin::setAttribute(const std::string& attributeName,
551 double value)
552 {
553 int return_value = SBasePlugin::setAttribute(attributeName, value);
554
555 return return_value;
556 }
557
558 /** @endcond */
559
560
561
562 /** @cond doxygenLibsbmlInternal */
563
564 /*
565 * Sets the value of the "attributeName" attribute of this GroupsModelPlugin.
566 */
567 int
setAttribute(const std::string & attributeName,unsigned int value)568 GroupsModelPlugin::setAttribute(const std::string& attributeName,
569 unsigned int value)
570 {
571 int return_value = SBasePlugin::setAttribute(attributeName, value);
572
573 return return_value;
574 }
575
576 /** @endcond */
577
578
579
580 /** @cond doxygenLibsbmlInternal */
581
582 /*
583 * Sets the value of the "attributeName" attribute of this GroupsModelPlugin.
584 */
585 int
setAttribute(const std::string & attributeName,const std::string & value)586 GroupsModelPlugin::setAttribute(const std::string& attributeName,
587 const std::string& value)
588 {
589 int return_value = SBasePlugin::setAttribute(attributeName, value);
590
591 return return_value;
592 }
593
594 /** @endcond */
595
596
597
598 /** @cond doxygenLibsbmlInternal */
599
600 /*
601 * Unsets the value of the "attributeName" attribute of this GroupsModelPlugin.
602 */
603 int
unsetAttribute(const std::string & attributeName)604 GroupsModelPlugin::unsetAttribute(const std::string& attributeName)
605 {
606 int value = SBasePlugin::unsetAttribute(attributeName);
607
608 return value;
609 }
610
611 /** @endcond */
612
613
614
615 /** @cond doxygenLibsbmlInternal */
616
617 /*
618 * Creates and returns an new "elementName" object in this GroupsModelPlugin.
619 */
620 SBase*
createChildObject(const std::string & elementName)621 GroupsModelPlugin::createChildObject(const std::string& elementName)
622 {
623 SBase* obj = NULL;
624
625 if (elementName == "group")
626 {
627 return createGroup();
628 }
629
630 return obj;
631 }
632
633 /** @endcond */
634
635
636
637 /** @cond doxygenLibsbmlInternal */
638
639 /*
640 * Adds a new "elementName" object to this GroupsModelPlugin.
641 */
642 int
addChildObject(const std::string & elementName,const SBase * element)643 GroupsModelPlugin::addChildObject(const std::string& elementName,
644 const SBase* element)
645 {
646 if (elementName == "group" && element->getTypeCode() == SBML_GROUPS_GROUP)
647 {
648 return addGroup((const Group*)(element));
649 }
650
651 return LIBSBML_OPERATION_FAILED;
652 }
653
654 /** @endcond */
655
656
657
658 /** @cond doxygenLibsbmlInternal */
659
660 /*
661 * Removes and returns the new "elementName" object with the given id in this
662 * GroupsModelPlugin.
663 */
664 SBase*
removeChildObject(const std::string & elementName,const std::string & id)665 GroupsModelPlugin::removeChildObject(const std::string& elementName,
666 const std::string& id)
667 {
668 if (elementName == "group")
669 {
670 return removeGroup(id);
671 }
672
673 return NULL;
674 }
675
676 /** @endcond */
677
678
679
680 /** @cond doxygenLibsbmlInternal */
681
682 /*
683 * Returns the number of "elementName" in this GroupsModelPlugin.
684 */
685 unsigned int
getNumObjects(const std::string & elementName)686 GroupsModelPlugin::getNumObjects(const std::string& elementName)
687 {
688 unsigned int n = 0;
689
690 if (elementName == "group")
691 {
692 return getNumGroups();
693 }
694
695 return n;
696 }
697
698 /** @endcond */
699
700
701
702 /** @cond doxygenLibsbmlInternal */
703
704 /*
705 * Returns the nth object of "objectName" in this GroupsModelPlugin.
706 */
707 SBase*
getObject(const std::string & elementName,unsigned int index)708 GroupsModelPlugin::getObject(const std::string& elementName,
709 unsigned int index)
710 {
711 SBase* obj = NULL;
712
713 if (elementName == "group")
714 {
715 return getGroup(index);
716 }
717
718 return obj;
719 }
720
721 /** @endcond */
722
723
724 /*
725 * Returns the first child element that has the given @p id in the model-wide
726 * SId namespace, or @c NULL if no such object is found.
727 */
728 SBase*
getElementBySId(const std::string & id)729 GroupsModelPlugin::getElementBySId(const std::string& id)
730 {
731 if (id.empty())
732 {
733 return NULL;
734 }
735
736 SBase* obj = NULL;
737
738 obj = mGroups.getElementBySId(id);
739
740 if (obj != NULL)
741 {
742 return obj;
743 }
744
745 return obj;
746 }
747
748
749 /*
750 * Returns the first child element that has the given @p metaid, or @c NULL if
751 * no such object is found.
752 */
753 SBase*
getElementByMetaId(const std::string & metaid)754 GroupsModelPlugin::getElementByMetaId(const std::string& metaid)
755 {
756 if (metaid.empty())
757 {
758 return NULL;
759 }
760
761 SBase* obj = NULL;
762
763 if (mGroups.getMetaId() == metaid)
764 {
765 return &mGroups;
766 }
767
768 obj = mGroups.getElementByMetaId(metaid);
769
770 if (obj != NULL)
771 {
772 return obj;
773 }
774
775 return obj;
776 }
777
778
779 /*
780 * Returns a List of all child SBase objects, including those nested to an
781 * arbitrary depth.
782 */
783 List*
getAllElements(ElementFilter * filter)784 GroupsModelPlugin::getAllElements(ElementFilter* filter)
785 {
786 List* ret = new List();
787 List* sublist = NULL;
788
789
790 ADD_FILTERED_LIST(ret, sublist, mGroups, filter);
791
792 return ret;
793 }
794
795
796
797 /** @cond doxygenLibsbmlInternal */
798
799 /*
800 * Append items from model (used in comp flattening)
801 */
802 int
appendFrom(const Model * model)803 GroupsModelPlugin::appendFrom(const Model* model)
804 {
805 int ret = LIBSBML_OPERATION_SUCCESS;
806
807 if (model == NULL)
808 {
809 return LIBSBML_INVALID_OBJECT;
810 }
811
812 const GroupsModelPlugin* plug = static_cast<const
813 GroupsModelPlugin*>(model->getPlugin(getPrefix()));
814
815 if (plug == NULL)
816 {
817 return ret;
818 }
819
820 Model* parent = static_cast<Model*>(getParentSBMLObject());
821
822 if (parent == NULL)
823 {
824 return LIBSBML_INVALID_OBJECT;
825 }
826
827 ret = mGroups.appendFrom(plug->getListOfGroups());
828
829 if (ret != LIBSBML_OPERATION_SUCCESS)
830 {
831 return ret;
832 }
833
834 return ret;
835 }
836
837 /** @endcond */
838
839
840
841 /** @cond doxygenLibsbmlInternal */
842
843 /*
844 * Creates a new object from the next XMLToken on the XMLInputStream
845 */
846 SBase*
createObject(XMLInputStream & stream)847 GroupsModelPlugin::createObject(XMLInputStream& stream)
848 {
849 SBase* obj = NULL;
850
851 const std::string& name = stream.peek().getName();
852 const XMLNamespaces& xmlns = stream.peek().getNamespaces();
853 const std::string& prefix = stream.peek().getPrefix();
854
855 const std::string& targetPrefix = (xmlns.hasURI(mURI)) ?
856 xmlns.getPrefix(mURI) : mPrefix;
857
858 if (prefix == targetPrefix)
859 {
860 if (name == "listOfGroups")
861 {
862 if (mGroups.size() != 0)
863 {
864 getErrorLog()->logPackageError("groups", GroupsModelAllowedElements,
865 getPackageVersion(), getLevel(), getVersion(), "", getLine(),
866 getColumn());
867 }
868
869 obj = &mGroups;
870 if (targetPrefix.empty())
871 {
872 mGroups.getSBMLDocument()->enableDefaultNS(mURI, true);
873 }
874 }
875 }
876
877 connectToChild();
878
879 return obj;
880 }
881
882 /** @endcond */
883
884
885 void
copyInformationToNestedLists()886 GroupsModelPlugin::copyInformationToNestedLists()
887 {
888 bool change = true;
889 while (change)
890 {
891 change = false;
892
893 for (unsigned int lnum = 0; lnum < getNumGroups(); lnum++)
894 {
895 Group* group = getGroup(lnum);
896 ListOf* listofmembers = group->getListOfMembers();
897
898 for (unsigned int mnum = 0; mnum < group->getNumMembers(); mnum++)
899 {
900 Member* member = group->getMember(mnum);
901 SBase* referent = NULL;
902
903 if (member->isSetIdRef())
904 {
905 referent = getElementBySId(member->getIdRef());
906 }
907
908 if (referent == NULL && member->isSetMetaIdRef())
909 {
910 referent = getElementByMetaId(member->getMetaIdRef());
911 }
912
913 if (referent != NULL && referent->getTypeCode() == SBML_LIST_OF)
914 {
915 ListOf* list = static_cast<ListOf*>(referent);
916
917 if (list->getItemTypeCode() == SBML_GROUPS_MEMBER)
918 {
919 if (!referent->isSetSBOTerm())
920 {
921 if (listofmembers->isSetSBOTerm())
922 {
923 referent->setSBOTerm(listofmembers->getSBOTerm());
924 change = true;
925 }
926 }
927
928 if (!referent->isSetNotes())
929 {
930 if (listofmembers->isSetNotes())
931 {
932 referent->setNotes(listofmembers->getNotes());
933 change = true;
934 }
935 }
936
937 if (!referent->isSetAnnotation())
938 {
939 if (listofmembers->isSetAnnotation())
940 {
941 referent->setAnnotation(listofmembers->getAnnotation());
942 change = true;
943 }
944 }
945 }
946 }
947 }
948 }
949 }
950 }
951
952
953
954 #endif /* __cplusplus */
955
956
957 /*
958 * Returns a ListOf_t * containing Group_t objects from this
959 * GroupsModelPlugin_t.
960 */
961 LIBSBML_EXTERN
962 ListOf_t*
GroupsModelPlugin_getListOfGroups(GroupsModelPlugin_t * gmp)963 GroupsModelPlugin_getListOfGroups(GroupsModelPlugin_t* gmp)
964 {
965 return (gmp != NULL) ? gmp->getListOfGroups() : NULL;
966 }
967
968
969 /*
970 * Get a Group_t from the GroupsModelPlugin_t.
971 */
972 LIBSBML_EXTERN
973 Group_t*
GroupsModelPlugin_getGroup(GroupsModelPlugin_t * gmp,unsigned int n)974 GroupsModelPlugin_getGroup(GroupsModelPlugin_t* gmp, unsigned int n)
975 {
976 return (gmp != NULL) ? gmp->getGroup(n) : NULL;
977 }
978
979
980 /*
981 * Get a Group_t from the GroupsModelPlugin_t based on its identifier.
982 */
983 LIBSBML_EXTERN
984 Group_t*
GroupsModelPlugin_getGroupById(GroupsModelPlugin_t * gmp,const char * sid)985 GroupsModelPlugin_getGroupById(GroupsModelPlugin_t* gmp, const char *sid)
986 {
987 return (gmp != NULL && sid != NULL) ? gmp->getGroup(sid) : NULL;
988 }
989
990
991 /*
992 * Adds a copy of the given Group_t to this GroupsModelPlugin_t.
993 */
994 LIBSBML_EXTERN
995 int
GroupsModelPlugin_addGroup(GroupsModelPlugin_t * gmp,const Group_t * g)996 GroupsModelPlugin_addGroup(GroupsModelPlugin_t* gmp, const Group_t* g)
997 {
998 return (gmp != NULL) ? gmp->addGroup(g) : LIBSBML_INVALID_OBJECT;
999 }
1000
1001
1002 /*
1003 * Get the number of Group_t objects in this GroupsModelPlugin_t.
1004 */
1005 LIBSBML_EXTERN
1006 unsigned int
GroupsModelPlugin_getNumGroups(GroupsModelPlugin_t * gmp)1007 GroupsModelPlugin_getNumGroups(GroupsModelPlugin_t* gmp)
1008 {
1009 return (gmp != NULL) ? gmp->getNumGroups() : SBML_INT_MAX;
1010 }
1011
1012
1013 /*
1014 * Creates a new Group_t object, adds it to this GroupsModelPlugin_t object and
1015 * returns the Group_t object created.
1016 */
1017 LIBSBML_EXTERN
1018 Group_t*
GroupsModelPlugin_createGroup(GroupsModelPlugin_t * gmp)1019 GroupsModelPlugin_createGroup(GroupsModelPlugin_t* gmp)
1020 {
1021 return (gmp != NULL) ? gmp->createGroup() : NULL;
1022 }
1023
1024
1025 /*
1026 * Removes the nth Group_t from this GroupsModelPlugin_t and returns a pointer
1027 * to it.
1028 */
1029 LIBSBML_EXTERN
1030 Group_t*
GroupsModelPlugin_removeGroup(GroupsModelPlugin_t * gmp,unsigned int n)1031 GroupsModelPlugin_removeGroup(GroupsModelPlugin_t* gmp, unsigned int n)
1032 {
1033 return (gmp != NULL) ? gmp->removeGroup(n) : NULL;
1034 }
1035
1036
1037 /*
1038 * Removes the Group_t from this GroupsModelPlugin_t based on its identifier
1039 * and returns a pointer to it.
1040 */
1041 LIBSBML_EXTERN
1042 Group_t*
GroupsModelPlugin_removeGroupById(GroupsModelPlugin_t * gmp,const char * sid)1043 GroupsModelPlugin_removeGroupById(GroupsModelPlugin_t* gmp, const char* sid)
1044 {
1045 return (gmp != NULL && sid != NULL) ? gmp->removeGroup(sid) : NULL;
1046 }
1047
1048
1049
1050
1051 LIBSBML_CPP_NAMESPACE_END
1052
1053
1054