28 #ifndef _util_group_topology_h
29 #define _util_group_topology_h
31 #include <util/class/class.h>
32 #include <util/keyval/keyval.h>
46 virtual int fwdsendto() = 0;
47 virtual int fwdsend() = 0;
48 virtual int fwdrecvfrom() = 0;
49 virtual int fwdrecv() = 0;
53 void backwards() { fwd_ = 0; i_ = n_ - 1; }
54 void forwards() { fwd_ = 1; i_ = 0; }
55 void next() {
if (fwd_) i_++;
else i_--; }
56 int done() {
return i_<0 || i_>=n_; }
57 int n() {
return n_; }
58 int sendto() {
return fwd_?fwdsendto():fwdrecvfrom(); }
59 int send() {
return fwd_?fwdsend():fwdrecv(); }
60 int recvfrom() {
return fwd_?fwdrecvfrom():fwdsendto(); }
61 int recv() {
return fwd_?fwdrecv():fwdsend(); }