- std::string subsystem(arg->getStringValue("subsystem"));
- std::string name = arg->getStringValue("name");
- if (subsystem.empty()) {
- SG_LOG(SG_GENERAL, SG_ALERT, "do_add_subsystem:"
- << "no subsystem/name supplied");
- return false;
- }
-
-
- if (name.empty()) {
- // default name is simply the subsytem's name
- name = subsystem;
- }
-
- if (globals->get_subsystem_mgr()->get_subsystem(name)) {
- SG_LOG(SG_GENERAL, SG_ALERT, "do_add_subsystem:"
- << "duplicate subsystem name:" << name);
- return false;
- }
-
- std::string groupname = arg->getStringValue("group");
- SGSubsystemMgr::GroupType group = SGSubsystemMgr::GENERAL;
- if (!groupname.empty()) {
- group = mapGroupNameToType(groupname);
- }
-
- SGSubsystem* instance = NULL;
- try {
- instance = createSubsystemByName(subsystem);
- } catch (sg_exception& e) {
- SG_LOG(SG_GENERAL, SG_ALERT, "subsystem creation failed:" <<
- name << ":" << e.getFormattedMessage());
- return false;
- }
-
- bool doInit = arg->getBoolValue("do-bind-init", false);
- if (doInit) {
- instance->bind();
- instance->init();
- }
-
- double minTime = arg->getDoubleValue("min-time-sec", 0.0);
- globals->get_subsystem_mgr()->add(name.c_str(), instance,
- group, minTime);
-
- return true;