-
Notifications
You must be signed in to change notification settings - Fork 28
/
FbcSpeciesPlugin.cpp
996 lines (781 loc) · 20.4 KB
/
FbcSpeciesPlugin.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
/**
* @file FbcSpeciesPlugin.cpp
* @brief Implementation of FbcSpeciesPlugin, the plugin class of
* the fbc package for the Species element.
* @author Frank T. Bergmann
*
*<!---------------------------------------------------------------------------
* This file is part of libSBML. Please visit http://sbml.org for more
* information about SBML, and the latest version of libSBML.
*
* Copyright (C) 2020 jointly by the following organizations:
* 1. California Institute of Technology, Pasadena, CA, USA
* 2. University of Heidelberg, Heidelberg, Germany
* 3. University College London, London, UK
*
* Copyright (C) 2019 jointly by the following organizations:
* 1. California Institute of Technology, Pasadena, CA, USA
* 2. University of Heidelberg, Heidelberg, Germany
*
* Copyright (C) 2013-2018 jointly by the following organizations:
* 1. California Institute of Technology, Pasadena, CA, USA
* 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
* 3. University of Heidelberg, Heidelberg, Germany
*
* Copyright (C) 2009-2013 jointly by the following organizations:
* 1. California Institute of Technology, Pasadena, CA, USA
* 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation. A copy of the license agreement is provided
* in the file named "LICENSE.txt" included with this software distribution
* and also available online as http://sbml.org/software/libsbml/license.html
*------------------------------------------------------------------------- -->
*/
#include <sbml/packages/fbc/extension/FbcSpeciesPlugin.h>
#include <sbml/packages/fbc/validator/FbcSBMLError.h>
#include <sbml/util/ElementFilter.h>
#include <sbml/Model.h>
#include <iostream>
using namespace std;
LIBSBML_CPP_NAMESPACE_BEGIN
#ifdef __cplusplus
bool
isWellFormedChemicalFormula(const std::string& chemicalFormula)
{
size_t index = 0;
size_t sizeStr = chemicalFormula.size();
char c = chemicalFormula[index];
bool valid = true;
// first must be a capital letter
if (isupper(c) == 0)
{
valid = false;
return valid;
}
if (sizeStr == 1)
{
return valid;
}
index++;
bool prevNum = false;
while (valid && index < sizeStr)
{
c = chemicalFormula[index];
// if it is a letter it should be
// upper if it follows a nume
if (isalpha(c) != 0)
{
if (prevNum)
{
if (isupper(c) == 0)
{
valid = false;
}
}
prevNum = false;
}
else
{
prevNum = true;
}
index++;
}
return valid;
}
static void
parseChemicalFormula(std::string& chemicalFormula,
SBMLErrorLog& errLog, unsigned int packageVersion,
unsigned int level, unsigned int version,
unsigned int line=0, unsigned int col=0,
Species* species = NULL)
{
std::vector< std::pair< std::string, int > > chemicalSymbols;
int chemicalNumber;
size_t index = 0;
size_t sizeStr = chemicalFormula.size();
char c = chemicalFormula[index];
while (index < sizeStr)
{
stringstream elementName;
stringstream elementCount;
if (isupper(c) == 0)
{
std::string message = "Encountered '";
message += c;
message += "' when expecting a capital letter.";
if (species)
{
message += "The chemicalFormula '";
message += chemicalFormula;
if (species->isSetId())
{
message += "' for the species with id '";
message += species->getId();
}
message += "' has incorrect syntax.";
}
errLog.logPackageError("fbc", FbcSpeciesFormulaMustBeString,
packageVersion, level, version, message, line, col);
// at this point we already *know* the formula is bad, at this point
// the map generated would be invalid in any case, so we quit here.
return;
}
else
{
elementName << c;
index++;
}
// next char
if (index < sizeStr)
{
c = chemicalFormula[index];
// is it a letter
while (islower(c) != 0 && index < sizeStr)
{
elementName << c;
index++;
if (index < sizeStr)
{
c = chemicalFormula[index];
}
else
{
break;
}
}
// is the next char a number
while (isdigit(c) != 0 && index < sizeStr)
{
elementCount << c;
index++;
if (index < sizeStr)
{
c = chemicalFormula[index];
}
else
{
break;
}
}
}
const string& chemicalName = elementName.str();
const string& chemicalNum = elementCount.str();
// create the pair
if (chemicalNum.empty() == true)
{
chemicalNumber = 1;
}
else
{
chemicalNumber = atoi(chemicalNum.c_str());
}
chemicalSymbols.push_back(make_pair(chemicalName, chemicalNumber));
}
}
/*
* Creates a new FbcSpeciesPlugin
*/
FbcSpeciesPlugin::FbcSpeciesPlugin(const std::string& uri,
const std::string& prefix,
FbcPkgNamespaces* fbcns) :
FbcSBasePlugin(uri, prefix, fbcns)
, mCharge (0)
, mChargeAsDouble (0.0)
, mIsSetCharge (false)
, mChemicalFormula ("")
{
}
/*
* Copy constructor for FbcSpeciesPlugin.
*/
FbcSpeciesPlugin::FbcSpeciesPlugin(const FbcSpeciesPlugin& orig)
: FbcSBasePlugin(orig)
, mCharge(orig.mCharge)
, mChargeAsDouble(orig.mChargeAsDouble)
, mIsSetCharge(orig.mIsSetCharge)
, mChemicalFormula(orig.mChemicalFormula)
{
}
/*
* Assignment operator for FbcSpeciesPlugin.
*/
FbcSpeciesPlugin&
FbcSpeciesPlugin::operator=(const FbcSpeciesPlugin& rhs)
{
if (&rhs != this)
{
this->FbcSBasePlugin::operator=(rhs);
mCharge = rhs.mCharge;
mChargeAsDouble = rhs.mChargeAsDouble;
mIsSetCharge = rhs.mIsSetCharge;
mChemicalFormula = rhs.mChemicalFormula;
}
return *this;
}
/*
* Creates and returns a deep copy of this FbcSpeciesPlugin object.
*/
FbcSpeciesPlugin*
FbcSpeciesPlugin::clone () const
{
return new FbcSpeciesPlugin(*this);
}
/*
* Destructor for FbcSpeciesPlugin.
*/
FbcSpeciesPlugin::~FbcSpeciesPlugin()
{
}
//---------------------------------------------------------------
//
// overridden virtual functions for read/write/check
//
//---------------------------------------------------------------
/** @cond doxygenLibsbmlInternal */
/*
* create object
*/
SBase*
FbcSpeciesPlugin::createObject (XMLInputStream&)
{
return NULL;
}
/** @endcond */
/** @cond doxygenLibsbmlInternal */
/*
* write elements
*/
void
FbcSpeciesPlugin::writeElements (XMLOutputStream&) const
{
}
/** @endcond */
/** @cond doxygenLibsbmlInternal */
/*
* Get the list of expected attributes for this element.
*/
void
FbcSpeciesPlugin::addExpectedAttributes(ExpectedAttributes& attributes)
{
FbcSBasePlugin::addExpectedAttributes(attributes);
attributes.add("charge");
attributes.add("chemicalFormula");
}
/** @endcond */
/** @cond doxygenLibsbmlInternal */
/*
* Read values from the given XMLAttributes set into their specific fields.
*/
void
FbcSpeciesPlugin::readAttributes (const XMLAttributes& attributes,
const ExpectedAttributes& expectedAttributes)
{
unsigned int pkgVersion = getPackageVersion();
// dont call this as all it does it log unknown attributes
// FbcSBasePlugin::readAttributes(attributes, expectedAttributes);
for (int i = 0; i < attributes.getLength(); i++)
{
std::string name = attributes.getName(i);
std::string uri = attributes.getURI(i);
if (uri != mURI) continue;
if (!expectedAttributes.hasAttribute(name))
{
getErrorLog()->logPackageError("fbc", FbcSpeciesAllowedL3Attributes,
pkgVersion, getLevel(), getVersion(), "", getLine(), getColumn());
}
}
if (mSBMLExt->getLevel(mURI) > 2)
{
XMLTriple tripleCharge("charge", mURI, mPrefix);
unsigned int numErrs = getErrorLog()->getNumErrors();
if (pkgVersion < 3)
{
mIsSetCharge = attributes.readInto(tripleCharge, mCharge, getErrorLog(),
false, getLine(), getColumn());
}
else
{
mIsSetCharge = attributes.readInto(tripleCharge, mChargeAsDouble, getErrorLog(),
false, getLine(), getColumn());
}
if (mIsSetCharge == false)
{
if (getErrorLog()->getNumErrors() == numErrs + 1 &&
getErrorLog()->contains(XMLAttributeTypeMismatch))
{
getErrorLog()->remove(XMLAttributeTypeMismatch);
if (pkgVersion < 3)
{
getErrorLog()->logPackageError("fbc", FbcSpeciesChargeMustBeInteger,
pkgVersion, getLevel(), getVersion(), "", getLine(), getColumn());
}
else
{
getErrorLog()->logPackageError("fbc", FbcSpeciesChargeMustBeDouble,
pkgVersion, getLevel(), getVersion(), "", getLine(), getColumn());
}
}
}
XMLTriple tripleChemicalFormula("chemicalFormula", mURI, mPrefix);
bool assigned = attributes.readInto(tripleChemicalFormula, mChemicalFormula);
if (assigned == true)
{
Species * s = static_cast<Species*>(getParentSBMLObject());
parseChemicalFormula(mChemicalFormula, *(getErrorLog()), pkgVersion,
getLevel(), getVersion(), getLine(), getColumn(), s);
}
}
}
/** @endcond */
/** @cond doxygenLibsbmlInternal */
/*
* Write values of XMLAttributes to the output stream.
*/
void
FbcSpeciesPlugin::writeAttributes (XMLOutputStream& stream) const
{
FbcSBasePlugin::writeAttributes(stream);
if (isSetCharge() == true)
{
if (getPackageVersion() < 3)
{
stream.writeAttribute("charge", getPrefix(), mCharge);
}
else
{
stream.writeAttribute("charge", getPrefix(), mChargeAsDouble);
}
}
if (isSetChemicalFormula() == true)
stream.writeAttribute("chemicalFormula", getPrefix(), mChemicalFormula);
}
/** @endcond */
//---------------------------------------------------------------
//
// Functions for interacting with the members of the plugin
//
//---------------------------------------------------------------
/*
* Returns the value of the "charge" attribute of this FbcSpeciesPlugin.
*/
int
FbcSpeciesPlugin::getCharge() const
{
return mCharge;
}
double
FbcSpeciesPlugin::getChargeAsDouble() const
{
return mChargeAsDouble;
}
/*
* Returns the value of the "chemicalFormula" attribute of this FbcSpeciesPlugin.
*/
const std::string&
FbcSpeciesPlugin::getChemicalFormula() const
{
return mChemicalFormula;
}
/*
* Returns true/false if charge is set.
*/
bool
FbcSpeciesPlugin::isSetCharge() const
{
return mIsSetCharge;
}
/*
* Returns true/false if chemicalFormula is set.
*/
bool
FbcSpeciesPlugin::isSetChemicalFormula() const
{
return (mChemicalFormula.empty() == false);
}
/*
* Sets charge and returns value indicating success.
*/
int
FbcSpeciesPlugin::setCharge(int charge)
{
mCharge = charge;
mIsSetCharge = true;
return LIBSBML_OPERATION_SUCCESS;
}
/*
* Sets charge and returns value indicating success.
*/
int
FbcSpeciesPlugin::setCharge(double charge)
{
mChargeAsDouble = charge;
mIsSetCharge = true;
return LIBSBML_OPERATION_SUCCESS;
}
/*
* Sets chemicalFormula and returns value indicating success.
*/
int
FbcSpeciesPlugin::setChemicalFormula(const std::string& chemicalFormula)
{
if (isWellFormedChemicalFormula(chemicalFormula))
{
mChemicalFormula = chemicalFormula;
return LIBSBML_OPERATION_SUCCESS;
}
else
{
// since not setting an invalid formula would be a change
// in behaviour I set it anyway
mChemicalFormula = chemicalFormula;
return LIBSBML_INVALID_ATTRIBUTE_VALUE;
}
}
/*
* Unsets charge and returns value indicating success.
*/
int
FbcSpeciesPlugin::unsetCharge()
{
mCharge = SBML_INT_MAX;
mChargeAsDouble = util_NaN();
mIsSetCharge = false;
if (isSetCharge() == false)
{
return LIBSBML_OPERATION_SUCCESS;
}
else
{
return LIBSBML_OPERATION_FAILED;
}
}
/*
* Unsets chemicalFormula and returns value indicating success.
*/
int
FbcSpeciesPlugin::unsetChemicalFormula()
{
mChemicalFormula.erase();
if (mChemicalFormula.empty() == true)
{
return LIBSBML_OPERATION_SUCCESS;
}
else
{
return LIBSBML_OPERATION_FAILED;
}
}
//---------------------------------------------------------------
/** @cond doxygenLibsbmlInternal */
/*
* Set the SBMLDocument.
*/
void
FbcSpeciesPlugin::setSBMLDocument(SBMLDocument* d)
{
FbcSBasePlugin::setSBMLDocument(d);
}
/** @endcond */
/** @cond doxygenLibsbmlInternal */
/*
* Connect to parent.
*/
void
FbcSpeciesPlugin::connectToParent(SBase* sbase)
{
FbcSBasePlugin::connectToParent(sbase);
}
/** @endcond */
/** @cond doxygenLibsbmlInternal */
/*
* Enables the given package.
*/
void
FbcSpeciesPlugin::enablePackageInternal(const std::string& ,
const std::string& , bool )
{
}
/** @endcond */
/** @cond doxygenLibsbmlInternal */
/*
* Accept the SBMLVisitor.
*/
bool
FbcSpeciesPlugin::accept(SBMLVisitor&) const
{
return true;
}
/** @endcond */
/** @cond doxygenLibsbmlInternal */
/*
* Returns the value of the "attributeName" attribute of this FbcSpeciesPlugin.
*/
int
FbcSpeciesPlugin::getAttribute(const std::string& attributeName,
bool& value) const
{
int return_value = FbcSBasePlugin::getAttribute(attributeName, value);
return return_value;
}
/** @endcond */
/** @cond doxygenLibsbmlInternal */
/*
* Returns the value of the "attributeName" attribute of this FbcSpeciesPlugin.
*/
int
FbcSpeciesPlugin::getAttribute(const std::string& attributeName,
int& value) const
{
int return_value = FbcSBasePlugin::getAttribute(attributeName, value);
if (return_value == LIBSBML_OPERATION_SUCCESS)
{
return return_value;
}
if (attributeName == "charge")
{
value = getCharge();
return_value = LIBSBML_OPERATION_SUCCESS;
}
return return_value;
}
/** @endcond */
/** @cond doxygenLibsbmlInternal */
/*
* Returns the value of the "attributeName" attribute of this FbcSpeciesPlugin.
*/
int
FbcSpeciesPlugin::getAttribute(const std::string& attributeName,
double& value) const
{
int return_value = FbcSBasePlugin::getAttribute(attributeName, value);
if (attributeName == "charge")
{
value = getCharge();
return_value = LIBSBML_OPERATION_SUCCESS;
}
return return_value;
}
/** @endcond */
/** @cond doxygenLibsbmlInternal */
/*
* Returns the value of the "attributeName" attribute of this FbcSpeciesPlugin.
*/
int
FbcSpeciesPlugin::getAttribute(const std::string& attributeName,
unsigned int& value) const
{
int return_value = FbcSBasePlugin::getAttribute(attributeName, value);
return return_value;
}
/** @endcond */
/** @cond doxygenLibsbmlInternal */
/*
* Returns the value of the "attributeName" attribute of this FbcSpeciesPlugin.
*/
int
FbcSpeciesPlugin::getAttribute(const std::string& attributeName,
std::string& value) const
{
int return_value = FbcSBasePlugin::getAttribute(attributeName, value);
if (return_value == LIBSBML_OPERATION_SUCCESS)
{
return return_value;
}
if (attributeName == "chemicalFormula")
{
value = getChemicalFormula();
return_value = LIBSBML_OPERATION_SUCCESS;
}
return return_value;
}
/** @endcond */
/** @cond doxygenLibsbmlInternal */
/*
* Predicate returning @c true if this FbcSpeciesPlugin's attribute
* "attributeName" is set.
*/
bool
FbcSpeciesPlugin::isSetAttribute(const std::string& attributeName) const
{
bool value = FbcSBasePlugin::isSetAttribute(attributeName);
if (attributeName == "charge")
{
value = isSetCharge();
}
else if (attributeName == "chemicalFormula")
{
value = isSetChemicalFormula();
}
return value;
}
/** @endcond */
/** @cond doxygenLibsbmlInternal */
/*
* Sets the value of the "attributeName" attribute of this FbcSpeciesPlugin.
*/
int
FbcSpeciesPlugin::setAttribute(const std::string& attributeName, bool value)
{
int return_value = FbcSBasePlugin::setAttribute(attributeName, value);
return return_value;
}
/** @endcond */
/** @cond doxygenLibsbmlInternal */
/*
* Sets the value of the "attributeName" attribute of this FbcSpeciesPlugin.
*/
int
FbcSpeciesPlugin::setAttribute(const std::string& attributeName, int value)
{
int return_value = FbcSBasePlugin::setAttribute(attributeName, value);
if (attributeName == "charge")
{
return_value = setCharge(value);
}
return return_value;
}
/** @endcond */
/** @cond doxygenLibsbmlInternal */
/*
* Sets the value of the "attributeName" attribute of this FbcSpeciesPlugin.
*/
int
FbcSpeciesPlugin::setAttribute(const std::string& attributeName, double value)
{
int return_value = FbcSBasePlugin::setAttribute(attributeName, value);
if (attributeName == "charge")
{
return_value = setCharge(value);
}
return return_value;
}
/** @endcond */
/** @cond doxygenLibsbmlInternal */
/*
* Sets the value of the "attributeName" attribute of this FbcSpeciesPlugin.
*/
int
FbcSpeciesPlugin::setAttribute(const std::string& attributeName,
unsigned int value)
{
int return_value = FbcSBasePlugin::setAttribute(attributeName, value);
return return_value;
}
/** @endcond */
/** @cond doxygenLibsbmlInternal */
/*
* Sets the value of the "attributeName" attribute of this FbcSpeciesPlugin.
*/
int
FbcSpeciesPlugin::setAttribute(const std::string& attributeName,
const std::string& value)
{
int return_value = FbcSBasePlugin::setAttribute(attributeName, value);
if (attributeName == "chemicalFormula")
{
return_value = setChemicalFormula(value);
}
return return_value;
}
/** @endcond */
/** @cond doxygenLibsbmlInternal */
/*
* Unsets the value of the "attributeName" attribute of this FbcSpeciesPlugin.
*/
int
FbcSpeciesPlugin::unsetAttribute(const std::string& attributeName)
{
int value = FbcSBasePlugin::unsetAttribute(attributeName);
if (attributeName == "charge")
{
value = unsetCharge();
}
else if (attributeName == "chemicalFormula")
{
value = unsetChemicalFormula();
}
return value;
}
/** @endcond */
#endif /* __cplusplus */
/** @cond doxygenIgnored */
LIBSBML_EXTERN
int
FbcSpeciesPlugin_getCharge(FbcSBasePlugin_t * fbc)
{
return (fbc != NULL) ? static_cast<FbcSpeciesPlugin*>(fbc)->getCharge()
: SBML_INT_MAX;
}
LIBSBML_EXTERN
double
FbcSpeciesPlugin_getChargeAsDouble(FbcSBasePlugin_t * fbc)
{
return (fbc != NULL) ? static_cast<FbcSpeciesPlugin*>(fbc)->getChargeAsDouble()
: util_NaN();
}
LIBSBML_EXTERN
int
FbcSpeciesPlugin_isSetCharge(FbcSBasePlugin_t * fbc)
{
return (fbc != NULL) ?
static_cast<int>(static_cast<FbcSpeciesPlugin*>(fbc)->isSetCharge()) : 0;
}
LIBSBML_EXTERN
int
FbcSpeciesPlugin_setCharge(FbcSBasePlugin_t * fbc, int charge)
{
return (fbc != NULL) ? static_cast<FbcSpeciesPlugin*>(fbc)->setCharge(charge)
: LIBSBML_INVALID_OBJECT;
}
LIBSBML_EXTERN
int
FbcSpeciesPlugin_setChargeAsDouble(FbcSBasePlugin_t * fbc, double charge)
{
return (fbc != NULL) ? static_cast<FbcSpeciesPlugin*>(fbc)->setCharge(charge)
: LIBSBML_INVALID_OBJECT;
}
LIBSBML_EXTERN
int
FbcSpeciesPlugin_unsetCharge(FbcSBasePlugin_t * fbc)
{
return (fbc != NULL) ? static_cast<FbcSpeciesPlugin*>(fbc)->unsetCharge()
: LIBSBML_INVALID_OBJECT;
}
LIBSBML_EXTERN
char *
FbcSpeciesPlugin_getChemicalFormula(FbcSBasePlugin_t * fbc)
{
if (fbc == NULL) return NULL;
return static_cast<FbcSpeciesPlugin*>(fbc)->getChemicalFormula().empty()
? safe_strdup("")
: safe_strdup(static_cast<FbcSpeciesPlugin*>(fbc)->getChemicalFormula().c_str());
}
LIBSBML_EXTERN
int
FbcSpeciesPlugin_isSetChemicalFormula(FbcSBasePlugin_t * fbc)
{
return (fbc != NULL)
? static_cast<int>
(static_cast<FbcSpeciesPlugin*>(fbc)->isSetChemicalFormula())
: 0;
}
LIBSBML_EXTERN
int
FbcSpeciesPlugin_setChemicalFormula(FbcSBasePlugin_t * fbc, const char * chemform)
{
return (fbc != NULL)
? static_cast<FbcSpeciesPlugin*>(fbc)->setChemicalFormula(chemform)
: LIBSBML_INVALID_OBJECT;
}
LIBSBML_EXTERN
int
FbcSpeciesPlugin_unsetChemicalFormula(FbcSBasePlugin_t * fbc)
{
return (fbc != NULL)
? static_cast<FbcSpeciesPlugin*>(fbc)->unsetChemicalFormula()
: LIBSBML_INVALID_OBJECT;
}
/** @endcond */
LIBSBML_CPP_NAMESPACE_END