|
/////////////////////////////////
// msgrouter.hpp.hpp
// generic message routing
//
#pragma once
#include "graphs.hpp"
#pragma message ("Compiling " __FILE__)
//define a model for routing of messages into a graph
namespace GE_ { namespace stdx { namespace graph {
template<class Data, class Node, class Fn> //void Fn(Arc*, Data&): can be mem_fun(void(Arc::*)(Data&))
void route_arcs(Data& d, Node& node, Fn fn)
{
for(typename Node::arc_iterator i = node.begin_arcto(); i!=node.end_arcto(); i++)
Fn(i, d);
}
template<class Data, class Node, class Fn> //void Fn(Node*, Data&): can be mem_fun(void(Node::*)(Data&))
void route_linked(Data& d, Node& node, Fn fn)
{
for(typename Node::arc_iterator i = node.begin_arcto(); i!=node.end_arcto(); i++)
{
Node* p(i->get_to());
if(p) fn(p, d);
}
}
template<class Data, class Node, class Fn> //void Fn(Arc*, Data&): can be mem_fun(void(Arc::*)(Data&))
void backroute_arcs(Data& d, Node& node, Fn fn)
{
for(typename Node::arc_iterator i = node.begin_arcfrom(); i!=node.end_arcfrom(); i++)
Fn(i, d);
}
template<class Data, class Node, class Fn> //void Fn(Node*, Data&): can be mem_fun(void(Node::*)(Data&))
void backroute_linked(Data& d, Node& node, Fn fn)
{
for(typename Node::arc_iterator i = node.begin_arcfrom(); i!=node.end_arcfrom(); i++)
{
Node* p(i->get_to());
if(p) fn(p, d);
}
}
}}}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Born and living in Milan (Italy), I'm an engineer in electronics actually working in the ICT department of an important oil/gas & energy company as responsible for planning and engineering of ICT infrastructures.
Interested in programming since the '70s, today I still define architectures for the ICT, deploying dedicated specific client application for engineering purposes, working with C++, MFC, STL, and recently also C# and D.