void TestExtension::init() { if (SBMLExtensionRegistry::getInstance().isRegistered(getPackageName())) { return; } TestExtension testExtension; std::vector<std::string> packageURIs; packageURIs.push_back(getXmlnsL3V1V1()); SBaseExtensionPoint sbmldocExtPoint("core",SBML_DOCUMENT); SBaseExtensionPoint modelExtPoint("core",SBML_MODEL); SBasePluginCreator<SBMLDocumentPlugin, TestExtension> sbmldocPluginCreator(sbmldocExtPoint,packageURIs); SBasePluginCreator<TestModelPlugin, TestExtension> modelPluginCreator(modelExtPoint,packageURIs); testExtension.addSBasePluginCreator(&sbmldocPluginCreator); testExtension.addSBasePluginCreator(&modelPluginCreator); int result = SBMLExtensionRegistry::getInstance().addExtension(&testExtension); if (result != LIBSBML_OPERATION_SUCCESS) { std::cerr << "[Error] TestExtension::init() failed." << std::endl; } }
/* * Initialization function of req extension module which is automatically invoked * by SBMLExtensionRegister class before main() function invoked. */ void ReqExtension::init() { //---------------------------------------------------------------- // // 1. Check if the req package has already been registered // //---------------------------------------------------------------- if (SBMLExtensionRegistry::getInstance().isRegistered(getPackageName())) { // do nothing return; } //---------------------------------------------------------------- // // 2. Creates an SBMLExtension derived object // //---------------------------------------------------------------- ReqExtension reqExtension; //---------------------------------------------------------------- // // 3. Creates the SBasePlugins required by this package // //---------------------------------------------------------------- std::vector<std::string> packageURIs; packageURIs.push_back(getXmlnsL3V1V1()); SBaseExtensionPoint sbmldocExtPoint("core", SBML_DOCUMENT); SBaseExtensionPoint sbaseExtPoint("all", SBML_GENERIC_SBASE); SBasePluginCreator<ReqSBMLDocumentPlugin, ReqExtension> sbmldocPluginCreator(sbmldocExtPoint, packageURIs); SBasePluginCreator<ReqSBasePlugin, ReqExtension> sbasePluginCreator(sbaseExtPoint, packageURIs); //---------------------------------------------------------------- // // 4. Adds the creator objects to the extension // //---------------------------------------------------------------- reqExtension.addSBasePluginCreator(&sbmldocPluginCreator); reqExtension.addSBasePluginCreator(&sbasePluginCreator); //---------------------------------------------------------------- // // 5. Register the object with the registry // //---------------------------------------------------------------- int result = SBMLExtensionRegistry::getInstance().addExtension(&reqExtension); if (result != LIBSBML_OPERATION_SUCCESS) { std::cerr << "[Error] ReqExtension::init() failed." << std::endl; } }
SBMLNamespaces* TestExtension::getSBMLExtensionNamespaces(const std::string &uri) const { TestPkgNamespaces* pkgns = NULL; if ( uri == getXmlnsL3V1V1()) { pkgns = new TestPkgNamespaces(3,1,1); } return pkgns; }
unsigned int TestExtension::getPackageVersion(const std::string &uri) const { if (uri == getXmlnsL3V1V1()) { return 1; } return 0; }
/* * Returns an SBMLExtensionNamespaces<class SBMLExtensionType> object * (e.g. SBMLExtensionNamespaces<GroupsExtension> whose alias type is * GroupsPkgNamespaces) corresponding to the given uri. * NULL will be returned if the given uri is not defined in the corresponding package. * * (NOTICE) Package developers MUST OVERRIDE this pure virtual function in their derived class. * */ SBMLNamespaces* GroupsExtension::getSBMLExtensionNamespaces(const std::string &uri) const { GroupsPkgNamespaces* pkgns = 0; if ( uri == getXmlnsL3V1V1()) { pkgns = new GroupsPkgNamespaces(3,1,1); } return pkgns; }
/* * Returns the SBML version with the given URI of this package. * * (NOTICE) Package developers MUST OVERRIDE this pure virtual function in their derived class. * */ unsigned int GroupsExtension::getVersion(const std::string &uri) const { if (uri == getXmlnsL3V1V1()) { return 1; } return 0; }
unsigned int TestExtension::getLevel(const std::string &uri) const { if (uri == getXmlnsL3V1V1()) { return 3; } return 0; }
/* * Returns the SBML level with the given URI of this package. */ unsigned int LayoutExtension::getLevel(const std::string &uri) const { if (uri == getXmlnsL3V1V1()) { return 3; } else if (uri == getXmlnsL2()) { return 2; } return 0; }
/* * Returns the package version with the given URI of this package. */ unsigned int LayoutExtension::getPackageVersion(const std::string &uri) const { if (uri == getXmlnsL3V1V1()) { return 1; } else if (uri == getXmlnsL2()) { // // (NOTE) This should be harmless but may cause some problem. // return 1; } return 0; }
/* * Returns an SBMLExtensionNamespaces<class SBMLExtensionType> object * (e.g. SBMLExtensionNamespaces<LayoutExtension> whose alias type is * LayoutPkgNamespaces) corresponding to the given uri. * Null will be returned if the given uri is not defined in the corresponding package. */ SBMLNamespaces* LayoutExtension::getSBMLExtensionNamespaces(const std::string &uri) const { LayoutPkgNamespaces* pkgns = NULL; if ( uri == getXmlnsL3V1V1()) { pkgns = new LayoutPkgNamespaces(3,1,1); } else if ( uri == getXmlnsL2()) { // // (NOTE) This should be harmless but may cause some problem. // pkgns = new LayoutPkgNamespaces(2); } return pkgns; }
/* * Returns the SBML version with the given URI of this package. */ unsigned int LayoutExtension::getVersion(const std::string &uri) const { if (uri == getXmlnsL3V1V1()) { return 1; } else if (uri == getXmlnsL2()) { // // (NOTE) This may cause unexpected behaviour. // /* which indeed it does */ return 1; } return 0; }
const std::string& TestExtension::getURI(unsigned int sbmlLevel, unsigned int sbmlVersion, unsigned int pkgVersion) const { if (sbmlLevel == 3) { if (sbmlVersion == 1) { if (pkgVersion == 1) { return getXmlnsL3V1V1(); } } } static std::string empty = ""; return empty; }
/* * * Initialization function of groups extension module which is automatically invoked * by SBMLExtensionRegister class before main() function invoked. * */ void GroupsExtension::init() { //------------------------------------------------------------------------- // // 1. Checks if the groups pacakge has already been registered. // //------------------------------------------------------------------------- if (SBMLExtensionRegistry::getInstance().isRegistered(getPackageName())) { // do nothing; return; } //------------------------------------------------------------------------- // // 2. Creates an SBMLExtension derived object. // //------------------------------------------------------------------------- GroupsExtension groupsExtension; //------------------------------------------------------------------------------------- // // 3. Creates SBasePluginCreatorBase derived objects required for this // extension. The derived classes can be instantiated by using the following // template class. // // temaplate<class SBasePluginType> class SBasePluginCreator // // The constructor of the creator class has two arguments: // // (1) SBaseExtensionPoint : extension point to which the plugin object connected // (2) std::vector<std::string> : a std::vector object that contains a list of URI // (package versions) supported by the plugin object. // // For example, two plugin objects (plugged in SBMLDocument and Model elements) are // required for the groups extension. // // Since only 'required' attribute is used in SBMLDocument by the groups package, existing // SBMLDocumentPluginNotRequired class can be used as-is for the plugin. // // Since the lists of supported package versions (currently only L3V1-groups-V1 supported ) // are equal in the both plugin objects, the same vector object is given to each // constructor. // //--------------------------------------------------------------------------------------- std::vector<std::string> packageURIs; packageURIs.push_back(getXmlnsL3V1V1()); SBaseExtensionPoint sbmldocExtPoint("core",SBML_DOCUMENT); SBaseExtensionPoint modelExtPoint("core",SBML_MODEL); SBasePluginCreator<GroupsSBMLDocumentPlugin, GroupsExtension> sbmldocPluginCreator(sbmldocExtPoint, packageURIs); SBasePluginCreator<GroupsModelPlugin, GroupsExtension> modelPluginCreator(modelExtPoint,packageURIs); //-------------------------------------------------------------------------------------- // // 3. Adds the above SBasePluginCreatorBase derived objects to the SBMLExtension derived object. // //-------------------------------------------------------------------------------------- groupsExtension.addSBasePluginCreator(&sbmldocPluginCreator); groupsExtension.addSBasePluginCreator(&modelPluginCreator); //------------------------------------------------------------------------- // // 4. Registers the SBMLExtension derived object to SBMLExtensionRegistry // //------------------------------------------------------------------------- int result = SBMLExtensionRegistry::getInstance().addExtension(&groupsExtension); if (result != LIBSBML_OPERATION_SUCCESS) { std::cerr << "[Error] GroupsExtension::init() failed." << std::endl; } }
/* * Initialization function of multi extension module which is automatically invoked * by SBMLExtensionRegister class before main() function invoked. */ void MultiExtension::init() { //---------------------------------------------------------------- // // 1. Check if the multi package has already been registered // //---------------------------------------------------------------- if (SBMLExtensionRegistry::getInstance().isRegistered(getPackageName())) { // do nothing return; } //---------------------------------------------------------------- // // 2. Creates an SBMLExtension derived object // //---------------------------------------------------------------- MultiExtension multiExtension; //---------------------------------------------------------------- // // 3. Creates the SBasePlugins required by this package // //---------------------------------------------------------------- std::vector<std::string> packageURIs; packageURIs.push_back(getXmlnsL3V1V1()); SBaseExtensionPoint sbmldocExtPoint("core", SBML_DOCUMENT); SBaseExtensionPoint modelExtPoint("core", SBML_MODEL); SBaseExtensionPoint compartmentExtPoint("core", SBML_COMPARTMENT); SBaseExtensionPoint speciesExtPoint("core", SBML_SPECIES); SBaseExtensionPoint reactionExtPoint("core", SBML_REACTION); SBaseExtensionPoint simplespeciesreferenceExtPoint("core", SBML_MODIFIER_SPECIES_REFERENCE); SBaseExtensionPoint speciesreferenceExtPoint("core", SBML_SPECIES_REFERENCE); SBasePluginCreator<MultiSBMLDocumentPlugin, MultiExtension> sbmldocPluginCreator(sbmldocExtPoint, packageURIs); SBasePluginCreator<MultiModelPlugin, MultiExtension> modelPluginCreator(modelExtPoint, packageURIs); SBasePluginCreator<MultiCompartmentPlugin, MultiExtension> compartmentPluginCreator(compartmentExtPoint, packageURIs); SBasePluginCreator<MultiSpeciesPlugin, MultiExtension> speciesPluginCreator(speciesExtPoint, packageURIs); SBasePluginCreator<MultiReactionPlugin, MultiExtension> reactionPluginCreator(reactionExtPoint, packageURIs); SBasePluginCreator<MultiSimpleSpeciesReferencePlugin, MultiExtension> simplespeciesreferencePluginCreator(simplespeciesreferenceExtPoint, packageURIs); SBasePluginCreator<MultiSpeciesReferencePlugin, MultiExtension> speciesreferencePluginCreator(speciesreferenceExtPoint, packageURIs); //---------------------------------------------------------------- // // 4. Adds the creator objects to the extension // //---------------------------------------------------------------- multiExtension.addSBasePluginCreator(&sbmldocPluginCreator); multiExtension.addSBasePluginCreator(&modelPluginCreator); multiExtension.addSBasePluginCreator(&compartmentPluginCreator); multiExtension.addSBasePluginCreator(&speciesPluginCreator); multiExtension.addSBasePluginCreator(&reactionPluginCreator); multiExtension.addSBasePluginCreator(&simplespeciesreferencePluginCreator); multiExtension.addSBasePluginCreator(&speciesreferencePluginCreator); multiExtension.setASTBasePlugin(new MultiASTPlugin(getXmlnsL3V1V1())); //---------------------------------------------------------------- // // 5. Register the object with the registry // //---------------------------------------------------------------- int result = SBMLExtensionRegistry::getInstance().addExtension(&multiExtension); if (result != LIBSBML_OPERATION_SUCCESS) { std::cerr << "[Error] MultiExtension::init() failed." << std::endl; } }
/* * Initialization function of spatial extension module which is automatically invoked * by SBMLExtensionRegister class before main() function invoked. */ void SpatialExtension::init() { //---------------------------------------------------------------- // // 1. Check if the spatial package has already been registered // //---------------------------------------------------------------- if (SBMLExtensionRegistry::getInstance().isRegistered(getPackageName())) { // do nothing return; } //---------------------------------------------------------------- // // 2. Creates an SBMLExtension derived object // //---------------------------------------------------------------- SpatialExtension spatialExtension; //---------------------------------------------------------------- // // 3. Creates the SBasePlugins required by this package // //---------------------------------------------------------------- std::vector<std::string> packageURIs; packageURIs.push_back(getXmlnsL3V1V1()); SBaseExtensionPoint sbmldocExtPoint("core", SBML_DOCUMENT); SBaseExtensionPoint modelExtPoint("core", SBML_MODEL); SBaseExtensionPoint compartmentExtPoint("core", SBML_COMPARTMENT); SBaseExtensionPoint speciesExtPoint("core", SBML_SPECIES); SBaseExtensionPoint parameterExtPoint("core", SBML_PARAMETER); SBaseExtensionPoint reactionExtPoint("core", SBML_REACTION); SBasePluginCreator<SpatialSBMLDocumentPlugin, SpatialExtension> sbmldocPluginCreator(sbmldocExtPoint, packageURIs); SBasePluginCreator<SpatialModelPlugin, SpatialExtension> modelPluginCreator(modelExtPoint, packageURIs); SBasePluginCreator<SpatialCompartmentPlugin, SpatialExtension> compartmentPluginCreator(compartmentExtPoint, packageURIs); SBasePluginCreator<SpatialSpeciesPlugin, SpatialExtension> speciesPluginCreator(speciesExtPoint, packageURIs); SBasePluginCreator<SpatialParameterPlugin, SpatialExtension> parameterPluginCreator(parameterExtPoint, packageURIs); SBasePluginCreator<SpatialReactionPlugin, SpatialExtension> reactionPluginCreator(reactionExtPoint, packageURIs); //---------------------------------------------------------------- // // 4. Adds the creator objects to the extension // //---------------------------------------------------------------- spatialExtension.addSBasePluginCreator(&sbmldocPluginCreator); spatialExtension.addSBasePluginCreator(&modelPluginCreator); spatialExtension.addSBasePluginCreator(&compartmentPluginCreator); spatialExtension.addSBasePluginCreator(&speciesPluginCreator); spatialExtension.addSBasePluginCreator(¶meterPluginCreator); spatialExtension.addSBasePluginCreator(&reactionPluginCreator); //---------------------------------------------------------------- // // 5. Register the object with the registry // //---------------------------------------------------------------- int result = SBMLExtensionRegistry::getInstance().addExtension(&spatialExtension); if (result != LIBSBML_OPERATION_SUCCESS) { std::cerr << "[Error] SpatialExtension::init() failed." << std::endl; } }
/* * * Initialization function of layout extension module which is automatically invoked * by SBMLExtensionRegister class before main() function invoked. * */ void LayoutExtension::init() { //------------------------------------------------------------------------- // // 1. Checks if the layout package has already been registered. // //------------------------------------------------------------------------- if (SBMLExtensionRegistry::getInstance().isRegistered(getPackageName())) { // do nothing; return; } //------------------------------------------------------------------------- // // 2. Creates an SBMLExtension derived object. // //------------------------------------------------------------------------- LayoutExtension layoutExtension; //------------------------------------------------------------------------------------- // // 3. Creates SBasePluginCreatorBase derived objects required for this extension. // The derived classes can be instantiated by using the following template class. // // temaplate<class SBasePluginType> class SBasePluginCreator // // The constructor of the creator class has two arguments: // // (1) SBaseExtensionPoint : extension point to which the plugin object connected // (2) std::vector<std::string> : a std::vector object that contains a list of URI // (package versions) supported by the plugin object. // // For example, three plugin classes (plugged in SBMLDocument, Model, and SpeciesReference) // are required for the layout extension (The plugin class for SpeciesReference is required // only for SBML Level 2) . // //--------------------------------------------------------------------------------------- std::vector<std::string> packageURIs; packageURIs.push_back(getXmlnsL3V1V1()); packageURIs.push_back(getXmlnsL2()); // // LayoutSpeciesReferencePlugin is used only for SBML Level 2 // std::vector<std::string> L2packageURI; L2packageURI.push_back(getXmlnsL2()); SBaseExtensionPoint sbmldocExtPoint("core",SBML_DOCUMENT); SBaseExtensionPoint modelExtPoint("core",SBML_MODEL); SBaseExtensionPoint sprExtPoint("core",SBML_SPECIES_REFERENCE); SBaseExtensionPoint msprExtPoint("core",SBML_MODIFIER_SPECIES_REFERENCE); SBasePluginCreator<LayoutSBMLDocumentPlugin, LayoutExtension> sbmldocPluginCreator(sbmldocExtPoint, packageURIs); SBasePluginCreator<LayoutModelPlugin, LayoutExtension> modelPluginCreator(modelExtPoint,packageURIs); SBasePluginCreator<LayoutSpeciesReferencePlugin, LayoutExtension> sprPluginCreator(sprExtPoint,L2packageURI); SBasePluginCreator<LayoutSpeciesReferencePlugin, LayoutExtension> msprPluginCreator(msprExtPoint,L2packageURI); //------------------------------------------------------------------------------------------ // // 4. Adds the above SBasePluginCreatorBase derived objects to the SBMLExtension derived object. // //------------------------------------------------------------------------------------------ layoutExtension.addSBasePluginCreator(&sbmldocPluginCreator); layoutExtension.addSBasePluginCreator(&modelPluginCreator); layoutExtension.addSBasePluginCreator(&sprPluginCreator); layoutExtension.addSBasePluginCreator(&msprPluginCreator); //------------------------------------------------------------------------- // // 5. Registers the SBMLExtension derived object to SBMLExtensionRegistry // //------------------------------------------------------------------------- int result = SBMLExtensionRegistry::getInstance().addExtension(&layoutExtension); if (result != LIBSBML_OPERATION_SUCCESS) { std::cerr << "[Error] LayoutExtension::init() failed." << std::endl; } }
/* * * Initialization function of groups extension module which is automatically invoked * by SBMLExtensionRegister class before main() function invoked. * */ void RenderExtension::init() { //------------------------------------------------------------------------- // // 1. Checks if the groups pacakge has already been registered. // //------------------------------------------------------------------------- if (SBMLExtensionRegistry::getInstance().isRegistered(getPackageName())) { // do nothing; return; } //------------------------------------------------------------------------- // // 2. Creates an SBMLExtension derived object. // //------------------------------------------------------------------------- RenderExtension renderExtension; //------------------------------------------------------------------------------------- // // 3. Creates SBasePluginCreatorBase derived objects required for this // extension. The derived classes can be instantiated by using the following // template class. // // temaplate<class SBasePluginType> class SBasePluginCreator // // The constructor of the creator class has two arguments: // // (1) SBaseExtensionPoint : extension point to which the plugin object connected // (2) std::vector<std::string> : a std::vector object that contains a list of URI // (package versions) supported by the plugin object. // // For example, two plugin objects (plugged in SBMLDocument and Model elements) are // required for the groups extension. // // Since only 'required' attribute is used in SBMLDocument by the groups package, existing // SBMLDocumentPluginNotRequired class can be used as-is for the plugin. // // Since the lists of supported package versions (currently only L3V1-groups-V1 supported ) // are equal in the both plugin objects, the same vector object is given to each // constructor. // //--------------------------------------------------------------------------------------- std::vector<std::string> packageURIs; packageURIs.push_back(getXmlnsL3V1V1()); packageURIs.push_back(getXmlnsL2()); // // LayoutSpeciesReferencePlugin is used only for SBML Level 2 // std::vector<std::string> L2packageURI; L2packageURI.push_back(getXmlnsL2()); SBaseExtensionPoint sbmldocExtPoint("core",SBML_DOCUMENT); SBaseExtensionPoint layoutExtPoint("layout",SBML_LAYOUT_LAYOUT); SBaseExtensionPoint layoutGOExtPoint("layout",SBML_LAYOUT_GRAPHICALOBJECT); SBaseExtensionPoint clayoutExtPoint("core",SBML_LAYOUT_LAYOUT); SBaseExtensionPoint listOfLayoutsExtPoint("layout", SBML_LIST_OF); SBasePluginCreator<RenderSBMLDocumentPlugin, RenderExtension> sbmldocPluginCreator(sbmldocExtPoint,packageURIs); SBasePluginCreator<RenderLayoutPlugin, RenderExtension> layoutPluginCreator(layoutExtPoint,packageURIs); SBasePluginCreator<RenderLayoutPlugin, RenderExtension> clayoutPluginCreator(clayoutExtPoint,packageURIs); SBasePluginCreator<RenderListOfLayoutsPlugin, RenderExtension> lolPluginCreator(listOfLayoutsExtPoint,packageURIs); SBasePluginCreator<RenderGraphicalObjectPlugin, RenderExtension> goPluginCreator(layoutGOExtPoint,packageURIs); //-------------------------------------------------------------------------------------- // // 3. Adds the above SBasePluginCreatorBase derived objects to the SBMLExtension derived object. // //-------------------------------------------------------------------------------------- renderExtension.addSBasePluginCreator(&sbmldocPluginCreator); renderExtension.addSBasePluginCreator(&layoutPluginCreator); renderExtension.addSBasePluginCreator(&clayoutPluginCreator); renderExtension.addSBasePluginCreator(&lolPluginCreator); renderExtension.addSBasePluginCreator(&goPluginCreator); //------------------------------------------------------------------------- // // 4. Registers the SBMLExtension derived object to SBMLExtensionRegistry // //------------------------------------------------------------------------- int result = SBMLExtensionRegistry::getInstance().addExtension(&renderExtension); if (result != LIBSBML_OPERATION_SUCCESS) { std::cerr << "[Error] RenderExtension::init() failed." << std::endl; } // add converter to registry; RenderLayoutConverter rlc; SBMLConverterRegistry::getInstance().addConverter(&rlc); }