Kea  1.5.0
classify.h
Go to the documentation of this file.
1 // Copyright (C) 2014-2017 Internet Systems Consortium, Inc. ("ISC")
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 
7 #ifndef CLASSIFY_H
8 #define CLASSIFY_H
9 
10 #include <string>
11 #include <iterator>
12 #include <list>
13 #include <unordered_set>
14 
31 
32 namespace isc {
33 
34 namespace dhcp {
35 
37  typedef std::string ClientClass;
38 
43  class ClientClasses {
44  public:
45 
47  typedef std::list<ClientClass>::const_iterator const_iterator;
48 
50  ClientClasses() : list_(), set_() {
51  }
52 
57  ClientClasses(const ClientClass& class_names);
58 
62  void insert(const ClientClass& class_name) {
63  list_.push_back(class_name);
64  set_.insert(class_name);
65  }
66 
68  bool empty() const {
69  return (list_.empty());
70  }
71 
76  size_t size() const {
77  return (list_.size());
78  }
79 
82  return (list_.cbegin());
83  }
84 
86  const_iterator cend() const {
87  return (list_.cend());
88  }
89 
94  bool contains(const ClientClass& x) const {
95  return (set_.count(x) != 0);
96  }
97 
99  void clear() {
100  list_.clear();
101  set_.clear();
102  }
103 
109  std::string toText(const std::string& separator = ", ") const;
110 
111  private:
113  std::list<ClientClass> list_;
114 
116  std::unordered_set<ClientClass> set_;
117  };
118 
119 };
120 
121 };
122 
123 #endif /* CLASSIFY_H */
isc::dhcp::ClientClasses::toText
std::string toText(const std::string &separator=", ") const
Returns all class names as text.
Definition: classify.cc:34
isc
Defines the logger used by the top-level component of kea-dhcp-ddns.
Definition: agent_parser.cc:144
isc::dhcp::ClientClasses::cbegin
const_iterator cbegin() const
Iterator to the first element.
Definition: classify.h:81
isc::dhcp::ClientClasses::contains
bool contains(const ClientClass &x) const
returns if class x belongs to the defined classes
Definition: classify.h:94
isc::dhcp::ClientClasses::clear
void clear()
Clears containers.
Definition: classify.h:99
isc::dhcp::ClientClasses::empty
bool empty() const
Check if classes is empty.
Definition: classify.h:68
isc::dhcp::ClientClasses::const_iterator
std::list< ClientClass >::const_iterator const_iterator
Type of iterators.
Definition: classify.h:47
isc::dhcp::ClientClass
std::string ClientClass
Defines a single class name.
Definition: classify.h:37
isc::dhcp::ClientClasses::insert
void insert(const ClientClass &class_name)
Insert an element.
Definition: classify.h:62
isc::dhcp::ClientClasses::ClientClasses
ClientClasses()
Default constructor.
Definition: classify.h:50
isc::dhcp::ClientClasses::size
size_t size() const
Returns the number of classes.
Definition: classify.h:76
isc::dhcp::ClientClasses::cend
const_iterator cend() const
Iterator to the past the end element.
Definition: classify.h:86
isc::dhcp::ClientClasses
Container for storing client class names.
Definition: classify.h:43