libSBML Perl API  libSBML 5.17.2 Perl API
SBMLExtension Class Referenceabstract
Inheritance diagram for SBMLExtension:
[legend]

Detailed Description

{core}

Base class for SBML Level 3 package plug-ins.

This class of objects is defined by libSBML only and has no direct equivalent in terms of SBML components. This class is not prescribed by the SBML specifications, although it is used to implement features defined in SBML.

The SBMLExtension class is a component of the libSBML package extension mechanism. It is an abstract class that is extended by each package extension implementation.

Special handling for SBML LevelĀ 2

Public Member Functions

virtual void addL2Namespaces (XMLNamespaces *xmlns) const
 Adds the package's Level 2 namespace(s). More...
 
virtual SBMLExtensionclone () const =0
 Creates and returns a deep copy of this SBMLExtension object. More...
 
virtual void enableL2NamespaceForDocument (SBMLDocument *doc) const
 Called to enable the package on the SBMLDocument object. More...
 
virtual unsigned int getLevel (const std::string &uri) const =0
 Returns the SBML Level associated with the given XML namespace URI. More...
 
virtual const std::string & getName () const =0
 Returns the nickname of this package. More...
 
int getNumOfSBasePlugins () const
 Returns the number of SBasePluginCreatorBase objects stored in this object. More...
 
unsigned int getNumOfSupportedPackageURI () const
 Returns the number of supported package namespace URIs. More...
 
virtual unsigned int getPackageVersion (const std::string &uri) const =0
 Returns the package version associated with the given XML namespace URI. More...
 
virtual SBMLNamespacesgetSBMLExtensionNamespaces (const std::string &uri) const =0
 Returns a specialized SBMLNamespaces object corresponding to a given namespace URI. More...
 
virtual const char * getStringFromTypeCode (int typeCode) const =0
 Returns a string representation of a type code. More...
 
const std::string & getSupportedPackageURI (unsigned int n) const
 Returns the nth XML namespace URI. More...
 
virtual const std::string & getURI (unsigned int sbmlLevel, unsigned int sbmlVersion, unsigned int pkgVersion) const =0
 Returns the XML namespace URI for a given Level and Version. More...
 
virtual unsigned int getVersion (const std::string &uri) const =0
 Returns the SBML Version associated with the given XML namespace URI. More...
 
bool isEnabled () const
 Returns true if this package is enabled. More...
 
virtual bool isInUse (SBMLDocument *doc) const
 Indicates whether this extension is being used by the given SBMLDocument. More...
 
bool isSupported (const std::string &uri) const
 Returns true if the given XML namespace URI is supported by this package extension. More...
 
SBMLExtensionoperator= (const SBMLExtension &rhs)
 Assignment operator for SBMLExtension. More...
 
virtual void removeL2Namespaces (XMLNamespaces *xmlns) const
 Removes the package's Level 2 namespace(s). More...
 
 SBMLExtension ()
 Constructor; creates a new SBMLExtension object. More...
 
 SBMLExtension (const SBMLExtension &orig)
 Copy constructor. More...
 
bool setEnabled (bool isEnabled)
 Enable or disable this package. More...
 
virtual ~SBMLExtension ()
 Destroy this SBMLExtension object. More...
 

Constructor & Destructor Documentation

◆ SBMLExtension() [1/2]

SBMLExtension::SBMLExtension ( )

Constructor; creates a new SBMLExtension object.

◆ SBMLExtension() [2/2]

SBMLExtension::SBMLExtension ( const SBMLExtension orig)

Copy constructor.

This creates a copy of an SBMLExtension object.

Parameters
origthe SBMLExtension object to copy.

◆ ~SBMLExtension()

SBMLExtension::~SBMLExtension ( )
virtual

Destroy this SBMLExtension object.

Member Function Documentation

◆ addL2Namespaces()

void SBMLExtension::addL2Namespaces ( XMLNamespaces xmlns) const
virtual

Adds the package's Level 2 namespace(s).

This method is related to special facilities designed to support legacy behaviors surrounding SBML Level 2 models. Due to the historical background of the SBML Layout package, libSBML implements special behavior for that package: it always creates a Layout plugin object for any SBML Level 2 document it reads in, regardless of whether that document actually uses Layout constructs. Since Level 2 does not use namespaces on the top level of the SBML document object, libSBML simply keys off the fact that the model is a Level 2 model. To allow the extensions for the Layout and Render (and possibly other) packages to support this behavior, the SBMLExtension class contains special methods to allow packages to hook themselves into the Level 2 parsing apparatus when necessary.
Parameters
xmlnsan XMLNamespaces object that will be used for the annotation. Implementation should override this method with something that adds the package's namespace(s) to the set of namespaces in xmlns. For instance, here is the code from the Layout package extension:
if (!xmlns->containsUri( LayoutExtension::getXmlnsL2()))
xmlns->add(LayoutExtension::getXmlnsL2(), "layout");

Reimplemented in LayoutExtension, and RenderExtension.

◆ clone()

virtual SBMLExtension* SBMLExtension::clone ( ) const
pure virtual

Creates and returns a deep copy of this SBMLExtension object.

Returns
a (deep) copy of this SBMLExtension object.

Implemented in LayoutExtension, FbcExtension, MultiExtension, CompExtension, QualExtension, GroupsExtension, and RenderExtension.

◆ enableL2NamespaceForDocument()

void SBMLExtension::enableL2NamespaceForDocument ( SBMLDocument doc) const
virtual

Called to enable the package on the SBMLDocument object.

This method is related to special facilities designed to support legacy behaviors surrounding SBML Level 2 models. Due to the historical background of the SBML Layout package, libSBML implements special behavior for that package: it always creates a Layout plugin object for any SBML Level 2 document it reads in, regardless of whether that document actually uses Layout constructs. Since Level 2 does not use namespaces on the top level of the SBML document object, libSBML simply keys off the fact that the model is a Level 2 model. To allow the extensions for the Layout and Render (and possibly other) packages to support this behavior, the SBMLExtension class contains special methods to allow packages to hook themselves into the Level 2 parsing apparatus when necessary.
Parameters
docthe SBMLDocument object for the model. Implementations should override this method with something that enables the package based on the package's namespace(s). For example, here is the code from the Layout package extension:
if (doc->getLevel() == 2)
doc->enablePackage(LayoutExtension::getXmlnsL2(), "layout", true);

Reimplemented in LayoutExtension, and RenderExtension.

◆ getLevel()

virtual unsigned int SBMLExtension::getLevel ( const std::string &  uri) const
pure virtual

Returns the SBML Level associated with the given XML namespace URI.

Parameters
urithe string of URI that represents a version of the package.
Returns
the SBML Level associated with the given URI of this package.

Implemented in LayoutExtension, FbcExtension, MultiExtension, CompExtension, QualExtension, GroupsExtension, and RenderExtension.

◆ getName()

virtual const std::string& SBMLExtension::getName ( ) const
pure virtual

Returns the nickname of this package.

This returns the short-form name of an SBML Level 3 package implemented by a given SBMLExtension-derived class. Examples of such names are "layout", "fbc", etc.

Returns
a string, the nickname of SBML package.

Implemented in LayoutExtension, FbcExtension, MultiExtension, CompExtension, QualExtension, GroupsExtension, and RenderExtension.

◆ getNumOfSBasePlugins()

int SBMLExtension::getNumOfSBasePlugins ( ) const

Returns the number of SBasePluginCreatorBase objects stored in this object.

Returns
the total number of SBasePluginCreatorBase objects stored in this SBMLExtension-derived object.

◆ getNumOfSupportedPackageURI()

unsigned int SBMLExtension::getNumOfSupportedPackageURI ( ) const

Returns the number of supported package namespace URIs.

Returns
the number of supported package XML namespace URIs of this package extension.

◆ getPackageVersion()

virtual unsigned int SBMLExtension::getPackageVersion ( const std::string &  uri) const
pure virtual

Returns the package version associated with the given XML namespace URI.

Parameters
urithe string of URI that represents a version of this package.
Returns
the package version associated with the given URI of this package.

Implemented in LayoutExtension, FbcExtension, MultiExtension, CompExtension, QualExtension, GroupsExtension, and RenderExtension.

◆ getSBMLExtensionNamespaces()

virtual SBMLNamespaces* SBMLExtension::getSBMLExtensionNamespaces ( const std::string &  uri) const
pure virtual

Returns a specialized SBMLNamespaces object corresponding to a given namespace URI.

LibSBML package extensions each define a subclass of SBMLNamespaces.

The present method returns the appropriate object corresponding to the given XML namespace URI in argument uri.

Parameters
urithe namespace URI that represents one of versions of the package implemented in this extension.
Returns
an SBMLNamespaces object, or NULL if the given uri is not defined in the corresponding package.

Implemented in LayoutExtension, FbcExtension, MultiExtension, CompExtension, QualExtension, GroupsExtension, and RenderExtension.

◆ getStringFromTypeCode()

virtual const char* SBMLExtension::getStringFromTypeCode ( int  typeCode) const
pure virtual

Returns a string representation of a type code.

This method takes a numerical type code typeCode for a component object implemented by this package extension, and returns a string representing that type code.

Parameters
typeCodethe type code to turn into a string.
Returns
the string representation of typeCode.

Implemented in FbcExtension, LayoutExtension, MultiExtension, CompExtension, QualExtension, GroupsExtension, and RenderExtension.

◆ getSupportedPackageURI()

const std::string & SBMLExtension::getSupportedPackageURI ( unsigned int  n) const

Returns the nth XML namespace URI.

Parameters
nthe index number of the namespace URI being sought.
Returns
a string representing the XML namespace URI understood to be supported by this package. An empty string will be returned if there is no nth URI.

◆ getURI()

virtual const std::string& SBMLExtension::getURI ( unsigned int  sbmlLevel,
unsigned int  sbmlVersion,
unsigned int  pkgVersion 
) const
pure virtual

Returns the XML namespace URI for a given Level and Version.

Parameters
sbmlLevelthe SBML Level.
sbmlVersionthe SBML Version.
pkgVersionthe version of the package.
Returns
a string, the XML namespace URI for the package for the given SBML Level, SBML Version, and package version.

Implemented in LayoutExtension, FbcExtension, MultiExtension, CompExtension, QualExtension, GroupsExtension, and RenderExtension.

◆ getVersion()

virtual unsigned int SBMLExtension::getVersion ( const std::string &  uri) const
pure virtual

Returns the SBML Version associated with the given XML namespace URI.

Parameters
urithe string of URI that represents a version of the package.
Returns
the SBML Version associated with the given URI of this package.

Implemented in LayoutExtension, FbcExtension, MultiExtension, CompExtension, QualExtension, GroupsExtension, and RenderExtension.

◆ isEnabled()

bool SBMLExtension::isEnabled ( ) const

Returns true if this package is enabled.

Returns
true if this package is enabled, false otherwise.

◆ isInUse()

bool SBMLExtension::isInUse ( SBMLDocument doc) const
virtual

Indicates whether this extension is being used by the given SBMLDocument.

The default implementation returns true. This means that when a document had this extension enabled, it will not be possible to convert it to SBML Level 2 as we cannot make sure that the extension can be converted.

Parameters
docthe SBML document to test.
Returns
a boolean indicating whether the extension is actually being used by the document.

Reimplemented in LayoutExtension, and RenderExtension.

◆ isSupported()

bool SBMLExtension::isSupported ( const std::string &  uri) const

Returns true if the given XML namespace URI is supported by this package extension.

Returns
true if the given XML namespace URI (equivalent to a package version) is supported by this package extension, false otherwise.

◆ operator=()

SBMLExtension & SBMLExtension::operator= ( const SBMLExtension rhs)

Assignment operator for SBMLExtension.

Parameters
rhsthe object whose values are used as the basis of the assignment.

◆ removeL2Namespaces()

void SBMLExtension::removeL2Namespaces ( XMLNamespaces xmlns) const
virtual

Removes the package's Level 2 namespace(s).

This method is related to special facilities designed to support legacy behaviors surrounding SBML Level 2 models. Due to the historical background of the SBML Layout package, libSBML implements special behavior for that package: it always creates a Layout plugin object for any SBML Level 2 document it reads in, regardless of whether that document actually uses Layout constructs. Since Level 2 does not use namespaces on the top level of the SBML document object, libSBML simply keys off the fact that the model is a Level 2 model. To allow the extensions for the Layout and Render (and possibly other) packages to support this behavior, the SBMLExtension class contains special methods to allow packages to hook themselves into the Level 2 parsing apparatus when necessary.
Parameters
xmlnsan XMLNamespaces object that will be used for the annotation. Implementations should override this method with something that removes the package's namespace(s) from the set of namespaces in xmlns. For instance, here is the code from the Layout package extension:
for (int n = 0; n < xmlns->getNumNamespaces(); n++)
{
if (xmlns->getURI(n) == LayoutExtension::getXmlnsL2())
xmlns->remove(n);
}

Reimplemented in LayoutExtension, and RenderExtension.

◆ setEnabled()

bool SBMLExtension::setEnabled ( bool  isEnabled)

Enable or disable this package.

Parameters
isEnabledflag indicating whether to enable (if true) or disable (false) this package extension.
Returns
true if this call succeeded; false otherwise.