libSBML C++ API  5.20.4
DistribExtension Class Reference
Inheritance diagram for DistribExtension:
[legend]

Detailed Description

distrib Base extension class for the package.

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.

This is the Distrib package extension of the SBMLExtension class that is used to facilitate libSBML plug-ins in the implementation of an SBMLLevel 3 package.

Public Member Functions

virtual void addL2Namespaces (XMLNamespaces *xmlns) const
 Adds the package's Level 2 namespace(s). More...
 
virtual DistribExtensionclone () const
 Creates and returns a deep copy of this DistribExtension object. More...
 
 DistribExtension ()
 Creates a new DistribExtension instance. More...
 
 DistribExtension (const DistribExtension &orig)
 Copy constructor for DistribExtension. 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
 Returns the SBML Level for the given URI of this package. More...
 
virtual const std::string & getName () const
 Returns the name of this SBML Level 3 package ("distrib"). 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
 Returns the SBML Level 3 package version for the given URI of this package. More...
 
virtual SBMLNamespacesgetSBMLExtensionNamespaces (const std::string &uri) const
 Returns a DistribPkgNamespaces object. More...
 
virtual const char * getStringFromTypeCode (int typeCode) const
 Takes a type code of the “distrib” package and returns a string describing the 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
 Returns a string representing the SBML XML namespace of this SBML Level 3 package. More...
 
virtual unsigned int getVersion (const std::string &uri) const
 Returns the Version within the SBML Level for the given URI of this package. 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...
 
DistribExtensionoperator= (const DistribExtension &rhs)
 Assignment operator for DistribExtension. More...
 
virtual void removeL2Namespaces (XMLNamespaces *xmlns) const
 Removes the package's Level 2 namespace(s). More...
 
bool setEnabled (bool isEnabled)
 Enable or disable this package. More...
 
virtual ~DistribExtension ()
 Destructor for DistribExtension. More...
 

Static Public Member Functions

static unsigned int getDefaultLevel ()
 Returns the default SBML Level implemented by this libSBML extension. More...
 
static unsigned int getDefaultPackageVersion ()
 Returns the default version of the SBML Level 3 package implemented by this libSBML extension. More...
 
static unsigned int getDefaultVersion ()
 Returns the default SBML Version implemented by this libSBML extension. More...
 
static const std::string & getPackageName ()
 Returns the nickname of the SBML Level 3 package implemented by this libSBML extension. More...
 
static const std::string & getXmlnsL3V1V1 ()
 Returns the XML namespace URI of the SBML Level 3 package implemented by this libSBML extension. More...
 

Constructor & Destructor Documentation

◆ DistribExtension() [1/2]

DistribExtension::DistribExtension ( )

Creates a new DistribExtension instance.

◆ DistribExtension() [2/2]

DistribExtension::DistribExtension ( const DistribExtension orig)

Copy constructor for DistribExtension.

Parameters
origthe DistribExtension instance to copy.

◆ ~DistribExtension()

DistribExtension::~DistribExtension ( )
virtual

Destructor for DistribExtension.

Member Function Documentation

◆ addL2Namespaces()

void SBMLExtension::addL2Namespaces ( XMLNamespaces xmlns) const
virtualinherited

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.

This virtual method should be overridden by all package extensions that want to serialize to an SBML Level 2 annotation. In Level 2, the XML namespace declaration for the package is not placed on the top-level SBML document object but rather inside individual annotations. addL2Namespaces() is invoked automatically for Level 2 documents when an SBMLExtensionNamespace object is created; removeL2Namespaces() is automatically invoked by SBMLDocument to prevent the namespace(s) from being put on the top-level SBML Level 2 element (because Level 2 doesn't support namespaces there); and enableL2NamespaceForDocument() is called automatically when any SBML document (of any Level/Version) is read in.

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");
static const std::string & getXmlnsL2()
Returns the XML namespace URI of the SBML Level 2 version of the package implemented by this libSBML ...
Definition: LayoutExtension.cpp:109

Reimplemented in RenderExtension, and LayoutExtension.

◆ clone()

DistribExtension * DistribExtension::clone ( ) const
virtual

Creates and returns a deep copy of this DistribExtension object.

Returns
a (deep) copy of this DistribExtension object.

Implements SBMLExtension.

◆ enableL2NamespaceForDocument()

void SBMLExtension::enableL2NamespaceForDocument ( SBMLDocument doc) const
virtualinherited

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.

This virtual method should be overridden by all package extensions that want to serialize to an SBML Level 2 annotation. In Level 2, the XML namespace declaration for the package is not placed on the top-level SBML document object but rather inside individual annotations. addL2Namespaces() is invoked automatically for Level 2 documents when an SBMLExtensionNamespace object is created; removeL2Namespaces() is automatically invoked by SBMLDocument to prevent the namespace(s) from being put on the top-level SBML Level 2 element (because Level 2 doesn't support namespaces there); and enableL2NamespaceForDocument() is called automatically when any SBML document (of any Level/Version) is read in.

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 RenderExtension, and LayoutExtension.

◆ getDefaultLevel()

unsigned int DistribExtension::getDefaultLevel ( )
static

Returns the default SBML Level implemented by this libSBML extension.

Returns
the SBML Level, as an unsigned integer.

◆ getDefaultPackageVersion()

unsigned int DistribExtension::getDefaultPackageVersion ( )
static

Returns the default version of the SBML Level 3 package implemented by this libSBML extension.

Returns
the default version number of the SBML Level 3 package definition, as an unsigned integer.

◆ getDefaultVersion()

unsigned int DistribExtension::getDefaultVersion ( )
static

Returns the default SBML Version implemented by this libSBML extension.

Returns
the Version within the default SBML Level, as an unsigned integer.

◆ getLevel()

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

Returns the SBML Level for the given URI of this package.

Parameters
urithe string of the URI that represents one of the versions of the "distrib" package.
Returns
the SBML Level for the given URI of this package, or 0 if the given URI is invalid, or for a different package.

Implements SBMLExtension.

◆ getName()

const std::string & DistribExtension::getName ( ) const
virtual

Returns the name of this SBML Level 3 package ("distrib").

Returns
a string representing the name of this package ("distrib").

Implements SBMLExtension.

◆ getNumOfSBasePlugins()

int SBMLExtension::getNumOfSBasePlugins ( ) const
inherited

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
inherited

Returns the number of supported package namespace URIs.

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

◆ getPackageName()

const std::string & DistribExtension::getPackageName ( )
static

Returns the nickname of the SBML Level 3 package implemented by this libSBML extension.

Returns
the package nickname, as a string.

◆ getPackageVersion()

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

Returns the SBML Level 3 package version for the given URI of this package.

Parameters
urithe string of the URI that represents one of the versions of the "distrib" package.
Returns
the version of the SBML Level 3 package for the given URI of this package, or 0 if the given URI is invalid, or for a different package.

Implements SBMLExtension.

◆ getSBMLExtensionNamespaces()

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

Returns a DistribPkgNamespaces object.

Parameters
urithe string of the URI that represents one of the versions of the "distrib" package.
Returns
DistribPkgNamespaces object corresponding to the given URI of this package, or NULL if the given URI is not defined in the "distrib" package.

Implements SBMLExtension.

◆ getStringFromTypeCode()

const char * DistribExtension::getStringFromTypeCode ( int  typeCode) const
virtual

Takes a type code of the “distrib” package and returns a string describing the code.

Parameters
typeCodea libSBML type code defined by the libSBML extension implementing support for the SBML Level 3 “distrib” package.
Returns
a text string representing the type code given by typeCode. If the type code is unrecognized for this implementation of the libSBML “distrib” package, the string returned will be "(Unknown SBML Distrib Type)".

Implements SBMLExtension.

◆ getSupportedPackageURI()

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

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()

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

Returns a string representing the SBML XML namespace of this SBML Level 3 package.

Parameters
sbmlLevelthe level of SBML.
sbmlVersionthe version of SBML.
pkgVersionthe version of this package.
Returns
a string representing the name of this package ("distrib").

The namespace URI constructed by this method corresponds to the combination of the Level and Version of SBML, and the Version of the SBML Level 3 package. (At the time of this writing, the only SBML Level that supports packages is Level 3, so the value of sbmlLevel is necessarily always 3.)

Implements SBMLExtension.

◆ getVersion()

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

Returns the Version within the SBML Level for the given URI of this package.

Parameters
urithe string of the URI that represents one of the versions of the "distrib" package.
Returns
the SBML Version within the SBML Level for the given URI of this package, or 0 if the given URI is invalid, or for a different package.

Implements SBMLExtension.

◆ getXmlnsL3V1V1()

const std::string & DistribExtension::getXmlnsL3V1V1 ( )
static

Returns the XML namespace URI of the SBML Level 3 package implemented by this libSBML extension.

Returns
the XML namespace, as a string.

◆ isEnabled()

bool SBMLExtension::isEnabled ( ) const
inherited

Returns true if this package is enabled.

Returns
true if this package is enabled, false otherwise.

◆ isInUse()

bool SBMLExtension::isInUse ( SBMLDocument doc) const
virtualinherited

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 RenderExtension, and LayoutExtension.

◆ isSupported()

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

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=()

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

Assignment operator for DistribExtension.

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

◆ removeL2Namespaces()

void SBMLExtension::removeL2Namespaces ( XMLNamespaces xmlns) const
virtualinherited

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.

This virtual method should be overridden by all package extensions that want to serialize to an SBML Level 2 annotation. In Level 2, the XML namespace declaration for the package is not placed on the top-level SBML document object but rather inside individual annotations. addL2Namespaces() is invoked automatically for Level 2 documents when an SBMLExtensionNamespace object is created; removeL2Namespaces() is automatically invoked by SBMLDocument to prevent the namespace(s) from being put on the top-level SBML Level 2 element (because Level 2 doesn't support namespaces there); and enableL2NamespaceForDocument() is called automatically when any SBML document (of any Level/Version) is read in.

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 RenderExtension, and LayoutExtension.

◆ setEnabled()

bool SBMLExtension::setEnabled ( bool  isEnabled)
inherited

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.