FREEDM DGI
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
CGlobalPeerList.hpp
Go to the documentation of this file.
1 
23 #ifndef CGLOBALPEERLIST_HPP
24 #define CGLOBALPEERLIST_HPP
25 
26 #include <map>
27 #include <string>
28 
29 #include <boost/noncopyable.hpp>
30 
31 namespace freedm {
32 
33 namespace broker {
34 
35 // We have to forward declare GMAgent (and its namespace!) to make it a friend.
36 namespace gm {
37 
38 class GMAgent;
39 
40 }
41 
42 class CPeerNode;
43 
45  : private boost::noncopyable
46 {
47  public:
50  typedef std::map<std::string, CPeerNode> PeerSet;
52  typedef PeerSet::iterator PeerSetIterator;
55  {
56  static CGlobalPeerList inst;
57  return inst;
58  }
60  CPeerNode GetPeer(const std::string& uuid);
62  int Count(const std::string& uuid);
64  PeerSetIterator Find(const std::string& uuid);
70  PeerSet& PeerList();
72  CPeerNode Create(std::string uuid);
74  void Insert(CPeerNode p);
75  private:
78 
79 };
80 
81 }
82 
83 }
84 
85 #endif
PeerSetIterator begin()
Iterator to the beginning of the peerset.
Definition: CGlobalPeerList.cpp:75
PeerSet m_peerlist
The set of peers to present.
Definition: CGlobalPeerList.hpp:77
PeerSet::iterator PeerSetIterator
Provides a PeerSet iterator templated on T.
Definition: PeerSets.hpp:37
Base interface for agents/broker modules.
Definition: CPeerNode.hpp:37
PeerSetIterator end()
Iterator to the end of the peerset.
Definition: CGlobalPeerList.cpp:84
static CGlobalPeerList & instance()
Provides the global instance.
Definition: CGlobalPeerList.hpp:54
Declaration of Garcia-Molina Invitation Leader Election algorithm.
Definition: GroupManagement.hpp:45
PeerSetIterator Find(const std::string &uuid)
Return an iterator to the peer with the given uuid.
Definition: CGlobalPeerList.cpp:66
CPeerNode GetPeer(const std::string &uuid)
Fetch a peer based on uuid, throws an exception if they aren't found.
Definition: CGlobalPeerList.cpp:41
int Count(const std::string &uuid)
Count the number of peers with a specified uuid (should be 1 or 0)
Definition: CGlobalPeerList.cpp:56
void Insert(CPeerNode p)
Pushes a peer node into the set.
Definition: CGlobalPeerList.cpp:95
PeerSet::iterator PeerSetIterator
Provides and Iterator.
Definition: CGlobalPeerList.hpp:52
CPeerNode Create(std::string uuid)
Construct a peer.
Definition: CGlobalPeerList.cpp:108
Definition: CGlobalPeerList.hpp:44
PeerSet & PeerList()
Returns a copy of the peer map.
Definition: CGlobalPeerList.cpp:123
std::map< std::string, CPeerNode > PeerSet
The peerset type.
Definition: CGlobalPeerList.hpp:50
std::map< std::string, CPeerNode > PeerSet
Provides a PeerSet type for a module templated on T.
Definition: PeerSets.hpp:35