G
gexarchakos
Hi there,
Please give me at least a hint...
I have a problem implementing a function object with parameters two
iterators. That is:
A class 'node' produces messages using a routing policy. The routing
policy needs to take the node's neighbours and return a subset of them
based on several criteria. Each message may have different routing
policy. Thus, the policy should be specified while the new message is
produced. The policy should be a different class that can be inherited
and be able to take the (begin,end) iterators of the neighbour list
and return a std::stack of a subset of them.
The node should not reveal any of its internal structures, not even
the neighbours structure. This is why I created a templated function
object but I do not know how to declare the two iterators to be
general without having to specify their exact type.
template<class _TYPE> class router {
public:
// function to take the start and end iterators of a container and
return a subset of them in a stack.
// it decides using further inheritance which routing policy will be
used for each message
std::stack<_TYPE> operator()(iterator _begin, iterator _end);
};
template<class _MSG, class _CLK> class node { //this is a node
class with MESSAGE and CLOCK parameters
private:
// map holding node's neighbours and their expiry time
std::map<node<_MSG, _CLK>*, _CLK> _fanin, _fanout;
public:
// function to produce a message ready to deliver with the actual
content, expiry and routing policy
node<_MSG, _CLK>& produce(_MSG _msg, _CLK _clock, router _rout);
};
The user of the node:roduce funtion does not need to specify the
exact iterator type since than would violate the principle of hiding
the neighbour's structure.
I need for the iterators a form so that I declare & define & use the
produce function without having to specify std::map<node<_MSG, _CLK>*,
_CLK>::iterator.
Please, help me or post a an idea that has the same effect.
Thanks in advance,
-- George
Please give me at least a hint...
I have a problem implementing a function object with parameters two
iterators. That is:
A class 'node' produces messages using a routing policy. The routing
policy needs to take the node's neighbours and return a subset of them
based on several criteria. Each message may have different routing
policy. Thus, the policy should be specified while the new message is
produced. The policy should be a different class that can be inherited
and be able to take the (begin,end) iterators of the neighbour list
and return a std::stack of a subset of them.
The node should not reveal any of its internal structures, not even
the neighbours structure. This is why I created a templated function
object but I do not know how to declare the two iterators to be
general without having to specify their exact type.
template<class _TYPE> class router {
public:
// function to take the start and end iterators of a container and
return a subset of them in a stack.
// it decides using further inheritance which routing policy will be
used for each message
std::stack<_TYPE> operator()(iterator _begin, iterator _end);
};
template<class _MSG, class _CLK> class node { //this is a node
class with MESSAGE and CLOCK parameters
private:
// map holding node's neighbours and their expiry time
std::map<node<_MSG, _CLK>*, _CLK> _fanin, _fanout;
public:
// function to produce a message ready to deliver with the actual
content, expiry and routing policy
node<_MSG, _CLK>& produce(_MSG _msg, _CLK _clock, router _rout);
};
The user of the node:roduce funtion does not need to specify the
exact iterator type since than would violate the principle of hiding
the neighbour's structure.
I need for the iterators a form so that I declare & define & use the
produce function without having to specify std::map<node<_MSG, _CLK>*,
_CLK>::iterator.
Please, help me or post a an idea that has the same effect.
Thanks in advance,
-- George