libSBML Perl API  libSBML 5.10.0 Perl API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
doc_additional_typecode_details Class Reference

Detailed Description

Here follow some additional general information about SBML type codes:
  • The codes are the possible return values (integers) for the following functions: (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.)
  • 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;
       case SBML_REACTION:
          ....
     }
   } 
   else if (pkgName == "layout")
   {
     switch (sb->getTypeCode())
     {
       case SBML_LAYOUT_LAYOUT:
          ....
          break;
       case SBML_LAYOUT_REACTIONGLYPH:
          ....
     }
   } 
   ...
 } 
See also
SBMLTypeCode_t
SBMLCompTypeCode_t
SBMLFbcTypeCode_t
SBMLLayoutTypeCode_t
SBMLQualTypeCode_t