libSBML Python API  5.11.0
libsbml.RenderPkgNamespaces Class Reference
Inheritance diagram for libsbml.RenderPkgNamespaces:
[legend]

Detailed Description

Set of SBML Level + Version + namespace triples.

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.

How to use SBMLExtensionNamespaces for a package implementation

Each package extension in libSBML needs to extend and instantiate the template class SBMLExtensionNamespaces, as well as declare a specific typedef. The following sections explain these steps in detail.

1. Define the typedef

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:

typedef SBMLExtensionNamespaces<LayoutExtension> LayoutPkgNamespaces;

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.

2. Instantiate a template instance

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:

template class LIBSBML_EXTERN SBMLExtensionNamespaces<LayoutExtension>;

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.

3. Create constructors that accept the class

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

BoundingBox(LayoutPkgNamespaces layoutns);

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:

BoundingBox.BoundingBox()
: SBase(layoutns)
,mPosition(layoutns)
,mDimensions(layoutns)
,mPositionExplicitlySet (false)
,mDimensionsExplicitlySet (false)
{
// Standard extension actions.
setElementNamespace(layoutns->getURI());
connectToChild();
// Package-specific actions.
mPosition.setElementName('position');
// Load package extensions bound with this object (if any).
loadPlugins(layoutns);
}

Public Member Functions

def __init__ (self, args)
  Set of SBML Level + Version + namespace triples. More...
 
def addNamespace (self, uri, prefix)
 Add an XML namespace (a pair of URI and prefix) to the set of namespaces within this SBMLNamespaces object. More...
 
def addNamespaces (self, xmlns)
 Add the given XML namespaces list to the set of namespaces within this SBMLNamespaces object. More...
 
def addPackageNamespace (self, args)
 Add an XML namespace (a pair of URI and prefix) of a package extension to the set of namespaces within this SBMLNamespaces object. More...
 
def addPackageNamespaces (self, 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...
 
def clone (self)
 Creates and returns a deep copy of this SBMLNamespaces object. More...
 
def freeSBMLNamespaces (supportedNS)
 Frees the list of supported namespaces as generated by getSupportedNamespaces(). More...
 
def getLevel (self, args)
 Get the SBML Level of this SBMLNamespaces object. More...
 
def getNamespaces (self, args)
 Get the XML namespaces list for this SBMLNamespaces object. More...
 
def getPackageName (self)
 Returns the name of the main package for this namespace. More...
 
def getPackageVersion (self)
 
def getSBMLNamespaceURI (level, version)
 Returns a string representing the SBML XML namespace for the given level and version of SBML. More...
 
def getSupportedNamespaces ()
 Returns a list of all supported SBMLNamespaces in this version of libsbml. More...
 
def getURI (self)
 Returns a string representing the SBML XML namespace of this object. More...
 
def getVersion (self, args)
 Get the SBML Version of this SBMLNamespaces object. More...
 
def isSBMLNamespace (uri)
 Predicate returning True if the given URL is one of SBML XML namespaces. More...
 
def isValidCombination (self)
 Predicate returning True if the given set of namespaces represent a valid set. More...
 
def removeNamespace (self, uri)
 Removes an XML namespace from the set of namespaces within this SBMLNamespaces object. More...
 
def removePackageNamespace (self, level, version, pkgName, pkgVersion)
 Removes an XML namespace of a package extension from the set of namespaces within this SBMLNamespaces object. More...
 

Member Function Documentation

def libsbml.SBMLNamespaces.addNamespace (   self,
  uri,
  prefix 
)
inherited

Add an XML namespace (a pair of URI and prefix) to the set of namespaces within this SBMLNamespaces object.

addNamespace(string uri, string prefix)   int
Parameters
urithe XML namespace to be added.
prefixthe prefix of the namespace to be added.
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
def libsbml.SBMLNamespaces.addNamespaces (   self,
  xmlns 
)
inherited

Add the given XML namespaces list to the set of namespaces within this SBMLNamespaces object.

addNamespaces(XMLNamespaces xmlns)   int

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.

1 sbmlDoc = None
2 try:
3  sbmlDoc = SBMLDocument(3, 1)
4 except ValueError:
5  # Do something to handle exceptional situation. Candidate
6  # causes include invalid combinations of SBML Level and Version
7  # (impossible if hardwired as given here), running out of memory, and
8  # unknown system exceptions.
9 
10 namespaces = sbmlDoc.getNamespaces()
11 if namespaces == None:
12  # Do something to handle case of no namespaces.
13 
14 status = namespaces.add('http://www.w3.org/1999/xhtml', 'html')
15 if status != LIBSBML_OPERATION_SUCCESS:
16  # Do something to handle failure.
Parameters
xmlnsthe XML namespaces to be added.
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
def libsbml.SBMLNamespaces.addPackageNamespace (   self,
  args 
)
inherited

Add an XML namespace (a pair of URI and prefix) of a package extension to the set of namespaces within this SBMLNamespaces object.

addPackageNamespace(string pkgName, long pkgVersion, string prefix)   int
addPackageNamespace(string pkgName, long pkgVersion)   int

The SBML Level and SBML Version of this object is used.

Parameters
pkgNamethe string of package name (e.g. 'layout', 'multi')
pkgVersionthe package version
prefixthe prefix of the package namespace to be added. The package's name will be used if the given string is empty (default).
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
Note
An XML namespace of a non-registered package extension can't be added by this function (LIBSBML_INVALID_ATTRIBUTE_VALUE will be returned).
See also
addNamespace()
def libsbml.SBMLNamespaces.addPackageNamespaces (   self,
  xmlns 
)
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).

addPackageNamespaces(XMLNamespaces xmlns)   int
Parameters
xmlnsthe XML namespaces to be added.
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
Note
XML namespaces of a non-registered package extensions are not added (just ignored) by this function. LIBSBML_INVALID_ATTRIBUTE_VALUE will be returned if the given xmlns is null.
def libsbml.RenderPkgNamespaces.clone (   self)

Creates and returns a deep copy of this SBMLNamespaces object.

clone()   ISBMLExtensionNamespaces
Returns
the (deep) copy of this SBMLNamespaces object.
def libsbml.SBMLNamespaces.freeSBMLNamespaces (   supportedNS)
inherited

Frees the list of supported namespaces as generated by getSupportedNamespaces().

freeSBMLNamespaces(List * supportedNS)
Parameters
supportedNSthe list to be freed.
Note
Because this is a static method on a class, the Python language interface for libSBML will contain two variants. One will be the expected, normal static method on the class (i.e., a regular methodName), and the other will be a standalone top-level function with the name ClassName_methodName(). This is merely an artifact of how the language interfaces are created in libSBML. The methods are functionally identical.
def libsbml.SBMLNamespaces.getLevel (   self,
  args 
)
inherited

Get the SBML Level of this SBMLNamespaces object.

getLevel()   long
Returns
the SBML Level of this SBMLNamespaces object.
def libsbml.SBMLNamespaces.getNamespaces (   self,
  args 
)
inherited

Get the XML namespaces list for this SBMLNamespaces object.

getNamespaces()   XMLNamespaces
SBMLNamespaces objects are used in libSBML to communicate SBML Level and Version data between constructors and other methods. The SBMLNamespaces object class holds triples consisting of SBML Level, Version, and the corresponding SBML XML namespace. 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.

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.

Returns
the XML namespaces of this SBMLNamespaces object.
def libsbml.RenderPkgNamespaces.getPackageName (   self)

Returns the name of the main package for this namespace.

getPackageName()   string
Returns
the name of the main package for this namespace. 'core' will be returned if this namespace is defined in the SBML core.
def libsbml.RenderPkgNamespaces.getPackageVersion (   self)
getPackageVersion()   long
def libsbml.SBMLNamespaces.getSBMLNamespaceURI (   level,
  version 
)
inherited

Returns a string representing the SBML XML namespace for the given level and version of SBML.

getSBMLNamespaceURI(long level, long version)   string
Parameters
levelthe SBML level
versionthe SBML version
Returns
a string representing the SBML namespace that reflects the SBML Level and Version specified.
Note
Because this is a static method on a class, the Python language interface for libSBML will contain two variants. One will be the expected, normal static method on the class (i.e., a regular methodName), and the other will be a standalone top-level function with the name ClassName_methodName(). This is merely an artifact of how the language interfaces are created in libSBML. The methods are functionally identical.
def libsbml.SBMLNamespaces.getSupportedNamespaces ( )
inherited

Returns a list of all supported SBMLNamespaces in this version of libsbml.

getSupportedNamespaces()   List *
Returns
a list with supported SBML namespaces.
Note
Because this is a static method on a class, the Python language interface for libSBML will contain two variants. One will be the expected, normal static method on the class (i.e., a regular methodName), and the other will be a standalone top-level function with the name ClassName_methodName(). This is merely an artifact of how the language interfaces are created in libSBML. The methods are functionally identical.
def libsbml.RenderPkgNamespaces.getURI (   self)

Returns a string representing the SBML XML namespace of this object.

getURI()   string
Returns
a string representing the SBML namespace that reflects the SBML Level and Version of this object.
def libsbml.SBMLNamespaces.getVersion (   self,
  args 
)
inherited

Get the SBML Version of this SBMLNamespaces object.

getVersion()   long
Returns
the SBML Version of this SBMLNamespaces object.
def libsbml.SBMLNamespaces.isSBMLNamespace (   uri)
inherited

Predicate returning True if the given URL is one of SBML XML namespaces.

isSBMLNamespace(string uri)   bool
Parameters
urithe URI of namespace
Returns
True if the 'uri' is one of SBML namespaces, False otherwise.
Note
Because this is a static method on a class, the Python language interface for libSBML will contain two variants. One will be the expected, normal static method on the class (i.e., a regular methodName), and the other will be a standalone top-level function with the name ClassName_methodName(). This is merely an artifact of how the language interfaces are created in libSBML. The methods are functionally identical.
def libsbml.SBMLNamespaces.isValidCombination (   self)
inherited

Predicate returning True if the given set of namespaces represent a valid set.

Returns
True if the set of namespaces is valid, False otherwise.
isValidCombination()   bool
def libsbml.SBMLNamespaces.removeNamespace (   self,
  uri 
)
inherited

Removes an XML namespace from the set of namespaces within this SBMLNamespaces object.

removeNamespace(string uri)   int
Parameters
urithe XML namespace to be added.
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
def libsbml.SBMLNamespaces.removePackageNamespace (   self,
  level,
  version,
  pkgName,
  pkgVersion 
)
inherited

Removes an XML namespace of a package extension from the set of namespaces within this SBMLNamespaces object.

removePackageNamespace(long level, long version, string pkgName, long pkgVersion)   int
Parameters
levelthe SBML level
versionthe SBML version
pkgNamethe string of package name (e.g. 'layout', 'multi')
pkgVersionthe package version
Returns
integer value indicating success/failure of the function. The possible values returned by this function are: