Loading...
Searching...
No Matches
doc_extension_sbmlextensionregister Class Reference

## Detailed Description

  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:

static SBMLExtensionRegister<LayoutExtension> layoutExtensionRegistry;

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.