Graybat  1.1
Graph Approach for Highly Generic Communication Schemes Based on Adaptive Topologies
Edge.hpp
1 #pragma once
2 
3 #include <boost/optional.hpp> /* boost::optional */
4 
5 namespace graybat {
6 
7  template <class T_Cage>
9 
10  typedef T_Cage Cage;
11  typedef unsigned EdgeID;
12  typedef typename Cage::GraphPolicy GraphPolicy;
13  typedef typename Cage::Vertex Vertex;
14  typedef typename Cage::Event Event;
15  typedef typename GraphPolicy::EdgeProperty EdgeProperty;
16  typedef typename GraphPolicy::VertexProperty VertexProperty;
17 
18  EdgeID id;
19  Vertex target;
20  Vertex source;
21  EdgeProperty &edgeProperty;
22  Cage &cage;
23 
24  CommunicationEdge(const EdgeID id,
25  Vertex source,
26  Vertex target,
27  EdgeProperty &edgeProperty,
28  Cage &cage) :
29  id(id),
30  target(target),
31  source(source),
32  edgeProperty(edgeProperty),
33  cage(cage){
34 
35  }
36 
37  /***************************************************************************
38  * Graph Operations
39  ****************************************************************************/
40 
41  EdgeProperty& operator()(){
42  return edgeProperty;
43  }
44 
45  CommunicationEdge inverse(){
46  boost::optional<CommunicationEdge> edge = cage.getEdge(target, source);
47  if(edge){
48  return *edge;
49  }
50  return *this;
51  }
52 
53  /***************************************************************************
54  * Communication Operations
55  ****************************************************************************/
56 
57  template <class T_Send>
58  Event operator<<(const T_Send &data){
59  std::vector<Event> events;
60  cage.send(*this, data, events);
61  return events.back();
62  }
63 
64  template <class T_Recv>
65  void operator>>(T_Recv &data){
66  cage.recv(*this, data);
67  }
68 
69  };
70 
71 } /* namespace graybat */
Definition: Vertex.hpp:9
Definition: Edge.hpp:8
Definition: BiStar.hpp:8