libSBML C++ API
5.18.0
|
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.
SBMLExtensionNamespaces is a template class. It is extended from SBMLNamespaces and is meant to be used by package extensions to store the SBML Level, Version within a Level, and package version of the SBML Level 3 package implemented by a libSBML package extension.
typedef
. The following sections explain these steps in detail.Each package needs to declare a package-specific version of the SBMLExtensionNamespaces class using a typedef
. The following example code demonstrates how this is done in the case of the Layout package:
This creates a new type called LayoutPkgNamespaces. The code above is usually placed in the same file that contains the SBMLExtension-derived definition of the package extension base class. In the case of the Layout package, this is in the file src/packages/layout/extension/LayoutExtension.h
in the libSBML source distribution.
Each package needs to instantiate a template instance of the SBMLExtensionNamespaces class. The following example code demonstrates how this is done in the case of the Layout package:
In the case of the Layout package, the code above is located in the file src/packages/layout/extension/LayoutExtension.cpp
in the libSBML source distribution.
Each SBase-derived class in the package extension should implement a constructor that accepts the SBMLExtensionNamespaces-derived class as an argument. For example, in the Layout package, the class BoundBox has a constructor declared as follows
The implementation of this constructor must, among other things, take the argument namespace object and use it to set the XML namespace URI for the object. Again, for the BoundingBox example:
Public Member Functions | |
int | addNamespace (const std::string &uri, const std::string &prefix) |
Add an XML namespace (a pair of URI and prefix) to the set of namespaces within this SBMLNamespaces object. More... | |
int | addNamespaces (const XMLNamespaces *xmlns) |
Add the given XML namespaces list to the set of namespaces within this SBMLNamespaces object. More... | |
int | addPackageNamespace (const std::string &pkgName, unsigned int pkgVersion, const std::string &prefix="") |
Add an XML namespace (a pair of URI and prefix) of a package extension to the set of namespaces within this SBMLNamespaces object. More... | |
int | addPackageNamespaces (const XMLNamespaces *xmlns) |
Add the XML namespaces of package extensions in the given XMLNamespace object to the set of namespaces within this SBMLNamespaces object (Non-package XML namespaces are not added by this function). More... | |
virtual ISBMLExtensionNamespaces * | clone () const |
Creates and returns a deep copy of this SBMLExtensionNamespaces object. More... | |
unsigned int | getLevel () |
Get the SBML Level of this SBMLNamespaces object. More... | |
unsigned int | getLevel () const |
Get the SBML Level of this SBMLNamespaces object. More... | |
XMLNamespaces * | getNamespaces () |
Get the XML namespaces list for this SBMLNamespaces object. More... | |
const XMLNamespaces * | getNamespaces () const |
Get the XML namespaces list for this SBMLNamespaces object. More... | |
virtual const std::string & | getPackageName () const |
Returns the name of the SBML package represented by this namespace object. More... | |
unsigned int | getPackageVersion () const |
Returns the version of the SBML package represented by this namespace object. More... | |
virtual std::string | getURI () const |
Returns a string representing the SBML XML namespace of this package. More... | |
unsigned int | getVersion () |
Get the SBML Version of this SBMLNamespaces object. More... | |
unsigned int | getVersion () const |
Get the SBML Version of this SBMLNamespaces object. More... | |
bool | isValidCombination () |
Predicate returning true if the given set of namespaces represent a valid set. More... | |
SBMLExtensionNamespaces & | operator= (const SBMLExtensionNamespaces &rhs) |
Assignment operator for SBMLExtensionNamespaces. More... | |
int | removeNamespace (const std::string &uri) |
Removes an XML namespace from the set of namespaces within this SBMLNamespaces object. More... | |
int | removePackageNamespace (unsigned int level, unsigned version, const std::string &pkgName, unsigned int pkgVersion) |
Removes an XML namespace of a package extension from the set of namespaces within this SBMLNamespaces object. More... | |
SBMLExtensionNamespaces (unsigned int level=SBMLExtensionType::getDefaultLevel(), unsigned int version=SBMLExtensionType::getDefaultVersion(), unsigned int pkgVersion=SBMLExtensionType::getDefaultPackageVersion(), const std::string &prefix=SBMLExtensionType::getPackageName()) | |
Creates a new SBMLExtensionNamespaces object corresponding to the given SBML level , version and package version. More... | |
SBMLExtensionNamespaces (const SBMLExtensionNamespaces &orig) | |
Copy constructor; creates a copy of a SBMLExtensionNamespaces. More... | |
virtual | ~SBMLExtensionNamespaces () |
Destroys this SBMLExtensionNamespaces object. More... | |
Static Public Member Functions | |
static void | freeSBMLNamespaces (List *supportedNS) |
Frees the list of supported namespaces as generated by getSupportedNamespaces(). More... | |
static std::string | getSBMLNamespaceURI (unsigned int level, unsigned int version) |
Returns a string representing the SBML XML namespace for the given level and version of SBML. More... | |
static const List * | getSupportedNamespaces () |
Returns a list of all supported SBMLNamespaces in this version of libsbml. More... | |
static bool | isSBMLNamespace (const std::string &uri) |
Predicate returning true if the given URL is one of SBML XML namespaces. More... | |
SBMLExtensionNamespaces< SBMLExtensionType >::SBMLExtensionNamespaces | ( | unsigned int | level = SBMLExtensionType::getDefaultLevel() , |
unsigned int | version = SBMLExtensionType::getDefaultVersion() , |
||
unsigned int | pkgVersion = SBMLExtensionType::getDefaultPackageVersion() , |
||
const std::string & | prefix = SBMLExtensionType::getPackageName() |
||
) |
Creates a new SBMLExtensionNamespaces object corresponding to the given SBML level
, version
and package
version.
level | the SBML Level. |
version | the SBML Version. |
pkgVersion | the package version. |
prefix | the prefix of the package namespace (e.g. "layout", "multi") to be added. The package's name will be used if the given string is empty (default). |
SBMLExtensionException | if the extension module that supports the combination of the given SBML Level, SBML Version, package name, and package version has not been registered. |
|
virtual |
Destroys this SBMLExtensionNamespaces object.
SBMLExtensionNamespaces< SBMLExtensionType >::SBMLExtensionNamespaces | ( | const SBMLExtensionNamespaces< SBMLExtensionType > & | orig | ) |
Copy constructor; creates a copy of a SBMLExtensionNamespaces.
orig | the SBMLExtensionNamespaces instance to copy. |
|
inherited |
Add an XML namespace (a pair of URI and prefix) to the set of namespaces within this SBMLNamespaces object.
uri | the XML namespace to be added. |
prefix | the prefix of the namespace to be added. |
|
inherited |
Add the given XML namespaces list to the set of namespaces within this SBMLNamespaces object.
The following code gives an example of how one could add the XHTML namespace to the list of namespaces recorded by the top-level <sbml>
element of a model. It gives the new namespace a prefix of html
.
xmlns | the XML namespaces to be added. |
|
inherited |
Add an XML namespace (a pair of URI and prefix) of a package extension to the set of namespaces within this SBMLNamespaces object.
The SBML Level and SBML Version of this object is used.
pkgName | the string of package name (e.g. "layout", "multi"). |
pkgVersion | the package version. |
prefix | the prefix of the package namespace to be added. The package's name will be used if the given string is empty (default). |
|
inherited |
Add the XML namespaces of package extensions in the given XMLNamespace object to the set of namespaces within this SBMLNamespaces object (Non-package XML namespaces are not added by this function).
xmlns | the XML namespaces to be added. |
NULL
.
|
virtual |
Creates and returns a deep copy of this SBMLExtensionNamespaces object.
Reimplemented from SBMLNamespaces.
|
staticinherited |
Frees the list of supported namespaces as generated by getSupportedNamespaces().
supportedNS | the list to be freed. |
|
inherited |
Get the SBML Level of this SBMLNamespaces object.
|
inherited |
Get the SBML Level of this SBMLNamespaces object.
|
inherited |
Get the XML namespaces list for this SBMLNamespaces object.
The plural name (SBMLNamespaces) is not a mistake, because in SBML Level 3, objects may have extensions added by Level 3 packages used by a given model and therefore may have multiple namespaces associated with them. In SBML Levels below Level 3, the SBMLNamespaces object only records one SBML Level/Version/namespace combination at a time. Most constructors for SBML objects in libSBML take a SBMLNamespaces object as an argument, thereby allowing the constructor to produce the proper combination of attributes and other internal data structures for the given SBML Level and Version.
|
inherited |
Get the XML namespaces list for this SBMLNamespaces object.
The plural name (SBMLNamespaces) is not a mistake, because in SBML Level 3, objects may have extensions added by Level 3 packages used by a given model and therefore may have multiple namespaces associated with them. In SBML Levels below Level 3, the SBMLNamespaces object only records one SBML Level/Version/namespace combination at a time. Most constructors for SBML objects in libSBML take a SBMLNamespaces object as an argument, thereby allowing the constructor to produce the proper combination of attributes and other internal data structures for the given SBML Level and Version.
|
virtual |
Returns the name of the SBML package represented by this namespace object.
Reimplemented from SBMLNamespaces.
unsigned int SBMLExtensionNamespaces< SBMLExtensionType >::getPackageVersion | ( | ) | const |
Returns the version of the SBML package represented by this namespace object.
|
staticinherited |
Returns a string representing the SBML XML namespace for the given level
and version
of SBML.
level | the SBML level. |
version | the SBML version. |
|
staticinherited |
Returns a list of all supported SBMLNamespaces in this version of libsbml.
|
virtual |
Returns a string representing the SBML XML namespace of this package.
Reimplemented from SBMLNamespaces.
|
inherited |
Get the SBML Version of this SBMLNamespaces object.
|
inherited |
Get the SBML Version of this SBMLNamespaces object.
|
staticinherited |
Predicate returning true
if the given URL is one of SBML XML namespaces.
uri | the URI of namespace. |
true
if the "uri" is one of SBML namespaces, false
otherwise.
|
inherited |
Predicate returning true
if the given set of namespaces represent a valid set.
true
if the set of namespaces is valid, false
otherwise. SBMLExtensionNamespaces& SBMLExtensionNamespaces< SBMLExtensionType >::operator= | ( | const SBMLExtensionNamespaces< SBMLExtensionType > & | rhs | ) |
Assignment operator for SBMLExtensionNamespaces.
rhs | the SBMLExtensionNamespaces instance to assign from. |
|
inherited |
Removes an XML namespace from the set of namespaces within this SBMLNamespaces object.
uri | the XML namespace to be added. |
|
inherited |
Removes an XML namespace of a package extension from the set of namespaces within this SBMLNamespaces object.
level | the SBML level. |
version | the SBML version. |
pkgName | the string of package name (e.g. "layout", "multi"). |
pkgVersion | the package version. |