libSBML C++ API  5.18.0
SBMLTypeCodes.h File Reference

Enumeration to identify SBML objects at runtime. More...

Include dependency graph for SBMLTypeCodes.h:
This graph shows which files directly or indirectly include this file:

Enumerations

enum  SBMLTypeCode_t {
  SBML_UNKNOWN = 0,
  SBML_COMPARTMENT = 1,
  SBML_COMPARTMENT_TYPE = 2,
  SBML_CONSTRAINT = 3,
  SBML_DOCUMENT = 4,
  SBML_EVENT = 5,
  SBML_EVENT_ASSIGNMENT = 6,
  SBML_FUNCTION_DEFINITION = 7,
  SBML_INITIAL_ASSIGNMENT = 8,
  SBML_KINETIC_LAW = 9,
  SBML_LIST_OF = 10,
  SBML_MODEL = 11,
  SBML_PARAMETER = 12,
  SBML_REACTION = 13,
  SBML_RULE = 14,
  SBML_SPECIES = 15,
  SBML_SPECIES_REFERENCE = 16,
  SBML_SPECIES_TYPE = 17,
  SBML_MODIFIER_SPECIES_REFERENCE = 18,
  SBML_UNIT_DEFINITION = 19,
  SBML_UNIT = 20,
  SBML_ALGEBRAIC_RULE = 21,
  SBML_ASSIGNMENT_RULE = 22,
  SBML_RATE_RULE = 23,
  SBML_SPECIES_CONCENTRATION_RULE = 24,
  SBML_COMPARTMENT_VOLUME_RULE = 25,
  SBML_PARAMETER_RULE = 26,
  SBML_TRIGGER = 27,
  SBML_DELAY = 28,
  SBML_STOICHIOMETRY_MATH = 29,
  SBML_LOCAL_PARAMETER = 30,
  SBML_PRIORITY = 31,
  SBML_GENERIC_SBASE = 32
}
 The enumeration of possible SBML core object types. More...
 

Functions

const char * SBMLTypeCode_toString (int tc, const char *pkgName)
 This method takes an SBML type code and returns a string representing the code. More...
 

Detailed Description

Enumeration to identify SBML objects at runtime.

Author
Ben Bornstein

Enumeration Type Documentation

The enumeration of possible SBML core object types.

LibSBML attaches an identifying code to every kind of SBML object. These are integer constants known as SBML type codes. The names of all the codes begin with the characters SBML_. The set of possible type codes for core elements is defined in the enumeration SBMLTypeCode_t, and in addition, libSBML plug-ins for SBML Level 3 packages define their own extra enumerations of type codes (e.g., SBMLLayoutTypeCode_t for the Level 3 Layout package). Note that different Level 3 package plug-ins may use overlapping type codes; to identify the package to which a given object belongs, call the SBase::getPackageName() method on the object.

The exception to this is lists: all SBML-style list elements have the type SBML_LIST_OF, regardless of what package they are from.

Here follow some additional general information about libSBML type codes:
  • The codes are the possible return values (integers) for the following functions: (Compatibility note: in libSBML 5, the type of return values of these functions changed from an enumeration to an integer for extensibility in the face of different programming languages.)
  • Each package extension must define similar sets of values for each SBase subclass (e.g. SBMLLayoutTypeCode_t for the SBML Level 3 Layout extension, SBMLFbcTypeCode_t for the SBML Level 3 Flux Balance Constraints extension, etc.).
  • The value of each package-specific type code can be duplicated between those of different packages. (This is necessary because the development of libSBML extensions for different SBML packages may be undertaken by different developers at different times; requiring the developers to coordinate their use of type codes would be nettlesome and probably doomed to failure.)
  • To distinguish between the type codes of different packages, both the return value of SBase::getTypeCode() and SBase::getPackageName() must be checked. This is particularly important for functions that take an SBML type code as an argument, such as SBase::getAncestorOfType(), which by default assumes you are handing it a core type, and will return NULL if the value you give it is actually from a package.

The following example code illustrates the combined use of SBase::getPackageName() and SBase::getTypeCode():

void example (const SBase *sb)
{
cons std::string pkgName = sb->getPackageName();
if (pkgName == "core")
{
switch (sb->getTypeCode())
{
case SBML_MODEL:
....
break;
....
}
}
else if (pkgName == "layout")
{
switch (sb->getTypeCode())
{
....
break;
....
}
}
...
}
Enumerator
SBML_UNKNOWN 

An unknown SBase type. The default, but will not be returned for any SBML core object, nor any fully-implemented package object.

SBML_COMPARTMENT 

Compartment

SBML_COMPARTMENT_TYPE 

CompartmentType (Note: L2 only)

SBML_CONSTRAINT 

Constraint

SBML_DOCUMENT 

SBMLDocument

SBML_EVENT 

Event

SBML_EVENT_ASSIGNMENT 

EventAssignment

SBML_FUNCTION_DEFINITION 

FunctionDefinition

SBML_INITIAL_ASSIGNMENT 

InitialAssignment

SBML_KINETIC_LAW 

KineticLaw

SBML_LIST_OF 

ListOf

SBML_MODEL 

Model

SBML_PARAMETER 

Parameter

SBML_REACTION 

Reaction

SBML_RULE 

Rule (Note: will not be returned from any getType function on any SBML core object, as it is an abstract base class only.)

SBML_SPECIES 

Species

SBML_SPECIES_REFERENCE 

SpeciesReference

SBML_SPECIES_TYPE 

SpeciesType (Note: L2 only)

SBML_MODIFIER_SPECIES_REFERENCE 

ModifierSpeciesReference

SBML_UNIT_DEFINITION 

UnitDefinition

SBML_UNIT 

Unit

SBML_ALGEBRAIC_RULE 

AlgebraicRule

SBML_ASSIGNMENT_RULE 

AssignmentRule

SBML_RATE_RULE 

RateRule

SBML_SPECIES_CONCENTRATION_RULE 

A Rule of the L1 type SpeciesConcentrationRule

SBML_COMPARTMENT_VOLUME_RULE 

A Rule of the L1 type CompartmentVolumeRule

SBML_PARAMETER_RULE 

A Rule of the L1 type ParameterRule

SBML_TRIGGER 

Trigger

SBML_DELAY 

Delay

SBML_STOICHIOMETRY_MATH 

StoichiometryMath (Note: L2 only)

SBML_LOCAL_PARAMETER 

LocalParameter

SBML_PRIORITY 

Priority

SBML_GENERIC_SBASE 

Any SBase-derived class. Not returned by any getType function, but used internally for packages that extend the SBase class itself, in the PKGNAMEExtension classes (such as CompExtension).

Function Documentation

const char* SBMLTypeCode_toString ( int  tc,
const char *  pkgName 
)

This method takes an SBML type code and returns a string representing the code.

LibSBML attaches an identifying code to every kind of SBML object. These are known as SBML type codes. The set of possible type codes is defined in the enumeration SBMLTypeCode_t. The names of the type codes all begin with the characters SBML_.

Returns
a human readable name for the given SBMLTypeCode_t value.
Note
The caller does not own the returned string and is therefore not allowed to modify it.