Open Lighting Architecture  Latest Git
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
RpcPeer.h
1 /*
2  * This library is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU Lesser General Public
4  * License as published by the Free Software Foundation; either
5  * version 2.1 of the License, or (at your option) any later version.
6  *
7  * This library is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10  * Lesser General Public License for more details.
11  *
12  * You should have received a copy of the GNU Lesser General Public
13  * License along with this library; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15  *
16  * RpcPeer.h
17  * Represents the peer of an RpcChannel.
18  * Copyright (C) 2013 Simon Newton
19  */
20 
21 #ifndef COMMON_RPC_RPCPEER_H_
22 #define COMMON_RPC_RPCPEER_H_
23 
24 #include <ola/Callback.h>
26 #include <string>
27 
28 namespace ola {
29 namespace rpc {
30 
31 class RpcPeer {
32  public:
33  explicit RpcPeer(const ola::network::GenericSocketAddress &socket_addr)
34  : m_socket_addr(socket_addr) {
35  }
36 
37  const ola::network::GenericSocketAddress& SocketAddress() const {
38  return m_socket_addr;
39  }
40 
44  RpcPeer& operator=(const RpcPeer& other) {
45  if (this != &other) {
46  m_socket_addr = other.m_socket_addr;
47  }
48  return *this;
49  }
50 
55  std::string ToString() const {
56  return m_socket_addr.ToString();
57  }
58 
64  friend ostream& operator<<(ostream &out, const RpcPeer &peer) {
65  return out << peer.ToString();
66  }
67 
68  private:
70 };
71 } // namespace rpc
72 } // namespace ola
73 
74 #endif // COMMON_RPC_RPCPEER_H_
Represents Socket Addresses.
std::string ToString() const
Convert a peer to a human readable string.
Definition: RpcPeer.h:55
friend ostream & operator<<(ostream &out, const RpcPeer &peer)
A helper function to write an RpcPeer to an ostream.
Definition: RpcPeer.h:64
Definition: RpcPeer.h:31
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
RpcPeer & operator=(const RpcPeer &other)
Assignment operator.
Definition: RpcPeer.h:44
a Generic Socket Address
Definition: SocketAddress.h:166