libSBML C++ API  5.20.4
SBMLNamespaces Class Reference
Inheritance diagram for SBMLNamespaces:
[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.

There are differences in the definitions of components between different SBML Levels, as well as Versions within Levels. For example, the "sboTerm" attribute was not introduced until Level 2 Version 2, and then only on certain component classes; the SBML Level 2 Version 3 specification moved the "sboTerm" attribute to the SBase class, thereby allowing nearly all components to have SBO annotations. As a result of differences such as those, libSBML needs to track the SBML Level and Version of every object created.

The purpose of the SBMLNamespaces object class is to make it easier to communicate SBML Level and Version data between libSBML constructors and other methods. The SBMLNamespaces object class tracks 3-tuples (triples) consisting of SBML Level, Version, and the corresponding SBML XML namespace.

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; however, until the introduction of SBML 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.

Examples
convertLayout.cpp, example1-L3.cpp, example1.cpp, example2-L3.cpp, example2.cpp, example3-L3.cpp, example3.cpp, fbc_example1.cpp, groups_example1.cpp, groups_example2.cpp, printSupported.cpp, qual_example1.cpp, spec_example1.cpp, spec_example2.cpp, spec_example3.cpp, and spec_example4.cpp.

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 SBMLNamespacesclone () const
 Creates and returns a deep copy of this SBMLNamespaces 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...
 
XMLNamespacesgetNamespaces ()
 Get the XML namespaces list for this SBMLNamespaces object. More...
 
const XMLNamespacesgetNamespaces () const
 Get the XML namespaces list for this SBMLNamespaces object. More...
 
virtual const std::string & getPackageName () const
 Returns the name of the main package for this namespace. More...
 
virtual std::string getURI () const
 Returns a string representing the SBML XML namespace of this object. 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...
 
SBMLNamespacesoperator= (const SBMLNamespaces &rhs)
 Assignment operator for SBMLNamespaces. 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...
 
 SBMLNamespaces (const SBMLNamespaces &orig)
 Copy constructor; creates a copy of a SBMLNamespaces. More...
 
 SBMLNamespaces (unsigned int level, unsigned int version, const std::string &pkgName, unsigned int pkgVersion, const std::string pkgPrefix="")
 (For extensions) Creates a new SBMLNamespaces object corresponding to the combination of (1) the given SBML level and version, and (2) the given package with the package version. More...
 
 SBMLNamespaces (unsigned int level=SBML_DEFAULT_LEVEL, unsigned int version=SBML_DEFAULT_VERSION)
 Creates a new SBMLNamespaces object corresponding to the given SBML level and version. More...
 
virtual ~SBMLNamespaces ()
 Destroys this SBMLNamespaces 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 ListgetSupportedNamespaces ()
 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...
 

Constructor & Destructor Documentation

◆ SBMLNamespaces() [1/3]

SBMLNamespaces::SBMLNamespaces ( unsigned int  level = SBML_DEFAULT_LEVEL,
unsigned int  version = SBML_DEFAULT_VERSION 
)

Creates a new SBMLNamespaces object corresponding to the given SBML level and version.

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.

Parameters
levelthe SBML level.
versionthe SBML version.

◆ SBMLNamespaces() [2/3]

SBMLNamespaces::SBMLNamespaces ( unsigned int  level,
unsigned int  version,
const std::string &  pkgName,
unsigned int  pkgVersion,
const std::string  pkgPrefix = "" 
)

(For extensions) Creates a new SBMLNamespaces object corresponding to the combination of (1) the given SBML level and version, and (2) the given package with the package version.

(For Extension)

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.

Parameters
levelthe SBML Level.
versionthe SBML Version.
pkgNamethe string of package name (e.g. "layout", "multi").
pkgVersionthe package version.
pkgPrefixthe 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).
Exceptions
SBMLExtensionExceptionif the extension module that supports the combination of the given SBML Level, SBML Version, package name, and package version has not been registered with libSBML.

Creates a new SBMLNamespaces object corresponding to the combination of (1) the given SBML level and version, and (2) the given package with the package version.

◆ ~SBMLNamespaces()

SBMLNamespaces::~SBMLNamespaces ( )
virtual

Destroys this SBMLNamespaces object.

◆ SBMLNamespaces() [3/3]

SBMLNamespaces::SBMLNamespaces ( const SBMLNamespaces orig)

Copy constructor; creates a copy of a SBMLNamespaces.

Parameters
origthe SBMLNamespaces instance to copy.

Member Function Documentation

◆ addNamespace()

int SBMLNamespaces::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.

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 value is drawn from the enumeration OperationReturnValues_t. The possible values returned by this function are:
Examples
example1.cpp, and example3.cpp.

◆ addNamespaces()

int SBMLNamespaces::addNamespaces ( const XMLNamespaces xmlns)

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.

try
{
sd = new SBMLDocument(3, 1);
}
{
// Here, have code to handle a truly exceptional situation. Candidate
// causes include invalid combinations of SBML Level and Version
// (impossible if hardwired as given here), running out of memory, and
// unknown system exceptions.
}
if (sn != NULL)
{
sn->add("http://www.w3.org/1999/xhtml", "html");
}
else
{
// Handle another truly exceptional situation.
}
Definition: SBMLConstructorException.h:72
Definition: SBMLDocument.h:351
virtual XMLNamespaces * getNamespaces() const
Returns a list of XML Namespaces associated with the XML content of this SBML document.
Definition: SBMLDocument.cpp:1334
Definition: SBMLNamespaces.h:145
Parameters
xmlnsthe XML namespaces to be added.
Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. The possible values returned by this function are:

◆ addPackageNamespace()

int SBMLNamespaces::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.

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 value is drawn from the enumeration OperationReturnValues_t. 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()

◆ addPackageNamespaces()

int SBMLNamespaces::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).

Parameters
xmlnsthe XML namespaces to be added.
Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. 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.

◆ clone()

SBMLNamespaces * SBMLNamespaces::clone ( ) const
virtual

Creates and returns a deep copy of this SBMLNamespaces object.

Returns
the (deep) copy of this SBMLNamespaces object.

Reimplemented in SBMLExtensionNamespaces< SBMLExtensionType >.

◆ freeSBMLNamespaces()

void SBMLNamespaces::freeSBMLNamespaces ( List supportedNS)
static

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

Parameters
supportedNSthe list to be freed.
Examples
printSupported.cpp.

◆ getLevel() [1/2]

unsigned int SBMLNamespaces::getLevel ( )

Get the SBML Level of this SBMLNamespaces object.

Returns
the SBML Level of this SBMLNamespaces object.
Examples
printSupported.cpp.

◆ getLevel() [2/2]

unsigned int SBMLNamespaces::getLevel ( ) const

Get the SBML Level of this SBMLNamespaces object.

Returns
the SBML Level of this SBMLNamespaces object.

◆ getNamespaces() [1/2]

XMLNamespaces * SBMLNamespaces::getNamespaces ( )

Get the XML namespaces list for this SBMLNamespaces object.

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.

◆ getNamespaces() [2/2]

const XMLNamespaces * SBMLNamespaces::getNamespaces ( ) const

Get the XML namespaces list for this SBMLNamespaces object.

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.

◆ getPackageName()

virtual const std::string& SBMLNamespaces::getPackageName ( ) const
virtual

Returns the name of the main package for this namespace.

Returns
the name of the main package for this namespace. "core" will be returned if this namespace is defined in the SBML core.

Reimplemented in SBMLExtensionNamespaces< SBMLExtensionType >.

◆ getSBMLNamespaceURI()

std::string SBMLNamespaces::getSBMLNamespaceURI ( unsigned int  level,
unsigned int  version 
)
static

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

Parameters
levelthe SBML level.
versionthe SBML version.
Returns
a string representing the SBML namespace that reflects the SBML Level and Version specified.

◆ getSupportedNamespaces()

const List * SBMLNamespaces::getSupportedNamespaces ( )
static

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

Returns
a list with supported SBML namespaces.
Examples
printSupported.cpp.

◆ getURI()

std::string SBMLNamespaces::getURI ( ) const
virtual

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

Returns
a string representing the SBML namespace that reflects the SBML Level and Version of this object.

Reimplemented in SBMLExtensionNamespaces< SBMLExtensionType >.

◆ getVersion() [1/2]

unsigned int SBMLNamespaces::getVersion ( )

Get the SBML Version of this SBMLNamespaces object.

Returns
the SBML Version of this SBMLNamespaces object.
Examples
printSupported.cpp.

◆ getVersion() [2/2]

unsigned int SBMLNamespaces::getVersion ( ) const

Get the SBML Version of this SBMLNamespaces object.

Returns
the SBML Version of this SBMLNamespaces object.

◆ isSBMLNamespace()

bool SBMLNamespaces::isSBMLNamespace ( const std::string &  uri)
static

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

Parameters
urithe URI of namespace.
Returns
true if the "uri" is one of SBML namespaces, false otherwise.

◆ isValidCombination()

bool SBMLNamespaces::isValidCombination ( )

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

Returns
true if the set of namespaces is valid, false otherwise.

◆ operator=()

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

Assignment operator for SBMLNamespaces.

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

◆ removeNamespace()

int SBMLNamespaces::removeNamespace ( const std::string &  uri)

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

Parameters
urithe XML namespace to be added.
Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. The possible values returned by this function are:

◆ removePackageNamespace()

int SBMLNamespaces::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.

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 value is drawn from the enumeration OperationReturnValues_t. The possible values returned by this function are: