Kea  1.5.0
isc::dhcp::Triplet< T > Class Template Reference

This template specifies a parameter value. More...

#include <triplet.h>

Public Member Functions

 Triplet ()
 Constructor without parameters. More...
 
 Triplet (T min, T def, T max)
 Sets the default value and thresholds. More...
 
 Triplet (T value)
 Sets a fixed value. More...
 
get () const
 Returns the default value. More...
 
get (T hint) const
 Returns value with a hint. More...
 
getMax () const
 Returns a maximum allowed value. More...
 
getMin () const
 Returns a minimum allowed value. More...
 
 operator T () const
 Triplet to base type conversion. More...
 
Triplet< T > & operator= (T other)
 Base type to Triplet conversion. More...
 
bool unspecified () const
 Check if the value has been specified. More...
 

Detailed Description

template<class T>
class isc::dhcp::Triplet< T >

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. If the particular configuration parameter is not mandatory, it is possible to mark the parameter described by a Triplet "unspecified". For example, the T1 and T2 values in DHCPv4 server are optional and may be not specified in the configuration. The 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.

Definition at line 36 of file triplet.h.

Constructor & Destructor Documentation

◆ Triplet() [1/3]

template<class T >
isc::dhcp::Triplet< T >::Triplet ( )
inline

Constructor without parameters.

Marks value in Triplet unspecified.

Definition at line 65 of file triplet.h.

◆ Triplet() [2/3]

template<class T >
isc::dhcp::Triplet< T >::Triplet ( value)
inline

Sets a fixed value.

This constructor assigns a fixed (i.e. no range, just a single value) value.

Parameters
valueA number to be assigned as min, max and default value.

Definition at line 76 of file triplet.h.

◆ Triplet() [3/3]

template<class T >
isc::dhcp::Triplet< T >::Triplet ( min,
def,
max 
)
inline

Sets the default value and thresholds.

Exceptions
BadValueif min <= def <= max rule is violated

Definition at line 84 of file triplet.h.

Member Function Documentation

◆ get() [1/2]

template<class T >
T isc::dhcp::Triplet< T >::get ( ) const
inline

Returns the default value.

Definition at line 96 of file triplet.h.

◆ get() [2/2]

template<class T >
T isc::dhcp::Triplet< T >::get ( hint) const
inline

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.

Parameters
hintA value being returned when if it is within the range between min and max value of 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.
Returns
A value adjusted to the hint.

Definition at line 110 of file triplet.h.

◆ getMax()

template<class T >
T isc::dhcp::Triplet< T >::getMax ( ) const
inline

Returns a maximum allowed value.

Definition at line 123 of file triplet.h.

◆ getMin()

template<class T >
T isc::dhcp::Triplet< T >::getMin ( ) const
inline

Returns a minimum allowed value.

Definition at line 93 of file triplet.h.

◆ operator T()

template<class T >
isc::dhcp::Triplet< T >::operator T ( ) const
inline

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)

Definition at line 58 of file triplet.h.

◆ operator=()

template<class T >
Triplet<T>& isc::dhcp::Triplet< T >::operator= ( other)
inline

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;

Parameters
otherA number to be assigned as min, max and default value.

Definition at line 45 of file triplet.h.

◆ unspecified()

template<class T >
bool isc::dhcp::Triplet< T >::unspecified ( ) const
inline

Check if the value has been specified.

Returns
true if the value hasn't been specified, or false otherwise.

Definition at line 128 of file triplet.h.

Referenced by isc::dhcp::Subnet4ConfigParser::initSubnet().


The documentation for this class was generated from the following file: