std::vector<NodeTree<int>*>* GraphStructuredStack::getReachable(NodeTree<int>* start, int length) { std::vector<NodeTree<int>*>* reachableList = new std::vector<NodeTree<int>*>(); std::queue<NodeTree<int>*> currentNodes; std::queue<NodeTree<int>*> nextNodes; currentNodes.push(start); for (int i = 0; i < length; i++) { while (!currentNodes.empty()) { NodeTree<int>* currentNode = currentNodes.front(); currentNodes.pop(); std::vector<NodeTree<int>*> children = currentNode->getChildren(); //std::cout << currentNode->getData() << " has children "; for (std::vector<NodeTree<int>*>::size_type j = 0; j < children.size(); j++) { std::cout << children[j]->getData() << " "; nextNodes.push(children[j]); } std::cout << std::endl; } currentNodes = nextNodes; //No clear function, so go through and remove while(!nextNodes.empty()) nextNodes.pop(); } while (!currentNodes.empty()) { reachableList->push_back(currentNodes.front()); //std::cout << currentNodes.front()->getData() << " is reachable from " << start->getData() << " by length " << length << std::endl; currentNodes.pop(); } return reachableList; }
/*! Load the plugin options. \param server The server object to use. */ int PluginsManager::loadOptions (Server *server) { int ret = 0; string key ("server.plugins"); NodeTree<string>* node = server->getNodeTree (key); if (node == NULL) return 0; list<NodeTree<string>*> *children = node->getChildren (); if (children == NULL) return 0; string namespaceKey ("namespace"); string pluginKey ("plugin"); string globalKey ("global"); string enabledKey ("enabled"); for (list<NodeTree<string>*>::iterator it = children->begin (); it != children->end (); it++) { NodeTree<string>* node = *it; string plugin; string namespaceName; bool global = false; bool enabled = false; if (node->getAttr (namespaceKey)) namespaceName.assign (*node->getAttr (namespaceKey)); if (node->getAttr (pluginKey)) plugin.assign (*node->getAttr (pluginKey)); if (node->getAttr (globalKey)) global = stringcmpi (*node->getAttr (globalKey), "YES") == 0; if (node->getAttr (enabledKey)) enabled = stringcmpi (*node->getAttr (enabledKey), "YES") == 0; if (plugin.length ()) addPluginInfo (plugin, new PluginInfo (plugin, enabled, global)); else { server->log (MYSERVER_LOG_MSG_WARNING, _("Invalid plugin name in PLUGIN block.")); ret = -1; } } return ret; }