1 /**
2 * @file FbcReactionPlugin.cpp
3 * @brief Implementation of the FbcReactionPlugin 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
37 * the Free Software Foundation. A copy of the license agreement is provided
38 * in the file named "LICENSE.txt" included with this software distribution
39 * and also available online as http://sbml.org/software/libsbml/license.html
40 * ------------------------------------------------------------------------ -->
41 */
42
43
44 #include <sbml/packages/fbc/extension/FbcReactionPlugin.h>
45 #include <sbml/packages/fbc/validator/FbcSBMLError.h>
46 #include <sbml/util/ElementFilter.h>
47 #include <sbml/Model.h>
48
49
50 using namespace std;
51
52
53 #ifdef __cplusplus
54
55
56 LIBSBML_CPP_NAMESPACE_BEGIN
57
58
59 /*
60 * Creates a new FbcReactionPlugin
61 */
FbcReactionPlugin(const std::string & uri,const std::string & prefix,FbcPkgNamespaces * fbcns)62 FbcReactionPlugin::FbcReactionPlugin(const std::string& uri,
63 const std::string& prefix,
64 FbcPkgNamespaces* fbcns) :
65 SBasePlugin(uri, prefix, fbcns)
66 , mGeneProductAssociation ( NULL )
67 , mLowerFluxBound ("")
68 , mUpperFluxBound ("")
69 {
70 }
71
72
73 /*
74 * Copy constructor for FbcReactionPlugin.
75 */
FbcReactionPlugin(const FbcReactionPlugin & orig)76 FbcReactionPlugin::FbcReactionPlugin(const FbcReactionPlugin& orig) :
77 SBasePlugin(orig)
78 , mGeneProductAssociation ( NULL )
79 {
80 if (orig.mGeneProductAssociation != NULL)
81 {
82 mGeneProductAssociation = orig.mGeneProductAssociation->clone();
83 }
84 mLowerFluxBound = orig.mLowerFluxBound;
85 mUpperFluxBound = orig.mUpperFluxBound;
86 }
87
88
89 /*
90 * Assignment operator for FbcReactionPlugin.
91 */
92 FbcReactionPlugin&
operator =(const FbcReactionPlugin & rhs)93 FbcReactionPlugin::operator=(const FbcReactionPlugin& rhs)
94 {
95 if (&rhs != this)
96 {
97 this->SBasePlugin::operator=(rhs);
98 delete mGeneProductAssociation;
99 mGeneProductAssociation = NULL;
100 if (rhs.mGeneProductAssociation != NULL)
101 mGeneProductAssociation = rhs.mGeneProductAssociation->clone();
102 mLowerFluxBound = rhs.mLowerFluxBound;
103 mUpperFluxBound = rhs.mUpperFluxBound;
104 }
105
106 return *this;
107 }
108
109
110 /*
111 * Creates and returns a deep copy of this FbcReactionPlugin object.
112 */
113 FbcReactionPlugin*
clone() const114 FbcReactionPlugin::clone () const
115 {
116 return new FbcReactionPlugin(*this);
117 }
118
119
120 /*
121 * Destructor for FbcReactionPlugin.
122 */
~FbcReactionPlugin()123 FbcReactionPlugin::~FbcReactionPlugin()
124 {
125 delete mGeneProductAssociation;
126 mGeneProductAssociation = NULL;
127 }
128
129
130 //---------------------------------------------------------------
131 //
132 // overridden virtual functions for read/write/check
133 //
134 //---------------------------------------------------------------
135
136 /** @cond doxygenLibsbmlInternal */
137 /*
138 * create object
139 */
140 SBase*
createObject(XMLInputStream & stream)141 FbcReactionPlugin::createObject (XMLInputStream& stream)
142 {
143 SBase* object = NULL;
144
145 const std::string& name = stream.peek().getName();
146 const XMLNamespaces& xmlns1 = stream.peek().getNamespaces();
147 const std::string& prefix = stream.peek().getPrefix();
148
149 const std::string& targetPrefix = (xmlns1.hasURI(mURI)) ? xmlns1.getPrefix(mURI) : mPrefix;
150
151 if (prefix == targetPrefix)
152 {
153 FBC_CREATE_NS_WITH_VERSION(fbcns, getSBMLNamespaces(), getPackageVersion());
154 if (name == "geneProductAssociation" )
155 {
156 if (mGeneProductAssociation != NULL)
157 {
158 getErrorLog()->logPackageError("fbc", FbcReactionOnlyOneGeneProdAss,
159 getPackageVersion(), getLevel(), getVersion(), "", getLine(), getColumn());
160 }
161
162 delete mGeneProductAssociation;
163
164 mGeneProductAssociation = new GeneProductAssociation(fbcns);
165
166 object = mGeneProductAssociation;
167
168 }
169
170 delete fbcns;
171 }
172
173 return object;
174 }
175 /** @endcond */
176
177
178 /** @cond doxygenLibsbmlInternal */
179 /*
180 * write elements
181 */
182 void
writeElements(XMLOutputStream & stream) const183 FbcReactionPlugin::writeElements (XMLOutputStream& stream) const
184 {
185 // dont want to write <fbc:geneProductAssociation/>
186 // so check it actual has something in
187 if (isSetGeneProductAssociation() == true && getLevel() == 3
188 && getPackageVersion() == 2 && getGeneProductAssociation()->getAssociation() != NULL)
189 {
190 mGeneProductAssociation->write(stream);
191 }
192 }
193 /** @endcond */
194
195
196 /** @cond doxygenLibsbmlInternal */
197 /*
198 * Get the list of expected attributes for this element.
199 */
200 void
addExpectedAttributes(ExpectedAttributes & attributes)201 FbcReactionPlugin::addExpectedAttributes(ExpectedAttributes& attributes)
202 {
203 SBasePlugin::addExpectedAttributes(attributes);
204
205 attributes.add("lowerFluxBound");
206 attributes.add("upperFluxBound");
207 }
208
209
210 /** @endcond */
211
212
213 /** @cond doxygenLibsbmlInternal */
214
215 /*
216 * Read values from the given XMLAttributes set into their specific fields.
217 */
218 void
readAttributes(const XMLAttributes & attributes,const ExpectedAttributes & expectedAttributes)219 FbcReactionPlugin::readAttributes (const XMLAttributes& attributes,
220 const ExpectedAttributes& expectedAttributes)
221 {
222 const unsigned int sbmlLevel = getLevel ();
223 const unsigned int sbmlVersion = getVersion();
224
225 unsigned int numErrs =
226 (getErrorLog() != NULL ? getErrorLog()->getNumErrors() : 0);
227
228 SBasePlugin::readAttributes(attributes, expectedAttributes);
229
230 // look to see whether an unknown attribute error was logged
231 if (getErrorLog() != NULL)
232 {
233 unsigned newNumErrs = getErrorLog()->getNumErrors();
234 if (newNumErrs != numErrs)
235 {
236 for (unsigned int n = newNumErrs; n > numErrs; n--)
237 {
238 const SBMLError* err = getErrorLog()->getError(n-1);
239 if (err->getErrorId() == UnknownPackageAttribute)
240 {
241 const std::string details = err->getMessage();
242 getErrorLog()->remove(UnknownPackageAttribute);
243 getErrorLog()->logPackageError("fbc", FbcReactionAllowedAttributes,
244 getPackageVersion(), sbmlLevel, sbmlVersion, details,
245 getLine(), getColumn());
246 }
247 else if (err->getErrorId() == UnknownCoreAttribute)
248 {
249 const std::string details = err->getMessage();
250 getErrorLog()->remove(UnknownCoreAttribute);
251 getErrorLog()->logPackageError("fbc", FbcReactionAllowedAttributes,
252 getPackageVersion(), sbmlLevel, sbmlVersion, details,
253 getLine(), getColumn());
254 }
255 else if (err->getErrorId() == NotSchemaConformant)
256 {
257 const std::string details = err->getMessage();
258 getErrorLog()->remove(NotSchemaConformant);
259 getErrorLog()->logPackageError("fbc", FbcReactionAllowedAttributes,
260 getPackageVersion(), sbmlLevel, sbmlVersion, details,
261 getLine(), getColumn());
262 }
263 }
264 }
265 }
266
267 bool assigned = false;
268
269 //
270 // lowerFluxBound SIdRef ( use = "optional" )
271 //
272 assigned = attributes.readInto("lowerFluxBound", mLowerFluxBound);
273
274 if (assigned == true)
275 {
276 // check string is not empty and correct syntax
277
278 if (mLowerFluxBound.empty() == true)
279 {
280 logEmptyString(mLowerFluxBound, getLevel(), getVersion(),
281 getPackageVersion(), "<Reaction>");
282 }
283 else if (SyntaxChecker::isValidSBMLSId(mLowerFluxBound) == false
284 && getErrorLog() != NULL)
285 {
286 const std::string details = "The syntax of the attribute "
287 "lowerFluxBound='" + mLowerFluxBound + "' does not conform.";
288 getErrorLog()->logPackageError("fbc", FbcReactionLwrBoundSIdRef,
289 getPackageVersion(), sbmlLevel, sbmlVersion, details,
290 getLine(), getColumn());
291 }
292 }
293
294 //
295 // upperFluxBound SIdRef ( use = "optional" )
296 //
297 assigned = attributes.readInto("upperFluxBound", mUpperFluxBound);
298
299 if (assigned == true)
300 {
301 // check string is not empty and correct syntax
302
303 if (mUpperFluxBound.empty() == true)
304 {
305 logEmptyString(mUpperFluxBound, getLevel(), getVersion(),
306 getPackageVersion(), "<Reaction>");
307 }
308 else if (SyntaxChecker::isValidSBMLSId(mUpperFluxBound) == false && getErrorLog() != NULL)
309 {
310 const std::string details = "The syntax of the attribute "
311 "upperFluxBound='" + mUpperFluxBound + "' does not conform.";
312 getErrorLog()->logPackageError("fbc", FbcReactionUpBoundSIdRef,
313 getPackageVersion(), sbmlLevel, sbmlVersion, details,
314 getLine(), getColumn());
315 }
316 }
317
318 }
319 /** @endcond */
320
321 /** @cond doxygenLibsbmlInternal */
322 void
renameSIdRefs(const std::string & oldid,const std::string & newid)323 FbcReactionPlugin::renameSIdRefs(const std::string& oldid, const std::string& newid)
324 {
325 SBasePlugin::renameSIdRefs(oldid, newid);
326 if (isSetLowerFluxBound())
327 {
328 if (mLowerFluxBound==oldid) mLowerFluxBound=newid;
329 }
330 if (isSetUpperFluxBound())
331 {
332 if (mUpperFluxBound==oldid) mUpperFluxBound=newid;
333 }
334 }
335 /** @endcond */
336
337
338 /** @cond doxygenLibsbmlInternal */
339 /*
340 * Write values of XMLAttributes to the output stream.
341 */
342 void
writeAttributes(XMLOutputStream & stream) const343 FbcReactionPlugin::writeAttributes (XMLOutputStream& stream) const
344 {
345 if (getPackageVersion() == 1) return;
346
347 SBasePlugin::writeAttributes(stream);
348
349 if (isSetLowerFluxBound() == true)
350 stream.writeAttribute("lowerFluxBound", getPrefix(), mLowerFluxBound);
351
352 if (isSetUpperFluxBound() == true)
353 stream.writeAttribute("upperFluxBound", getPrefix(), mUpperFluxBound);
354
355 }
356 /** @endcond */
357
358
359 //---------------------------------------------------------------
360 //
361 // Functions for interacting with the members of the plugin
362 //
363 //---------------------------------------------------------------
364
365 List*
getAllElements(ElementFilter * filter)366 FbcReactionPlugin::getAllElements(ElementFilter* filter)
367 {
368 List* ret = new List();
369 List* sublist = NULL;
370
371 ADD_FILTERED_POINTER(ret, sublist, mGeneProductAssociation, filter);
372
373 return ret;
374 }
375
376
377 /*
378 * Returns the GeneProductAssociation from this FbcReactionPlugin object.
379 */
380 const GeneProductAssociation*
getGeneProductAssociation() const381 FbcReactionPlugin::getGeneProductAssociation () const
382 {
383 return mGeneProductAssociation;
384 }
385
386
387 /*
388 * Returns the GeneProductAssociation from this FbcReactionPlugin object.
389 */
390 GeneProductAssociation*
getGeneProductAssociation()391 FbcReactionPlugin::getGeneProductAssociation ()
392 {
393 return mGeneProductAssociation;
394 }
395
396
397 /*
398 * @return @c true if the "GeneProductAssociation" element has been set,
399 */
400 bool
isSetGeneProductAssociation() const401 FbcReactionPlugin::isSetGeneProductAssociation () const
402 {
403 return (mGeneProductAssociation != NULL);
404 }
405
406
407 /*
408 * Sets the GeneProductAssociation element in this FbcReactionPlugin object.
409 */
410 int
setGeneProductAssociation(const GeneProductAssociation * geneProductAssociation)411 FbcReactionPlugin::setGeneProductAssociation(const GeneProductAssociation* geneProductAssociation)
412 {
413 if (geneProductAssociation == NULL)
414 {
415 return LIBSBML_OPERATION_FAILED;
416 }
417 else if (geneProductAssociation->hasRequiredElements() == false)
418 {
419 return LIBSBML_INVALID_OBJECT;
420 }
421 else if (getLevel() != geneProductAssociation->getLevel())
422 {
423 return LIBSBML_LEVEL_MISMATCH;
424 }
425 else if (getVersion() != geneProductAssociation->getVersion())
426 {
427 return LIBSBML_VERSION_MISMATCH;
428 }
429 else if (getPackageVersion() != geneProductAssociation->getPackageVersion())
430 {
431 return LIBSBML_PKG_VERSION_MISMATCH;
432 }
433 else
434 {
435 delete mGeneProductAssociation;
436 mGeneProductAssociation = static_cast<GeneProductAssociation*>(geneProductAssociation->clone());
437 if (mGeneProductAssociation != NULL) mGeneProductAssociation->connectToParent(this->getParentSBMLObject());
438
439 return LIBSBML_OPERATION_SUCCESS;
440 }
441 }
442
443
444 /*
445 * Creates a new GeneProductAssociation object and adds it to the FbcReactionPlugin object.
446 */
447 GeneProductAssociation*
createGeneProductAssociation()448 FbcReactionPlugin::createGeneProductAssociation()
449 {
450 delete mGeneProductAssociation;
451 FBC_CREATE_NS_WITH_VERSION(fbcns, getSBMLNamespaces(), getPackageVersion());
452 mGeneProductAssociation = new GeneProductAssociation(fbcns);
453
454 mGeneProductAssociation->setSBMLDocument(this->getSBMLDocument());
455
456 delete fbcns;
457
458 return mGeneProductAssociation;
459 }
460
461
462 /*
463 * Returns the value of the "lowerFluxBound" attribute of this FbcReactionPlugin.
464 */
465 const std::string&
getLowerFluxBound() const466 FbcReactionPlugin::getLowerFluxBound() const
467 {
468 return mLowerFluxBound;
469 }
470
471
472 /*
473 * Returns the value of the "upperFluxBound" attribute of this FbcReactionPlugin.
474 */
475 const std::string&
getUpperFluxBound() const476 FbcReactionPlugin::getUpperFluxBound() const
477 {
478 return mUpperFluxBound;
479 }
480
481
482 /*
483 * Returns true/false if lowerFluxBound is set.
484 */
485 bool
isSetLowerFluxBound() const486 FbcReactionPlugin::isSetLowerFluxBound() const
487 {
488 return (mLowerFluxBound.empty() == false);
489 }
490
491
492 /*
493 * Returns true/false if upperFluxBound is set.
494 */
495 bool
isSetUpperFluxBound() const496 FbcReactionPlugin::isSetUpperFluxBound() const
497 {
498 return (mUpperFluxBound.empty() == false);
499 }
500
501
502 /*
503 * Sets lowerFluxBound and returns value indicating success.
504 */
505 int
setLowerFluxBound(const std::string & lowerFluxBound)506 FbcReactionPlugin::setLowerFluxBound(const std::string& lowerFluxBound)
507 {
508 if (!(SyntaxChecker::isValidInternalSId(lowerFluxBound)))
509 {
510 return LIBSBML_INVALID_ATTRIBUTE_VALUE;
511 }
512 else
513 {
514 mLowerFluxBound = lowerFluxBound;
515 return LIBSBML_OPERATION_SUCCESS;
516 }
517 }
518
519
520 /*
521 * Sets upperFluxBound and returns value indicating success.
522 */
523 int
setUpperFluxBound(const std::string & upperFluxBound)524 FbcReactionPlugin::setUpperFluxBound(const std::string& upperFluxBound)
525 {
526 if (!(SyntaxChecker::isValidInternalSId(upperFluxBound)))
527 {
528 return LIBSBML_INVALID_ATTRIBUTE_VALUE;
529 }
530 else
531 {
532 mUpperFluxBound = upperFluxBound;
533 return LIBSBML_OPERATION_SUCCESS;
534 }
535 }
536
537
538 /*
539 * Unsets lowerFluxBound and returns value indicating success.
540 */
541 int
unsetLowerFluxBound()542 FbcReactionPlugin::unsetLowerFluxBound()
543 {
544 mLowerFluxBound.erase();
545
546 if (mLowerFluxBound.empty() == true)
547 {
548 return LIBSBML_OPERATION_SUCCESS;
549 }
550 else
551 {
552 return LIBSBML_OPERATION_FAILED;
553 }
554 }
555
556
557 /*
558 * Unsets upperFluxBound and returns value indicating success.
559 */
560 int
unsetUpperFluxBound()561 FbcReactionPlugin::unsetUpperFluxBound()
562 {
563 mUpperFluxBound.erase();
564
565 if (mUpperFluxBound.empty() == true)
566 {
567 return LIBSBML_OPERATION_SUCCESS;
568 }
569 else
570 {
571 return LIBSBML_OPERATION_FAILED;
572 }
573 }
574
575 int
unsetGeneProductAssociation()576 FbcReactionPlugin::unsetGeneProductAssociation()
577 {
578 if (isSetGeneProductAssociation())
579 delete mGeneProductAssociation;
580 mGeneProductAssociation = NULL;
581 return LIBSBML_OPERATION_SUCCESS;
582 }
583
584 //---------------------------------------------------------------
585
586
587 /** @cond doxygenLibsbmlInternal */
588 /*
589 * Set the SBMLDocument.
590 */
591 void
setSBMLDocument(SBMLDocument * d)592 FbcReactionPlugin::setSBMLDocument(SBMLDocument* d)
593 {
594 SBasePlugin::setSBMLDocument(d);
595
596 if (isSetGeneProductAssociation() == true)
597 {
598 mGeneProductAssociation->setSBMLDocument(d);
599 }
600 }
601 /** @endcond */
602
603
604 /** @cond doxygenLibsbmlInternal */
605 /*
606 * Connect to parent.
607 */
608 void
connectToParent(SBase * sbase)609 FbcReactionPlugin::connectToParent(SBase* sbase)
610 {
611 SBasePlugin::connectToParent(sbase);
612
613 if (isSetGeneProductAssociation() == true)
614 {
615 mGeneProductAssociation->connectToParent(sbase);
616 }
617 }
618 /** @endcond */
619
620
621 /** @cond doxygenLibsbmlInternal */
622 /*
623 * Enables the given package.
624 */
625 void
enablePackageInternal(const std::string & pkgURI,const std::string & pkgPrefix,bool flag)626 FbcReactionPlugin::enablePackageInternal(const std::string& pkgURI,
627 const std::string& pkgPrefix, bool flag)
628 {
629 if (isSetGeneProductAssociation() == true)
630 {
631 mGeneProductAssociation->enablePackageInternal(pkgURI, pkgPrefix, flag);
632 }
633 }
634 /** @endcond */
635
636 /** @cond doxygenLibsbmlInternal */
637
638 /*
639 * Returns the value of the "attributeName" attribute of this FbcReactionPlugin.
640 */
641 int
getAttribute(const std::string & attributeName,bool & value) const642 FbcReactionPlugin::getAttribute(const std::string& attributeName,
643 bool& value) const
644 {
645 int return_value = SBasePlugin::getAttribute(attributeName, value);
646
647 return return_value;
648 }
649
650 /** @endcond */
651
652
653
654 /** @cond doxygenLibsbmlInternal */
655
656 /*
657 * Returns the value of the "attributeName" attribute of this FbcReactionPlugin.
658 */
659 int
getAttribute(const std::string & attributeName,int & value) const660 FbcReactionPlugin::getAttribute(const std::string& attributeName,
661 int& value) const
662 {
663 int return_value = SBasePlugin::getAttribute(attributeName, value);
664
665 return return_value;
666 }
667
668 /** @endcond */
669
670
671
672 /** @cond doxygenLibsbmlInternal */
673
674 /*
675 * Returns the value of the "attributeName" attribute of this FbcReactionPlugin.
676 */
677 int
getAttribute(const std::string & attributeName,double & value) const678 FbcReactionPlugin::getAttribute(const std::string& attributeName,
679 double& value) const
680 {
681 int return_value = SBasePlugin::getAttribute(attributeName, value);
682
683 return return_value;
684 }
685
686 /** @endcond */
687
688
689
690 /** @cond doxygenLibsbmlInternal */
691
692 /*
693 * Returns the value of the "attributeName" attribute of this FbcReactionPlugin.
694 */
695 int
getAttribute(const std::string & attributeName,unsigned int & value) const696 FbcReactionPlugin::getAttribute(const std::string& attributeName,
697 unsigned int& value) const
698 {
699 int return_value = SBasePlugin::getAttribute(attributeName, value);
700
701 return return_value;
702 }
703
704 /** @endcond */
705
706
707
708 /** @cond doxygenLibsbmlInternal */
709
710 /*
711 * Returns the value of the "attributeName" attribute of this FbcReactionPlugin.
712 */
713 int
getAttribute(const std::string & attributeName,std::string & value) const714 FbcReactionPlugin::getAttribute(const std::string& attributeName,
715 std::string& value) const
716 {
717 int return_value = SBasePlugin::getAttribute(attributeName, value);
718
719 if (return_value == LIBSBML_OPERATION_SUCCESS)
720 {
721 return return_value;
722 }
723
724 if (attributeName == "lowerFluxBound")
725 {
726 value = getLowerFluxBound();
727 return_value = LIBSBML_OPERATION_SUCCESS;
728 }
729 else if (attributeName == "upperFluxBound")
730 {
731 value = getUpperFluxBound();
732 return_value = LIBSBML_OPERATION_SUCCESS;
733 }
734
735 return return_value;
736 }
737
738 /** @endcond */
739
740
741
742 /** @cond doxygenLibsbmlInternal */
743
744 /*
745 * Predicate returning @c true if this FbcReactionPlugin's attribute
746 * "attributeName" is set.
747 */
748 bool
isSetAttribute(const std::string & attributeName) const749 FbcReactionPlugin::isSetAttribute(const std::string& attributeName) const
750 {
751 bool value = SBasePlugin::isSetAttribute(attributeName);
752
753 if (attributeName == "lowerFluxBound")
754 {
755 value = isSetLowerFluxBound();
756 }
757 else if (attributeName == "upperFluxBound")
758 {
759 value = isSetUpperFluxBound();
760 }
761
762 return value;
763 }
764
765 /** @endcond */
766
767
768
769 /** @cond doxygenLibsbmlInternal */
770
771 /*
772 * Sets the value of the "attributeName" attribute of this FbcReactionPlugin.
773 */
774 int
setAttribute(const std::string & attributeName,bool value)775 FbcReactionPlugin::setAttribute(const std::string& attributeName, bool value)
776 {
777 int return_value = SBasePlugin::setAttribute(attributeName, value);
778
779 return return_value;
780 }
781
782 /** @endcond */
783
784
785
786 /** @cond doxygenLibsbmlInternal */
787
788 /*
789 * Sets the value of the "attributeName" attribute of this FbcReactionPlugin.
790 */
791 int
setAttribute(const std::string & attributeName,int value)792 FbcReactionPlugin::setAttribute(const std::string& attributeName, int value)
793 {
794 int return_value = SBasePlugin::setAttribute(attributeName, value);
795
796 return return_value;
797 }
798
799 /** @endcond */
800
801
802
803 /** @cond doxygenLibsbmlInternal */
804
805 /*
806 * Sets the value of the "attributeName" attribute of this FbcReactionPlugin.
807 */
808 int
setAttribute(const std::string & attributeName,double value)809 FbcReactionPlugin::setAttribute(const std::string& attributeName,
810 double value)
811 {
812 int return_value = SBasePlugin::setAttribute(attributeName, value);
813
814 return return_value;
815 }
816
817 /** @endcond */
818
819
820
821 /** @cond doxygenLibsbmlInternal */
822
823 /*
824 * Sets the value of the "attributeName" attribute of this FbcReactionPlugin.
825 */
826 int
setAttribute(const std::string & attributeName,unsigned int value)827 FbcReactionPlugin::setAttribute(const std::string& attributeName,
828 unsigned int value)
829 {
830 int return_value = SBasePlugin::setAttribute(attributeName, value);
831
832 return return_value;
833 }
834
835 /** @endcond */
836
837
838
839 /** @cond doxygenLibsbmlInternal */
840
841 /*
842 * Sets the value of the "attributeName" attribute of this FbcReactionPlugin.
843 */
844 int
setAttribute(const std::string & attributeName,const std::string & value)845 FbcReactionPlugin::setAttribute(const std::string& attributeName,
846 const std::string& value)
847 {
848 int return_value = SBasePlugin::setAttribute(attributeName, value);
849
850 if (attributeName == "lowerFluxBound")
851 {
852 return_value = setLowerFluxBound(value);
853 }
854 else if (attributeName == "upperFluxBound")
855 {
856 return_value = setUpperFluxBound(value);
857 }
858
859 return return_value;
860 }
861
862 /** @endcond */
863
864
865
866 /** @cond doxygenLibsbmlInternal */
867
868 /*
869 * Unsets the value of the "attributeName" attribute of this FbcReactionPlugin.
870 */
871 int
unsetAttribute(const std::string & attributeName)872 FbcReactionPlugin::unsetAttribute(const std::string& attributeName)
873 {
874 int value = SBasePlugin::unsetAttribute(attributeName);
875
876 if (attributeName == "lowerFluxBound")
877 {
878 value = unsetLowerFluxBound();
879 }
880 else if (attributeName == "upperFluxBound")
881 {
882 value = unsetUpperFluxBound();
883 }
884
885 return value;
886 }
887
888 /** @endcond */
889
890
891
892 /** @cond doxygenLibsbmlInternal */
893
894 /*
895 * Creates and returns an new "elementName" object in this FbcReactionPlugin.
896 */
897 SBase*
createChildObject(const std::string & elementName)898 FbcReactionPlugin::createChildObject(const std::string& elementName)
899 {
900 SBase* obj = NULL;
901
902 if (elementName == "geneProductAssociation")
903 {
904 return createGeneProductAssociation();
905 }
906
907 return obj;
908 }
909
910 /** @endcond */
911
912
913
914 /** @cond doxygenLibsbmlInternal */
915
916 /*
917 * Returns the number of "elementName" in this FbcReactionPlugin.
918 */
919 unsigned int
getNumObjects(const std::string & elementName)920 FbcReactionPlugin::getNumObjects(const std::string& elementName)
921 {
922 unsigned int n = 0;
923
924 if (elementName == "geneProductAssociation")
925 {
926 if (isSetGeneProductAssociation())
927 {
928 return 1;
929 }
930 }
931
932 return n;
933 }
934
935 /** @endcond */
936
937
938
939 /** @cond doxygenLibsbmlInternal */
940
941 /*
942 * Returns the nth object of "objectName" in this FbcReactionPlugin.
943 */
944 SBase*
getObject(const std::string & elementName,unsigned int index)945 FbcReactionPlugin::getObject(const std::string& elementName,
946 unsigned int index)
947 {
948 SBase* obj = NULL;
949
950 if (elementName == "geneProductAssociation")
951 {
952 return getGeneProductAssociation();
953 }
954
955 return obj;
956 }
957
958 /** @endcond */
959
960 /** @cond doxygenLibsbmlInternal */
961
962 /*
963 * Accept the SBMLVisitor.
964 */
965 bool
accept(SBMLVisitor & v) const966 FbcReactionPlugin::accept(SBMLVisitor& v) const
967 {
968 const Reaction * r = static_cast<const Reaction * >(this->getParentSBMLObject());
969
970 v.visit(*r);
971
972 for (unsigned int n = 0; n < r->getNumReactants(); n++)
973 {
974 v.visit(*(r->getReactant(n)));
975 }
976
977 for (unsigned int n = 0; n < r->getNumProducts(); n++)
978 {
979 v.visit(*(r->getProduct(n)));
980 }
981
982 v.leave(*r);
983
984 if (mGeneProductAssociation != NULL) mGeneProductAssociation->accept(v);
985
986 return true;
987 }
988 /** @endcond */
989
990
991
992
993
994 #endif /* __cplusplus */
995
996
997 LIBSBML_EXTERN
998 char *
FbcReactionPlugin_getUpperFluxBound(SBasePlugin_t * fbc)999 FbcReactionPlugin_getUpperFluxBound(SBasePlugin_t * fbc)
1000 {
1001 if (fbc == NULL) return NULL;
1002
1003 return static_cast<FbcReactionPlugin*>(fbc)->getUpperFluxBound().empty()
1004 ? safe_strdup("")
1005 : safe_strdup(static_cast<FbcReactionPlugin*>(fbc)->getUpperFluxBound().c_str());
1006 }
1007
1008
1009 LIBSBML_EXTERN
1010 int
FbcReactionPlugin_isSetUpperFluxBound(SBasePlugin_t * fbc)1011 FbcReactionPlugin_isSetUpperFluxBound(SBasePlugin_t * fbc)
1012 {
1013 return (fbc != NULL)
1014 ? static_cast<int>
1015 (static_cast<FbcReactionPlugin*>(fbc)->isSetUpperFluxBound())
1016 : 0;
1017 }
1018
1019
1020 LIBSBML_EXTERN
1021 int
FbcReactionPlugin_setUpperFluxBound(SBasePlugin_t * fbc,const char * chemform)1022 FbcReactionPlugin_setUpperFluxBound(SBasePlugin_t * fbc, const char * chemform)
1023 {
1024 return (fbc != NULL)
1025 ? static_cast<FbcReactionPlugin*>(fbc)->setUpperFluxBound(chemform)
1026 : LIBSBML_INVALID_OBJECT;
1027 }
1028
1029
1030 LIBSBML_EXTERN
1031 int
FbcReactionPlugin_unsetUpperFluxBound(SBasePlugin_t * fbc)1032 FbcReactionPlugin_unsetUpperFluxBound(SBasePlugin_t * fbc)
1033 {
1034 return (fbc != NULL)
1035 ? static_cast<FbcReactionPlugin*>(fbc)->unsetUpperFluxBound()
1036 : LIBSBML_INVALID_OBJECT;
1037 }
1038
1039
1040 LIBSBML_EXTERN
1041 char *
FbcReactionPlugin_getLowerFluxBound(SBasePlugin_t * fbc)1042 FbcReactionPlugin_getLowerFluxBound(SBasePlugin_t * fbc)
1043 {
1044 if (fbc == NULL) return NULL;
1045
1046 return static_cast<FbcReactionPlugin*>(fbc)->getLowerFluxBound().empty()
1047 ? safe_strdup("")
1048 : safe_strdup(static_cast<FbcReactionPlugin*>(fbc)->getLowerFluxBound().c_str());
1049 }
1050
1051
1052 LIBSBML_EXTERN
1053 int
FbcReactionPlugin_isSetLowerFluxBound(SBasePlugin_t * fbc)1054 FbcReactionPlugin_isSetLowerFluxBound(SBasePlugin_t * fbc)
1055 {
1056 return (fbc != NULL)
1057 ? static_cast<int>
1058 (static_cast<FbcReactionPlugin*>(fbc)->isSetLowerFluxBound())
1059 : 0;
1060 }
1061
1062
1063 LIBSBML_EXTERN
1064 int
FbcReactionPlugin_setLowerFluxBound(SBasePlugin_t * fbc,const char * chemform)1065 FbcReactionPlugin_setLowerFluxBound(SBasePlugin_t * fbc, const char * chemform)
1066 {
1067 return (fbc != NULL)
1068 ? static_cast<FbcReactionPlugin*>(fbc)->setLowerFluxBound(chemform)
1069 : LIBSBML_INVALID_OBJECT;
1070 }
1071
1072
1073 LIBSBML_EXTERN
1074 int
FbcReactionPlugin_unsetLowerFluxBound(SBasePlugin_t * fbc)1075 FbcReactionPlugin_unsetLowerFluxBound(SBasePlugin_t * fbc)
1076 {
1077 return (fbc != NULL)
1078 ? static_cast<FbcReactionPlugin*>(fbc)->unsetLowerFluxBound()
1079 : LIBSBML_INVALID_OBJECT;
1080 }
1081
1082
1083 LIBSBML_EXTERN
1084 int
FbcReactionPlugin_isSetGeneProductAssociation(SBasePlugin_t * fbc)1085 FbcReactionPlugin_isSetGeneProductAssociation(SBasePlugin_t * fbc)
1086 {
1087 return (fbc != NULL)
1088 ? static_cast<int>
1089 (static_cast<FbcReactionPlugin*>(fbc)->isSetGeneProductAssociation())
1090 : 0;
1091 }
1092
1093
1094 LIBSBML_EXTERN
1095 GeneProductAssociation_t*
FbcReactionPlugin_getGeneProductAssociation(SBasePlugin_t * fbc)1096 FbcReactionPlugin_getGeneProductAssociation(SBasePlugin_t * fbc)
1097 {
1098 return (fbc != NULL) ? static_cast<FbcReactionPlugin*>(fbc)->getGeneProductAssociation() : NULL;
1099
1100 }
1101
1102 LIBSBML_EXTERN
1103 int
FbcReactionPlugin_setGeneProductAssociation(SBasePlugin_t * fbc,GeneProductAssociation_t * gpa)1104 FbcReactionPlugin_setGeneProductAssociation(SBasePlugin_t * fbc,
1105 GeneProductAssociation_t* gpa)
1106 {
1107 return (fbc != NULL)
1108 ? static_cast<FbcReactionPlugin*>(fbc)->setGeneProductAssociation(gpa)
1109 : LIBSBML_INVALID_OBJECT;
1110 }
1111
1112
1113
1114
1115 LIBSBML_CPP_NAMESPACE_END
1116
1117