Kea  2.3.5-git
serial.h
Go to the documentation of this file.
1 // Copyright (C) 2011-2015,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 SERIAL_H
8 #define SERIAL_H 1
9 
10 #include <stdint.h>
11 #include <iostream>
12 
13 namespace isc {
14 namespace dns {
15 
19 const uint32_t MAX_SERIAL_INCREMENT = 2147483647;
20 
22 const uint64_t MAX_SERIAL_VALUE = 4294967296ull;
23 
41 class Serial {
42 public:
46  explicit Serial(uint32_t value) : value_(value) {}
47 
49  Serial(const Serial& other) : value_(other.getValue()) {}
50 
54  Serial& operator=(const Serial& other) {
55  value_ = other.getValue();
56  return (*this);
57  }
58 
62  void operator=(uint32_t value) { value_ = value; }
63 
67  uint32_t getValue() const { return (value_); }
68 
72  bool operator==(const Serial& other) const;
73 
77  bool operator!=(const Serial& other) const;
78 
85  bool operator<(const Serial& other) const;
86 
94  bool operator<=(const Serial& other) const;
95 
102  bool operator>(const Serial& other) const;
103 
111  bool operator>=(const Serial& other) const;
112 
122  Serial operator+(const Serial& other) const;
123 
134  Serial operator+(uint32_t other_val) const;
135 
136 private:
137  uint32_t value_;
138 };
139 
145 std::ostream& operator<<(std::ostream& os, const Serial& serial);
146 
147 } // end namespace dns
148 } // end namespace isc
149 
150 #endif // SERIAL_H
void operator=(uint32_t value)
Direct assignment from value.
Definition: serial.h:62
ostream & operator<<(std::ostream &os, const EDNS &edns)
Insert the EDNS as a string into stream.
Definition: edns.cc:172
bool operator>=(const Serial &other) const
Returns true if the serial value of this serial is equal to or greater than the other, according to serial arithmetic as described in RFC 1982.
Definition: serial.cc:47
This class defines DNS serial numbers and serial arithmetic.
Definition: serial.h:41
uint32_t getValue() const
Returns the uint32_t representation of this serial value.
Definition: serial.h:67
const uint64_t MAX_SERIAL_VALUE
Maximum value a serial can have, used in + operator.
Definition: serial.h:22
bool operator<(const Serial &other) const
Returns true if the serial value of this serial is smaller than the other, according to serial arithm...
Definition: serial.cc:25
bool operator==(const Serial &other) const
Returns true if the serial values are equal.
Definition: serial.cc:15
Serial(const Serial &other)
Copy constructor.
Definition: serial.h:49
Defines the logger used by the top-level component of kea-lfc.
bool operator!=(const Serial &other) const
Returns true if the serial values are not equal.
Definition: serial.cc:20
const uint32_t MAX_SERIAL_INCREMENT
The maximum difference between two serial numbers.
Definition: serial.h:19
bool operator>(const Serial &other) const
Returns true if the serial value of this serial is greater than the other, according to serial arithm...
Definition: serial.cc:42
Serial operator+(const Serial &other) const
Adds the given value to the serial number.
Definition: serial.cc:59
Serial(uint32_t value)
Constructor with value.
Definition: serial.h:46
Serial & operator=(const Serial &other)
Direct assignment from other Serial.
Definition: serial.h:54
bool operator<=(const Serial &other) const
Returns true if the serial value of this serial is equal to or smaller than the other, according to serial arithmetic as described in RFC 1982.
Definition: serial.cc:37