本文整理汇总了C++中CfgNode类的典型用法代码示例。如果您正苦于以下问题:C++ CfgNode类的具体用法?C++ CfgNode怎么用?C++ CfgNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CfgNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _get_commit_other_node
static CfgNode *
_get_commit_other_node(CfgNode *cfg1, CfgNode *cfg2, const Cpath& cur_path)
{
string name, value;
bool not_tag_node, is_value, is_leaf_typeless;
vector<CfgNode *> rcnodes1, rcnodes2;
cnode::cmp_non_leaf_nodes(cfg1, cfg2, rcnodes1, rcnodes2, not_tag_node,
is_value, is_leaf_typeless, name, value);
if (!cfg1) {
return _create_commit_cfg_node(*cfg2, cur_path, COMMIT_STATE_ADDED);
} else if (!cfg2) {
return _create_commit_cfg_node(*cfg1, cur_path, COMMIT_STATE_DELETED);
}
CfgNode *cn = _create_commit_cfg_node(*cfg1, cur_path,
COMMIT_STATE_UNCHANGED);
for (size_t i = 0; i < rcnodes1.size(); i++) {
CfgNode *cnode = getCommitTree(rcnodes1[i], rcnodes2[i],
cn->getCommitPath());
if (cnode) {
cn->addChildNode(cnode);
}
}
if (cn->numChildNodes() < 1) {
delete cn;
return NULL;
}
return cn;
}
示例2: getId2Node
Graph* Connector::connect(Graph* g)
{
const std::vector<CfgNode*>& nodes = g->getNodes();
std::map<unsigned int, CfgNode*> id2node = getId2Node(nodes);
for (unsigned int i = 0; i < nodes.size(); i++) {
CfgNode* fromNode = nodes[i];
Cfg* cfg = fromNode->getCfg();
std::vector<unsigned int> nexts = cfg->getNext();
for (unsigned int j = 0; j < nexts.size(); j++) {
CfgNode* toNode = id2node[nexts[j]];
if (toNode == NULL)
THROWEXCEPTION("next statement is illegal; there is no node with id=%d", nexts[j]);
if (connectNodes) // insert the connection in the graph
g->addEdge(fromNode, toNode);
msg(MSG_INFO, "Connecting module %s[Id = %d] -> %s[Id = %d]",
cfg->getName().c_str(), cfg->getID(),
id2node[nexts[j]]->getCfg()->getName().c_str(),
id2node[nexts[j]]->getCfg()->getID());
if (connectModules) {// connect the modules
DPRINTF("connecting instances");
cfg->connectInstances(toNode->getCfg());
}
}
}
return g;
}
示例3: lockGraph
void ConfigManager::shutdown()
{
lockGraph();
std::vector<CfgNode*> topoNodes = graph->topoSort();
// shutdown modules
for (size_t i = 0; i < topoNodes.size(); i++) {
Cfg* cfg = topoNodes[i]->getCfg();
msg(MSG_INFO, "shutting down module %s (id=%u)", cfg->getName().c_str(), cfg->getID());
cfg->shutdown(true, true);
}
// trigger sensorManager to get the final statistics of this Vermont run
if (sensorManager) {
sensorManager->retrieveStatistics(true);
}
// disconnect the modules
for (size_t i = 0; i < topoNodes.size(); i++) {
CfgNode* n = topoNodes[i];
Cfg* cfg = n->getCfg();
// disconnect the module from its sources ..
vector<CfgNode*> sources = graph->getSources(n);
msg(MSG_INFO, "disconnecting module %s (id=%u)", cfg->getName().c_str(), cfg->getID());
for (size_t k = 0; k < sources.size(); k++) {
sources[k]->getCfg()->disconnectInstances();
}
}
unlockGraph();
}
示例4: _set_node_commit_child_delete_failed
static void
_set_node_commit_child_delete_failed(CfgNode& node)
{
// recursively bottom-up
node.setCommitChildDeleteFailed();
if (node.getParent()) {
_set_node_commit_child_delete_failed(*(node.getParent()));
}
}
示例5: _set_node_commit_state
static void
_set_node_commit_state(CfgNode& node, CommitState s, bool recursive)
{
node.setCommitState(s);
if (recursive) {
for (size_t i = 0; i < node.numChildNodes(); i++) {
_set_node_commit_state(*(node.childAt(i)), s, recursive);
}
}
}
示例6: _create_commit_cfg_node
// "changed" single-value leaf nodes (this does apply to the value)
static CfgNode *
_create_commit_cfg_node(const CfgNode& cn, const Cpath& p, const string& val1,
const string& val2, bool def1, bool def2)
{
CfgNode *node = new CfgNode(cn);
_set_node_commit_state(*node, COMMIT_STATE_CHANGED, false);
_set_node_commit_path(*node, p, false);
node->setCommitValue(val1, val2, def1, def2);
return node;
}
示例7: _set_node_commit_create_failed
static void
_set_node_commit_create_failed(CfgNode& node)
{
// recursively top-down
if (node.getCommitState() == COMMIT_STATE_ADDED) {
// only set failure if the node is being created
node.setCommitCreateFailed();
}
for (size_t i = 0; i < node.numChildNodes(); i++) {
_set_node_commit_create_failed(*(node.childAt(i)));
}
}
示例8: _set_commit_subtree_changed
static void
_set_commit_subtree_changed(CfgNode& node)
{
// recursively bottom-up
if (node.commitSubtreeChanged()) {
// already set => terminate recursion
return;
}
node.setCommitSubtreeChanged();
if (node.getParent()) {
_set_commit_subtree_changed(*(node.getParent()));
}
}
示例9: CfgNode
CfgNode* Graph::addNode(Cfg* cfg)
{
if (nodes.size() + 1 >= reserved)
throw std::runtime_error("can't handle that many nodes");
CfgNode *n = new CfgNode(this, nodes.size());
n->setCfg(cfg);
nodes.push_back(n);
for (size_t i = 0; i < nodes.size(); i++) {
matrix[i][nodes.size()-1] = NULL;
matrix[nodes.size()-1][i] = NULL;
}
return n;
}
示例10: _exec_tmpl_actions
static bool
_exec_tmpl_actions(Cstore& cs, CommitState s, char *at_str,
const Cpath& path, const Cpath& disp_path,
const CfgNode& node, vtw_act_type act,
const vtw_def *def)
{
const vtw_node *actions = node.getActions(act);
if (!actions) {
// no actions => success
return true;
}
/* XXX this follows the logic in original implementation since some
* features are using it.
*/
const char *aenv = "ACTIVE";
switch (s) {
case COMMIT_STATE_ADDED:
case COMMIT_STATE_CHANGED:
aenv = "SET";
break;
case COMMIT_STATE_DELETED:
aenv = "DELETE";
break;
default:
break;
}
setenv("COMMIT_ACTION", aenv, 1);
set_in_delete_action((act == delete_act));
bool ret = cs.executeTmplActions(at_str, path, disp_path, actions, def);
set_in_delete_action(false);
unsetenv("COMMIT_ACTION");
return ret;
}
示例11: _get_commit_prio_subtrees
static void
_get_commit_prio_subtrees(CfgNode *sroot, PrioNode& parent)
{
if (!sroot) {
return;
}
PrioNode *pn = &parent;
// need a local copy since nodes can be detached
vector<CfgNode *> cnodes = sroot->getChildNodes();
if (sroot->getPriority() && (sroot->isValue() || !sroot->isTag())) {
// enforce hierarchical constraint
unsigned int prio = sroot->getPriority();
unsigned int pprio = parent.getPriority();
if (prio <= pprio) {
// can't have that => make it higher than parent priority
OUTPUT_USER("Warning: priority inversion [%s](%u) <= [%s](%u)\n"
" changing [%s] to (%u)\n",
sroot->getCommitPath().to_string().c_str(), prio,
parent.getCommitPath().to_string().c_str(), pprio,
sroot->getCommitPath().to_string().c_str(),
pprio + 1);
sroot->setPriority(pprio + 1);
}
// only non-"tag node" applies ("tag nodes" not used in prio tree)
pn = new PrioNode(sroot);
/* record the original parent in config tree. this will be used to
* enforce "hierarchical constraint" in the config. skip the tag node
* if this is a tag value since commit doesn't act on tag nodes.
*/
CfgNode *pnode = sroot->getParent();
pn->setCfgParent(sroot->isTag() ? pnode->getParent() : pnode);
parent.addChildNode(pn);
sroot->detachFromParent();
}
for (size_t i = 0; i < cnodes.size(); i++) {
_get_commit_prio_subtrees(cnodes[i], *pn);
}
}
示例12: _set_node_commit_path
static void
_set_node_commit_path(CfgNode& node, const Cpath &p, bool recursive)
{
node.setCommitPath(p, node.isValue(), node.getValue(), node.getName());
if (recursive) {
for (size_t i = 0; i < node.numChildNodes(); i++) {
_set_node_commit_path(*(node.childAt(i)), node.getCommitPath(),
recursive);
}
}
}
示例13: getId2Node
Graph* Connector::connect(Graph* g)
{
const std::vector<CfgNode*>& nodes = g->getNodes();
std::map<unsigned int, CfgNode*> id2node = getId2Node(nodes);
//add a ConnectionQueue to every Module which has more predecessors
vector<Cfg*> check;
for (unsigned int i = 0; i < nodes.size(); i++) {
vector<unsigned int> nexts = nodes[i]->getCfg()->getNext();
for (unsigned int j = 0; j < nexts.size(); j++){
Cfg* successor = id2node[nexts[j]]->getCfg();
bool found = false;
for(unsigned int k = 0; k < check.size(); k++){
if(check[k] == successor){
found = true;
msg(MSG_INFO, "Creating ConnectionQueue for module %s[Id = %d] because of multiple predecessors",
successor->getName().c_str(), successor->getID());
successor->getQueueInstance(true);
break;
}
}
if(!found)
check.push_back(successor);
}
}
//connect modules
for (unsigned int i = 0; i < nodes.size(); i++) {
CfgNode* fromNode = nodes[i];
Cfg* cfg = fromNode->getCfg();
std::vector<unsigned int> nexts = cfg->getNext();
if (nexts.size()==0) {
cfg->setupWithoutSuccessors();
} else {
for (unsigned int j = 0; j < nexts.size(); j++) {
CfgNode* toNode = id2node[nexts[j]];
if (toNode == NULL)
THROWEXCEPTION("next statement is illegal; there is no node with id=%d", nexts[j]);
if (connectNodes) // insert the connection in the graph
g->addEdge(fromNode, toNode);
msg(MSG_INFO, "Connecting module %s[Id = %d/%08X] -> %s[Id = %d/%08X]",
cfg->getName().c_str(), cfg->getID(), cfg->getInstance(),
id2node[nexts[j]]->getCfg()->getName().c_str(),
id2node[nexts[j]]->getCfg()->getID(), id2node[nexts[j]]->getCfg()->getInstance());
if (connectModules) {// connect the modules
DPRINTF("connecting instances");
cfg->connectInstances(toNode->getCfg());
}
}
}
}
return g;
}
示例14: _get_commit_multi_state_at
static CommitState
_get_commit_multi_state_at(const CfgNode& node, size_t idx)
{
CommitState s = node.getCommitState();
return (s == COMMIT_STATE_CHANGED ? node.commitMultiStateAt(idx) : s);
}
示例15: _get_commit_multi_value_at
static string
_get_commit_multi_value_at(const CfgNode& node, size_t idx)
{
return (node.getCommitState() == COMMIT_STATE_CHANGED
? node.commitMultiValueAt(idx) : (node.getValues())[idx]);
}