32 #ifndef _util_group_topology_h
33 #define _util_group_topology_h
35 #include <util/class/class.h>
36 #include <util/keyval/keyval.h>
50 virtual int fwdsendto() = 0;
51 virtual int fwdsend() = 0;
52 virtual int fwdrecvfrom() = 0;
53 virtual int fwdrecv() = 0;
57 void backwards() { fwd_ = 0; i_ = n_ - 1; }
58 void forwards() { fwd_ = 1; i_ = 0; }
59 void next() {
if (fwd_) i_++;
else i_--; }
60 int done() {
return i_<0 || i_>=n_; }
61 int n() {
return n_; }
62 int sendto() {
return fwd_?fwdsendto():fwdrecvfrom(); }
63 int send() {
return fwd_?fwdsend():fwdrecv(); }
64 int recvfrom() {
return fwd_?fwdrecvfrom():fwdsendto(); }
65 int recv() {
return fwd_?fwdrecv():fwdsend(); }