本文整理汇总了C++中Flow类的典型用法代码示例。如果您正苦于以下问题:C++ Flow类的具体用法?C++ Flow怎么用?C++ Flow使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Flow类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: controlDependenceGraph
Flow CFAnalysis::controlDependenceGraph(Flow& controlFlow) {
LabelSet condLabels=conditionLabels(controlFlow);
LabelSet targetLabels;
Flow controlDependenceEdges;
for(LabelSet::iterator i=condLabels.begin();i!=condLabels.end();++i) {
SgNode* condition=getLabeler()->getNode(*i);
cerr<<"DEBUG: cond:"<<condition->class_name()<<endl;
SgNode* stmt=SgNodeHelper::getParent(condition);
cerr<<"DEBUG: stmt:"<<stmt->class_name()<<endl;
// while/dowhile/for
if(SgNodeHelper::isLoopCond(condition)) {
SgNode* loopBody=SgNodeHelper::getLoopBody(stmt);
cerr<<"DEBUG: loopBody:"<<loopBody->class_name()<<endl;
LabelSet loopBodyInitLabels=setOfInitialLabelsOfStmtsInBlock(loopBody);
targetLabels=loopBodyInitLabels;
}
// if
if(isSgIfStmt(stmt)) {
SgNode* trueBranch=SgNodeHelper::getTrueBranch(stmt);
LabelSet trueBranchInitLabels=setOfInitialLabelsOfStmtsInBlock(trueBranch);
SgNode* falseBranch=SgNodeHelper::getFalseBranch(stmt);
LabelSet falseBranchInitLabels=setOfInitialLabelsOfStmtsInBlock(falseBranch);
targetLabels=trueBranchInitLabels+falseBranchInitLabels;
}
for(LabelSet::iterator j=targetLabels.begin();j!=targetLabels.end();++j) {
controlDependenceEdges.insert(Edge(*i,EDGE_FORWARD,*j));
}
}
return controlDependenceEdges;
}
示例2: reduceNode
int CFAnalysis::reduceNode(Flow& flow, Label lab) {
Flow inFlow=flow.inEdges(lab);
Flow outFlow=flow.outEdges(lab);
/* description of essential operations:
* inedges: (n_i,b)
* outedge: (b,n2)
* remove(n_i,b)
* remove(b,n2)
* insert(n1,n2)
*/
if(inFlow.size()==0 && outFlow.size()==0)
return 0;
if(inFlow.size()==0 || outFlow.size()==0) {
Flow edges=inFlow+outFlow;
flow.deleteEdges(edges);
return 1;
}
for(Flow::iterator initer=inFlow.begin();initer!=inFlow.end();++initer) {
for(Flow::iterator outiter=outFlow.begin();outiter!=outFlow.end();++outiter) {
Edge e1=*initer;
Edge e2=*outiter;
Edge newEdge=Edge(e1.source,e1.types(),e2.target);
flow.erase(e1);
flow.erase(e2);
flow.insert(newEdge);
}
}
return 1;
}
示例3:
Flow Flow::operator+(Flow& s2) {
Flow result;
result=*this;
for(Flow::iterator i2=s2.begin();i2!=s2.end();++i2)
result.insert(*i2);
return result;
}
示例4: assert
int CFAnalyzer::reduceBlockBeginNodes(Flow& flow) {
LabelSet labs=flow.nodeLabels();
int cnt=0;
for(LabelSet::iterator i=labs.begin();i!=labs.end();++i) {
if(isSgBasicBlock(getNode(*i))) {
cnt++;
Flow inFlow=flow.inEdges(*i);
Flow outFlow=flow.outEdges(*i);
// multiple out-edges not supported yet
assert(outFlow.size()<=1);
/* description of essential operations:
* inedges: (n_i,b)
* outedge: (b,n2)
* remove(n_i,b)
* remove(b,n2)
* insert(n1,n2)
*/
for(Flow::iterator initer=inFlow.begin();initer!=inFlow.end();++initer) {
Edge e1=*initer;
Edge e2=*outFlow.begin();
Edge newEdge=Edge(e1.source,e1.types(),e2.target);
flow.erase(e1);
flow.erase(e2);
flow.insert(newEdge);
}
}
}
return cnt;
}
示例5: ntop_get_interface_flow_by_key
static int ntop_get_interface_flow_by_key(lua_State* vm) {
NetworkInterface *ntop_interface;
u_int32_t key;
Flow *f;
if(ntop_lua_check(vm, __FUNCTION__, 1, LUA_TNUMBER)) return(CONST_LUA_ERROR);
key = (u_int32_t)lua_tonumber(vm, 1);
lua_getglobal(vm, "ntop_interface");
if((ntop_interface = (NetworkInterface*)lua_touserdata(vm, lua_gettop(vm))) == NULL) {
handle_null_interface(vm);
return(CONST_LUA_ERROR);
// ntop_interface = ntop->getInterfaceId(0);
}
if(!ntop_interface) return(false);
f = ntop_interface->findFlowByKey(key);
if(f == NULL)
return(false);
else {
f->lua(vm, true);
return(true);
}
}
示例6: inlineTrivialFunctions
/*!
* \author Markus Schordan
* \date 2013.
*/
int CFAnalysis::inlineTrivialFunctions(Flow& flow) {
//cerr<<"Error: inlineTrivialFunctions is deactivated."<<endl;
//exit(1);
// 1) compute all functions that are called exactly once (i.e. number of pred in ICFG is 1)
// AND have the number of formal parameters is 0 AND have void return type.
// 2) inline function
// more advanced version will also clone function-CFGs, but this makes the mapping label<->code loose the 1-1 mapping property.
int numInlined=0;
LabelSet lnLabs=functionEntryLabels(flow);
for(LabelSet::iterator i=lnLabs.begin();i!=lnLabs.end();++i) {
LabelSet pred=flow.pred(*i);
if(pred.size()==1) {
Label lc=*pred.begin();
ROSE_ASSERT(getLabeler()->isFunctionCallLabel(lc));
// check the number of formal parameters of ln
if(numberOfFunctionParameters(*i)==0 && isVoidFunction(*i)) {
// reduce all four nodes: lc,ln,lx,lr (this also reduces a possibly existing local edge)
Label ln=*i;
Label lx=correspondingFunctionExitLabel(ln);
LabelSet succ=flow.succ(lx);
// since we have exactly one call there must be exactly one return edge
ROSE_ASSERT(succ.size()==1);
Label lr=*succ.begin();
// reduce all four nodes now
reduceNode(flow,lc);
reduceNode(flow,ln);
reduceNode(flow,lx);
reduceNode(flow,lr);
numInlined++;
}
}
}
return numInlined;
}
示例7: PickColourPair
int Colour_Generator::
PickColourPair(const size_t & beam,const size_t & index) {
msg_Tracking()<<METHOD<<"(beam = "<<beam<<", index = "<<index<<"): "
<<m_col[beam][index].size()<<" "<<m_col[1-beam][1-index].size();
int col(-1);
for (set<int>::iterator cit1=m_col[beam][index].begin();
cit1!=m_col[beam][index].end();cit1++) {
for (set<int>::iterator cit2=m_col[1-beam][1-index].begin();
cit2!=m_col[1-beam][1-index].end();cit2++) {
if ((*cit1)==(*cit2)) {
col = (*cit1);
m_col[beam][index].erase(col);
m_col[1-beam][1-index].erase(col);
break;
}
}
if (col!=-1) break;
}
if (col==-1) {
Flow Flow;
col = Flow.Counter();
m_col[beam][1-index].insert(col);
m_col[1-beam][index].insert(col);
}
msg_Tracking()<<" ---> "<<col<<".\n";
return col;
}
示例8: while
Flow* FlowHash::find(IpAddress *src_ip, IpAddress *dst_ip,
u_int16_t src_port, u_int16_t dst_port,
u_int16_t vlanId, u_int8_t protocol,
bool *src2dst_direction) {
u_int32_t hash = ((src_ip->key()+dst_ip->key()+src_port+dst_port+vlanId+protocol) % num_hashes);
Flow *head = (Flow*)table[hash];
u_int16_t num_loops = 0;
while(head) {
if((!head->idle())
&& head->equal(src_ip, dst_ip, src_port, dst_port, vlanId, protocol, src2dst_direction)) {
if(num_loops > max_num_loops) {
ntop->getTrace()->traceEvent(TRACE_INFO, "DEBUG: [Num loops: %u][hashId: %u]", num_loops, hash);
max_num_loops = num_loops;
}
return(head);
} else
head = (Flow*)head->next(), num_loops++;
}
if(num_loops > max_num_loops) {
ntop->getTrace()->traceEvent(TRACE_INFO, "DEBUG: [Num loops: %u][hashId: %u]", num_loops, hash);
max_num_loops = num_loops;
}
return(NULL);
}
示例9: PickTwoColours
void Colour_Generator::PickTwoColours(const size_t & beam,int * cols) {
Flow flow;
size_t index;
cols[0] = cols[1] = -1;
for (index=0;index<2;index++) {
if (m_col[beam][index].size()==0) cols[index] = flow.Counter();
else {
cols[index] = (*m_col[beam][index].begin());
}
}
if (cols[0]==cols[1]) {
if (m_col[beam][0].size()==1 && m_col[beam][1].size()==1) {
cols[ran->Get()>0.5?0:1] = flow.Counter();
}
else {
index = m_col[beam][0].size()>m_col[beam][1].size()?0:1;
set<int>::iterator cit=m_col[beam][index].begin();
cit++;
cols[index] = (*cit);
m_col[beam][index].erase(cols[index]);
}
}
for (index=0;index<2;index++) {
if (cols[index]==(*m_col[beam][1-index].begin())) {
m_col[beam][1-index].erase(cols[index]);
}
}
msg_Tracking()<<METHOD<<" yields "<<cols[0]<<" "<<cols[1]<<".\n";
}
示例10: key
/// Find the flow corresponding to the specified transport and remote IP
/// address and port.
Flow* FlowTable::find_flow(pjsip_transport* transport, const pj_sockaddr* raddr)
{
Flow* flow = NULL;
FlowKey key(transport->key.type, raddr);
char buf[100];
LOG_DEBUG("Find flow for transport %s (%d), remote address %s",
transport->obj_name, transport->key.type,
pj_sockaddr_print(raddr, buf, sizeof(buf), 3));
pthread_mutex_lock(&_flow_map_lock);
std::map<FlowKey, Flow*>::iterator i = _tp2flow_map.find(key);
if (i != _tp2flow_map.end())
{
// Found a matching flow, so return this one.
flow = i->second;
// Increment the reference count on the flow.
flow->inc_ref();
LOG_DEBUG("Found flow record %p", flow);
}
pthread_mutex_unlock(&_flow_map_lock);
return flow;
}
示例11: reverseFlow
SPRAY::Flow Flow::reverseFlow() {
Flow reverseFlow;
for(Flow::iterator i=begin();i!=end();++i) {
reverseFlow.insert(Edge((*i).target,(*i).getTypes(),(*i).source));
}
return reverseFlow;
}
示例12: assert
Flow CFAnalysis::WhileAndDoWhileLoopFlow(SgNode* node,
Flow edgeSet,
EdgeType edgeTypeParam1,
EdgeType edgeTypeParam2) {
if(!(isSgWhileStmt(node) || isSgDoWhileStmt(node))) {
throw SPRAY::Exception("Error: WhileAndDoWhileLoopFlow: unsupported loop construct.");
}
SgNode* condNode=SgNodeHelper::getCond(node);
Label condLabel=getLabel(condNode);
SgNode* bodyNode=SgNodeHelper::getLoopBody(node);
assert(bodyNode);
Edge edge=Edge(condLabel,EDGE_TRUE,initialLabel(bodyNode));
edge.addType(edgeTypeParam1);
Flow flowB=flow(bodyNode);
LabelSet finalSetB=finalLabels(bodyNode);
edgeSet+=flowB;
edgeSet.insert(edge);
// back edges in while (forward edges in do-while)
for(LabelSet::iterator i=finalSetB.begin();i!=finalSetB.end();++i) {
Edge e;
if(SgNodeHelper::isCond(labeler->getNode(*i))) {
e=Edge(*i,EDGE_FALSE,condLabel);
e.addType(edgeTypeParam2);
} else {
e=Edge(*i,edgeTypeParam2,condLabel);
}
edgeSet.insert(e);
}
return edgeSet;
}
示例13: inEdges
Flow Flow::inEdges(Label label) {
Flow flow;
for(Flow::iterator i=begin();i!=end();++i) {
if((*i).target==label)
flow.insert(*i);
}
flow.setDotOptionDisplayLabel(_dotOptionDisplayLabel);
flow.setDotOptionDisplayStmt(_dotOptionDisplayStmt);
return flow;
}
示例14: edgesOfType
Flow Flow::edgesOfType(EdgeType edgeType) {
Flow flow;
for(Flow::iterator i=begin();i!=end();++i) {
if((*i).isType(edgeType))
flow.insert(*i);
}
flow.setDotOptionDisplayLabel(_dotOptionDisplayLabel);
flow.setDotOptionDisplayStmt(_dotOptionDisplayStmt);
return flow;
}
示例15: operator
/*! Computes the minimum cut of a network */
void operator()(int source)
{
bfs_select(source);
for(unsigned int i = 0; i < vertices.size(); i++)
if(vertices[i])
{
typename Graph::iterator it(G, i);
for(Flow *e = it.beg(); !it.end(); e = it.nxt())
if(!vertices[e->other(i)] /*&& e->capRto(e->other(i)) == 0*/ && e->from(i))
cut.push_back(e);
}
}