/* * Initializes groups extension by creating an object of this class with the * required SBasePlugin derived objects and registering the object to the * SBMLExtensionRegistry class */ void GroupsExtension::init() { if (SBMLExtensionRegistry::getInstance().isRegistered(getPackageName())) { return; } GroupsExtension groupsExtension; 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); groupsExtension.addSBasePluginCreator(&sbmldocPluginCreator); groupsExtension.addSBasePluginCreator(&modelPluginCreator); SBMLExtensionRegistry::getInstance().addExtension(&groupsExtension); }
/* * * 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; } }