本文整理汇总了C++中Cfg::start方法的典型用法代码示例。如果您正苦于以下问题:C++ Cfg::start方法的具体用法?C++ Cfg::start怎么用?C++ Cfg::start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cfg
的用法示例。
在下文中一共展示了Cfg::start方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseConfig
/**
* parses configuration and adjusts/creates module graph accordingly
* afterwards all modules are started
*/
void ConfigManager::parseConfig(std::string fileName)
{
lockGraph();
Graph* oldGraph = graph;
graph = new Graph();
old_document = document;
document = XMLDocument::parse_file(fileName);
XMLElement* root = document->getRootNode();
// consistency checks
if (!root) {
unlockGraph();
THROWEXCEPTION("%s is an empty XML-Document!", fileName.c_str());
}
if (!root->matches("ipfixConfig")) {
unlockGraph();
THROWEXCEPTION("Root element does not match \"ipfixConfig\"."
" This is not a valid configuration file!");
}
/* process each root element node and add a new node (with its config
* attached to the node) to the graph
*/
XMLNode::XMLSet<XMLElement*> rootElements = root->getElementChildren();
for (XMLNode::XMLSet<XMLElement*>::const_iterator it = rootElements.begin();
it != rootElements.end();
it++) {
bool found = false;
for (unsigned int i = 0; i < ARRAY_SIZE(configModules); i++) {
if ((*it)->getName() == configModules[i]->getName()) {
Cfg* cfg = configModules[i]->create(*it);
// handle special modules
SensorManagerCfg* smcfg = dynamic_cast<SensorManagerCfg*>(cfg);
if (smcfg) {
// SensorManager will not be connected to any modules, so its instance
// needs to be started manually
smcfg->setGraphIS(this);
sensorManager = smcfg->getInstance();
}
graph->addNode(cfg);
found = true;
}
}
if (!found) {
msg(MSG_ERROR, "Unknown cfg entry %s found", (*it)->getName().c_str());
}
}
if (!oldGraph) { // this is the first config we have read
Connector connector;
graph->accept(&connector);
} else {
// first, connect the nodes on the new graph (but NOT the modules)
Connector connector(true, false);
graph->accept(&connector);
// now connect the modules reusing those from the old graph
graph = reconnect(graph, oldGraph);
}
// start the instances if not already running
std::vector<CfgNode*> topoNodes = graph->topoSort();
for (size_t i = 0; i < topoNodes.size(); i++) {
Cfg* cfg = topoNodes[topoNodes.size() -1 -i]->getCfg();
msg(MSG_INFO, "Starting module %s", cfg->getName().c_str());
cfg->start(false);
}
if (old_document)
delete old_document;
unlockGraph();
}