25 #ifndef CONNECTIONMANAGER_HPP 26 #define CONNECTIONMANAGER_HPP 34 #include <boost/bimap.hpp> 35 #include <boost/noncopyable.hpp> 36 #include <boost/shared_ptr.hpp> 37 #include <boost/thread/mutex.hpp> 38 #include <boost/asio.hpp> 47 :
private boost::noncopyable
63 void PutHost(std::string u, std::string host, std::string port);
72 void Stop(ConnectionPtr c);
84 ConnectionPtr
CreateConnection(std::string uuid, boost::asio::ip::udp::endpoint endpoint);
96 hostnamemap::iterator
GetHost(std::string uuid) {
return m_hosts.find(uuid); };
122 #endif // CONNECTIONMANAGER_HPP boost::bimap< std::string, ConnectionPtr > connectionmap
Typedef for the map which handles uuid to connection.
Definition: CConnectionManager.hpp:57
void ChangePhase(bool newround)
Handle changing rounds.
Definition: CConnectionManager.cpp:289
connectionmap::iterator GetConnectionsBegin()
Iterator to the beginning of the connection map.
Definition: CConnectionManager.hpp:99
void Stop(ConnectionPtr c)
Stop the specified connection.
Definition: CConnectionManager.cpp:143
void StopAll()
Stop all connections.
Definition: CConnectionManager.cpp:161
void PutConnection(std::string uuid, ConnectionPtr c)
Register a connection with the manager once it has been built.
Definition: CConnectionManager.cpp:85
hostnamemap::iterator GetHostsBegin()
An iterator to the beginning of the hostname map.
Definition: CConnectionManager.hpp:90
CConnectionManager()
Private constructor for the singleton instance.
Definition: CConnectionManager.cpp:59
ConnectionPtr CreateConnection(std::string uuid, boost::asio::ip::udp::endpoint endpoint)
Creates a connection by binding it to an endpoint.
Definition: CConnectionManager.cpp:266
bool HasConnection(std::string uuid)
Returns true if this map is currently tracking a connection to this peer.
Definition: CConnectionManager.cpp:234
A container which lists the hostname and and port of a peer.
Definition: SRemoteHost.hpp:52
boost::mutex m_Mutex
Mutex for protecting the handler maps above.
Definition: CConnectionManager.hpp:116
connectionmap m_connections
Forward map (UUID->Connection)
Definition: CConnectionManager.hpp:114
hostnamemap::iterator GetHostsEnd()
An iterator to the end of the hostname map.
Definition: CConnectionManager.hpp:93
void PutHost(std::string u, std::string host, std::string port)
Place a host/port and uuid into the host / uuid map.
Definition: CConnectionManager.cpp:103
hostnamemap::iterator GetHost(std::string uuid)
An iterator to the specified hostname.
Definition: CConnectionManager.hpp:96
General FREEDM Namespace.
Definition: CBroker.cpp:53
connectionmap::iterator GetConnectionsEnd()
Iterator to the end of the connections map.
Definition: CConnectionManager.hpp:102
Manages open connections so that they may be cleanly stopped.
Definition: CConnectionManager.hpp:46
static CConnectionManager & Instance()
Access the singleton instance of the connection manager.
Definition: CConnectionManager.cpp:71
void LoadNetworkConfig()
Load a network configuration & apply it.
Definition: CConnectionManager.cpp:304
ConnectionPtr GetConnectionByUUID(std::string uuid)
Fetch a connection pointer via UUID.
Definition: CConnectionManager.cpp:185
boost::shared_ptr< CConnection > ConnectionPtr
ConnectionPtr Typedef.
Definition: CConnectionManager.hpp:51
hostnamemap m_hosts
Mapping from uuid to host.
Definition: CConnectionManager.hpp:112
std::map< std::string, SRemoteHost > hostnamemap
Typedef for the map which handles uuid to hostname.
Definition: CConnectionManager.hpp:54