libSBML C++ API  5.20.2
SBMLExtensionRegistry Class Reference

Detailed Description

Registry where package extensions are registered.

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 class provides a central registry of all extensions known to libSBML. Each package extension must be registered with the registry. The registry class is accessed by various classes to retrieve information about known package extensions and to create additional attributes and/or elements by factory objects of the package extensions.

The package extension registry is implemented as a singleton instance of SBMLExtensionRegistry. The class provides only utility functionality; implementations of SBML packages do not need to implement any subclasses or methods of this class. SBMLExtensionRegistry is useful for its facilities to query the known packages, and to enable or disable packages selectively.

Public Member Functions

int addExtension (const SBMLExtension *ext)
 Add the given SBMLExtension object to this SBMLExtensionRegistry. More...
 
void addL2Namespaces (XMLNamespaces *xmlns) const
 Adds SBML Level 2 namespaces to the namespace list. More...
 
void disableUnusedPackages (SBMLDocument *doc)
 Disables unused packages. More...
 
void enableL2NamespaceForDocument (SBMLDocument *doc) const
 Enables package extensions that support serialization to SBML annotations. More...
 
const ASTBasePlugin * getASTPlugin (unsigned int i)
 
std::vector< ASTBasePlugin * > getASTPlugins ()
 
SBMLExtensiongetExtension (const std::string &package)
 Returns an SBMLExtension object with the given package URI or package name. More...
 
unsigned int getNumASTPlugins ()
 
unsigned int getNumExtension (const SBaseExtensionPoint &extPoint)
 Returns the number of extensions that have a given extension point. More...
 
bool isEnabled (const std::string &uri)
 Returns true if the given extension is enabled. More...
 
bool isRegistered (const std::string &uri)
 Returns true if a package extension is registered for the corresponding package URI. More...
 
void removeL2Namespaces (XMLNamespaces *xmlns) const
 Removes SBML Level 2 namespaces from the namespace list. More...
 
bool setEnabled (const std::string &uri, bool isEnabled)
 Enables or disable the package with the given URI. More...
 

Static Public Member Functions

static void disablePackage (const std::string &package)
 Disables the package with the given URI or name. More...
 
static void enablePackage (const std::string &package)
 Enables the package with the given URI / name. More...
 
static std::vector< std::string > getAllRegisteredPackageNames ()
 Returns a list of registered packages. More...
 
static SBMLExtensionRegistrygetInstance ()
 Returns a singleton instance of the registry. More...
 
static unsigned int getNumRegisteredPackages ()
 Returns the number of registered packages. More...
 
static std::string getRegisteredPackageName (unsigned int index)
 Returns the nth registered package. More...
 
static ListgetRegisteredPackageNames ()
 Returns a list of registered packages. More...
 
static bool isPackageEnabled (const std::string &package)
 Returns true if the named package is enabled. More...
 

Private Member Functions

const SBMLExtensiongetExtensionInternal (const std::string &package)
 Returns an SBMLExtension object with the given package URI or package name (string). More...
 
SBMLExtensionRegistryoperator= (const SBMLExtensionRegistry &rhs)
 
 SBMLExtensionRegistry ()
 
 SBMLExtensionRegistry (const SBMLExtensionRegistry &orig)
 
 ~SBMLExtensionRegistry ()
 

Static Private Attributes

static bool registered
 

Constructor & Destructor Documentation

◆ SBMLExtensionRegistry() [1/2]

SBMLExtensionRegistry::SBMLExtensionRegistry ( )
private

◆ SBMLExtensionRegistry() [2/2]

SBMLExtensionRegistry::SBMLExtensionRegistry ( const SBMLExtensionRegistry orig)
private

◆ ~SBMLExtensionRegistry()

SBMLExtensionRegistry::~SBMLExtensionRegistry ( )
private

Member Function Documentation

◆ addExtension()

int SBMLExtensionRegistry::addExtension ( const SBMLExtension ext)

Add the given SBMLExtension object to this SBMLExtensionRegistry.

Parameters
extthe SBMLExtension object 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:

◆ addL2Namespaces()

void SBMLExtensionRegistry::addL2Namespaces ( XMLNamespaces xmlns) const

Adds SBML Level 2 namespaces to the namespace list.

This will call all overridden SBMLExtension::addL2Namespaces() methods.

Parameters
xmlnsan XMLNamespaces object providing one or more namespaces to be added.

◆ disablePackage()

void SBMLExtensionRegistry::disablePackage ( const std::string &  package)
static

Disables the package with the given URI or name.

Parameters
packagea string representing the URI or name of the SBML package whose package extension is to be disabled.

◆ disableUnusedPackages()

void SBMLExtensionRegistry::disableUnusedPackages ( SBMLDocument doc)

Disables unused packages.

This method walks through all extensions in the list of plugins of the given SBML document doc, and disables all that are not being used.

Parameters
docthe SBMLDocument object whose unused package extensions should be disabled.

◆ enableL2NamespaceForDocument()

void SBMLExtensionRegistry::enableL2NamespaceForDocument ( SBMLDocument doc) const

Enables package extensions that support serialization to SBML annotations.

SBML Level 2 does not have a package mechanism in the way that SBML Level 3 does. However, SBML annotations can be used to store SBML constructs. In fact, a widely-used approach to developing SBML Level 3 packages involves first using them as annotations.

Parameters
docthe SBMLDocument object for which this should be enabled.

◆ enablePackage()

void SBMLExtensionRegistry::enablePackage ( const std::string &  package)
static

Enables the package with the given URI / name.

Parameters
packagethe name or URI of a package to enable.

◆ getAllRegisteredPackageNames()

std::vector< std::string > SBMLExtensionRegistry::getAllRegisteredPackageNames ( )
static

Returns a list of registered packages.

This method returns a vector of strings containing the nicknames of the SBML packages for which package extensions are registered with this copy of libSBML. The vector will contain std::string objects.

Returns
a vector of strings of the registered package names.

◆ getASTPlugin()

const ASTBasePlugin * SBMLExtensionRegistry::getASTPlugin ( unsigned int  i)

◆ getASTPlugins()

std::vector< ASTBasePlugin * > SBMLExtensionRegistry::getASTPlugins ( )

◆ getExtension()

SBMLExtension* SBMLExtensionRegistry::getExtension ( const std::string &  package)

Returns an SBMLExtension object with the given package URI or package name.

Parameters
packagea string representing the URI or name of the SBML package whose package extension is being sought.
Returns
a clone of the SBMLExtension object with the given package URI or name.
Note
The caller is responsible for freeing the object returned. Since the object is a clone, freeing it will not result in the deletion of the original package extension object.

◆ getExtensionInternal()

const SBMLExtension* SBMLExtensionRegistry::getExtensionInternal ( const std::string &  package)
private

Returns an SBMLExtension object with the given package URI or package name (string).

Parameters
packagethe URI or name of the package extension.
Returns
the SBMLExtension object with the given package URI or name. The returned extension is NOT ALLOWED to be freed (i.e.: deleted)!

◆ getInstance()

static SBMLExtensionRegistry& SBMLExtensionRegistry::getInstance ( )
static

Returns a singleton instance of the registry.

Callers need to obtain a copy of the package extension registry before they can invoke its methods. The registry is implemented as a singleton, and this is the method callers can use to get a copy of it.

Returns
the instance of the SBMLExtensionRegistry object.

◆ getNumASTPlugins()

unsigned int SBMLExtensionRegistry::getNumASTPlugins ( )

◆ getNumExtension()

unsigned int SBMLExtensionRegistry::getNumExtension ( const SBaseExtensionPoint extPoint)

Returns the number of extensions that have a given extension point.

Parameters
extPointthe SBaseExtensionPoint object.
Returns
the number of SBMLExtension-derived objects with the given extension point.

◆ getNumRegisteredPackages()

unsigned int SBMLExtensionRegistry::getNumRegisteredPackages ( )
static

Returns the number of registered packages.

Returns
a count of the registered package extensions.
See also
getRegisteredPackageNames()
Examples
printRegisteredPackages.cpp.

◆ getRegisteredPackageName()

std::string SBMLExtensionRegistry::getRegisteredPackageName ( unsigned int  index)
static

Returns the nth registered package.

Parameters
indexzero-based index of the package name to return.
Returns
the package name with the given index, or NULL if none such exists.
See also
getNumRegisteredPackages()
Examples
printRegisteredPackages.cpp.

◆ getRegisteredPackageNames()

List * SBMLExtensionRegistry::getRegisteredPackageNames ( )
static

Returns a list of registered packages.

This method returns a List object containing the nicknames of the SBML packages for which package extensions are registered with this copy of libSBML. The list will contain strings (e.g., "layout", "fbc", etc.) and has to be freed by the caller.

Returns
a list of strings representing the names of the registered packages.

◆ isEnabled()

bool SBMLExtensionRegistry::isEnabled ( const std::string &  uri)

Returns true if the given extension is enabled.

Parameters
urithe URI of the target package.
Returns
false if the given package is disabled or not registered, true otherwise.

◆ isPackageEnabled()

bool SBMLExtensionRegistry::isPackageEnabled ( const std::string &  package)
static

Returns true if the named package is enabled.

Parameters
packagethe name or URI of a package to test.
Returns
true if the package is enabled, false otherwise.
Examples
flattenModel.cpp.

◆ isRegistered()

bool SBMLExtensionRegistry::isRegistered ( const std::string &  uri)

Returns true if a package extension is registered for the corresponding package URI.

Parameters
urithe URI of the target package.
Returns
true if the package with the given URI is registered, otherwise returns false.

◆ operator=()

SBMLExtensionRegistry& SBMLExtensionRegistry::operator= ( const SBMLExtensionRegistry rhs)
private

◆ removeL2Namespaces()

void SBMLExtensionRegistry::removeL2Namespaces ( XMLNamespaces xmlns) const

Removes SBML Level 2 namespaces from the namespace list.

This will call all overridden SBMLExtension::removeL2Namespaces() methods.

Parameters
xmlnsan XMLNamespaces object listing one or more namespaces to be removed.

◆ setEnabled()

bool SBMLExtensionRegistry::setEnabled ( const std::string &  uri,
bool  isEnabled 
)

Enables or disable the package with the given URI.

Parameters
urithe URI of the target package.
isEnabledtrue to enable the package, false to disable.
Returns
false if isEnabled is false or the given package is not registered, otherwise this method returns true.

Member Data Documentation

◆ registered

bool SBMLExtensionRegistry::registered
staticprivate