proxygen
AcceptorAddress.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree. An additional grant
7  * of patent rights can be found in the PATENTS file in the same directory.
8  *
9  */
10 #pragma once
11 
12 #include <folly/SocketAddress.h>
13 
14 namespace proxygen {
15 
17  enum class AcceptorType { TCP, UDP };
18 
19  AcceptorAddress() = delete;
21  : address(address), protocol(protocol) {
22  }
23 
26 };
27 
28 inline bool operator<(const AcceptorAddress& lv, const AcceptorAddress& rv) {
29  if (lv.address < rv.address) {
30  return true;
31  }
32  if (rv.address < lv.address) {
33  return false;
34  }
35  return lv.protocol < rv.protocol;
36 }
37 
38 inline std::ostream& operator<<(std::ostream& os,
39  const AcceptorAddress::AcceptorType& accType) {
40  switch (accType) {
42  os << "TCP";
43  break;
45  os << "UDP";
46  break;
47  default:
48  LOG(FATAL) << "Unknown Acceptor type.";
49  }
50  return os;
51 }
52 
53 inline std::ostream& operator<<(std::ostream& os,
54  const AcceptorAddress& accAddr) {
55  os << accAddr.address << "<" << accAddr.protocol << ">";
56  return os;
57 }
58 
60 
61 } // namespace proxygen
std::ostream & operator<<(std::ostream &os, const HeaderTable &table)
folly::SocketAddress address
bool operator<(const AcceptorAddress &lv, const AcceptorAddress &rv)
AcceptorAddress(folly::SocketAddress address, AcceptorType protocol)