|
@@ -1,4 +1,4 @@
|
|
|
-// Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
|
|
|
+// Copyright (C) 2012, 2014 Internet Systems Consortium, Inc. ("ISC")
|
|
|
//
|
|
|
// Permission to use, copy, modify, and/or distribute this software for any
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
@@ -20,12 +20,23 @@
|
|
|
namespace isc {
|
|
|
namespace dhcp {
|
|
|
|
|
|
-/// @brief this template specifies a parameter value
|
|
|
+/// @brief This template specifies a parameter value
|
|
|
///
|
|
|
-/// This template class is used to store configuration parameters, like lifetime or T1.
|
|
|
-/// It defines 3 parameters: min, default, and max value. There are 2 constructors:
|
|
|
+/// This template class is used to store configuration parameters, like lifetime
|
|
|
+/// or T1. It defines 3 parameters: min, default, and max value. If the
|
|
|
+/// particular configuration parameter is not mandatory, it is possible to
|
|
|
+/// mark the parameter described by a @c Triplet "unspcified". For example, the
|
|
|
+/// T1 and T2 values in DHCPv4 server are optional and may be not specified
|
|
|
+/// in the configuration. The @c Triplets describing these parameters will be
|
|
|
+/// marked "unspecified". If the server finds that the particular parameter
|
|
|
+/// is unspecified it will not include it (e.g. option 58 or 59) in the message
|
|
|
+/// to a client.
|
|
|
+///
|
|
|
+/// There are 3 constructors:
|
|
|
+/// - without parameters - marks the parameter "unspecified"
|
|
|
/// - simple (just one value that sets all parameters)
|
|
|
/// - extended (that sets default value and two thresholds)
|
|
|
+///
|
|
|
/// It will be used with integer types. It provides necessary operators, so
|
|
|
/// it can be assigned to a plain integer or integer assigned to a Triplet.
|
|
|
/// See TripletTest.operator test for details on an easy Triplet usage.
|
|
@@ -33,18 +44,20 @@ template <class T>
|
|
|
class Triplet {
|
|
|
public:
|
|
|
|
|
|
- /// @brief base type to Triple conversion
|
|
|
+ /// @brief Base type to Triplet conversion.
|
|
|
///
|
|
|
/// Typically: uint32_t to Triplet assignment. It is very convenient
|
|
|
/// to be able to simply write Triplet<uint32_t> x = 7;
|
|
|
+ ///
|
|
|
+ /// @param other A number to be assigned as min, max and default value.
|
|
|
Triplet<T>& operator=(T other) {
|
|
|
min_ = other;
|
|
|
default_ = other;
|
|
|
max_ = other;
|
|
|
- return *this;
|
|
|
+ return (*this);
|
|
|
}
|
|
|
|
|
|
- /// @brief triplet to base type conversion
|
|
|
+ /// @brief Triplet to base type conversion
|
|
|
///
|
|
|
/// Typically: Triplet to uint32_t assignment. It is very convenient
|
|
|
/// to be able to simply write uint32_t z = x; (where x is a Triplet)
|
|
@@ -52,15 +65,17 @@ public:
|
|
|
return (default_);
|
|
|
}
|
|
|
|
|
|
- /// @brief sets a fixed value
|
|
|
+ /// @brief Sets a fixed value.
|
|
|
///
|
|
|
/// This constructor assigns a fixed (i.e. no range, just a single value)
|
|
|
/// value.
|
|
|
+ ///
|
|
|
+ /// @param value A number to be assigned as min, max and default value.
|
|
|
Triplet(T value)
|
|
|
:min_(value), default_(value), max_(value) {
|
|
|
}
|
|
|
|
|
|
- /// @brief sets the default value and thresholds
|
|
|
+ /// @brief Sets the default value and thresholds
|
|
|
///
|
|
|
/// @throw BadValue if min <= def <= max rule is violated
|
|
|
Triplet(T min, T def, T max)
|
|
@@ -70,17 +85,24 @@ public:
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /// @brief returns a minimum allowed value
|
|
|
- T getMin() const { return min_;}
|
|
|
+ /// @brief Returns a minimum allowed value
|
|
|
+ T getMin() const { return (min_);}
|
|
|
|
|
|
- /// @brief returns the default value
|
|
|
- T get() const { return default_;}
|
|
|
+ /// @brief Returns the default value
|
|
|
+ T get() const { return (default_); }
|
|
|
|
|
|
- /// @brief returns value with a hint
|
|
|
+ /// @brief Returns value with a hint
|
|
|
///
|
|
|
/// DHCP protocol treats any values sent by a client as hints.
|
|
|
/// This is a method that implements that. We can assign any value
|
|
|
/// from configured range that client asks.
|
|
|
+ ///
|
|
|
+ /// @param hint A value being returned when if it is within the range
|
|
|
+ /// between min and max value of @c Triplet. If the hint value is lower
|
|
|
+ /// than min value, the min value is returned. if the hint is greater
|
|
|
+ /// than max value, the max value is returned.
|
|
|
+ ///
|
|
|
+ /// @return A value adjusted to the hint.
|
|
|
T get(T hint) const {
|
|
|
if (hint <= min_) {
|
|
|
return (min_);
|
|
@@ -93,10 +115,10 @@ public:
|
|
|
return (hint);
|
|
|
}
|
|
|
|
|
|
- /// @brief returns a maximum allowed value
|
|
|
- T getMax() const { return max_; }
|
|
|
+ /// @brief Returns a maximum allowed value
|
|
|
+ T getMax() const { return (max_); }
|
|
|
|
|
|
-protected:
|
|
|
+private:
|
|
|
|
|
|
/// @brief the minimum value
|
|
|
T min_;
|
|
@@ -112,4 +134,4 @@ protected:
|
|
|
} // namespace isc::dhcp
|
|
|
} // namespace isc
|
|
|
|
|
|
-#endif // ifdef TRIPLET_H
|
|
|
+#endif // TRIPLET_H
|