libSBML C++ API  5.18.0
SBMLExtensionRegister< SBMLExtensionType > Class Template Reference

Detailed Description

template<class SBMLExtensionType>
class SBMLExtensionRegister< SBMLExtensionType >

Template class for extension package registration

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 registration template class for SBML package extensions in libSBML. It is used by package extensions to register themselves with the SBMLExtensionRegistry when libSBML starts up. An instance of this class needs to be created by each package extension and used in a call to a method on SBMLExtensionRegistry.

How to use SBMLExtensionRegister in a package extension

When a package extension is first loaded, it must register itself with the registry of extensions maintained by the cleverly-named SBMLExtensionRegistry class. That registry is how other classes in libSBML access information about the packages recognized by a particular copy of libSML; a corollary is that libSBML can't parse or even recognize SBML Level 3 packages that have no corresponding extension registered with SBMLExtensionRegistry.

The SBMLExtensionRegister class is a template class for automatically registering each package extension to the SBMLExtensionRegistry class at startup time. The class and its use are very simple. An implementation of a package extension merely needs to use it to instantiate one object. The class used in the template invocation should be the extension derived from SBMLExtension (e.g., LayoutExtension for the Layout package). The following is an example:

The line above is typically be placed in the .cpp file associated with the definition of the SBMLExtension-derived class; in the case of the Layout package, this is LayoutExtension.cpp.

The result of doing the above is that the init() method on LayoutExtension will be automatically invoked when the "register" object is instantiated. This results in initialization and registration of the package extension with libSBML.

Examples:
spec_example1.cpp, spec_example2.cpp, spec_example3.cpp, and spec_example4.cpp.

Public Member Functions

 SBMLExtensionRegister ()
 Constructor for SBMLExtensionRegister. More...
 

Constructor & Destructor Documentation

template<class SBMLExtensionType>
SBMLExtensionRegister< SBMLExtensionType >::SBMLExtensionRegister ( )
inline

Constructor for SBMLExtensionRegister.

This simple constructor arranges for the initialization code of the corresponding package extension to be executed when an object of this class is created. Specifically, it causes the init() method on the SBMLExtension-derived class to be called when the package is registered with SBMLExtensionRegistry. Extension packages should put any necessary initialization code in their init() method.