Kea 2.5.8
isc::util::Triplet< T > Class Template Reference

This template specifies a parameter value. More...

#include <triplet.h>

+ Inheritance diagram for isc::util::Triplet< T >:

Public Member Functions

 Triplet ()
 Constructor without parameters.
 
 Triplet (T min, T def, T max)
 Sets the default value and thresholds.
 
 Triplet (T value)
 Sets a fixed value.
 
get (T hint) const
 Returns value with a hint.
 
getMax () const
 Returns a maximum allowed value.
 
getMin () const
 Returns a minimum allowed value.
 
Triplet< T > & operator= (T other)
 Base type to Triplet conversion.
 
- Public Member Functions inherited from isc::util::Optional< T >
 Optional ()
 Default constructor.
 
 Optional ()
 Specialization of the default Optional constructor for strings.
 
template<typename A >
 Optional (A value, const bool unspecified=false)
 Constructor.
 
bool empty () const
 Checks if the encapsulated value is empty.
 
bool empty () const
 Specialization of the Optional::empty method for strings.
 
get () const
 Retrieves the encapsulated value.
 
 operator T () const
 Type cast operator.
 
bool operator!= (const T &other) const
 Inequality operator.
 
template<typename A >
Optional< T > & operator= (A other)
 Assigns a new value value and marks it "specified".
 
bool operator== (const T &other) const
 Equality operator.
 
bool unspecified () const
 Checks if the value has been specified or unspecified.
 
void unspecified (bool unspecified)
 Modifies the flag that indicates whether the value is specified or unspecified.
 
valueOr (T const &or_value) const
 Retrieves the encapsulated value if specified, or the given value otherwise.
 

Additional Inherited Members

- Public Types inherited from isc::util::Optional< T >
typedef T ValueType
 Type of the encapsulated value.
 
- Protected Attributes inherited from isc::util::Optional< T >
default_
 Encapsulated value.
 
bool unspecified_
 Flag which indicates if the value is specified.
 

Detailed Description

template<class T>
class isc::util::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 37 of file triplet.h.

Constructor & Destructor Documentation

◆ Triplet() [1/3]

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

Constructor without parameters.

Marks value in Triplet unspecified.

Definition at line 60 of file triplet.h.

◆ Triplet() [2/3]

template<class T >
isc::util::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 70 of file triplet.h.

◆ Triplet() [3/3]

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

Sets the default value and thresholds.

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

Definition at line 77 of file triplet.h.

References isc_throw.

Member Function Documentation

◆ get()

template<class T >
T isc::util::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 99 of file triplet.h.

Referenced by isc::db::PsqlBindArray::add(), isc::db::PsqlBindArray::addMax(), isc::db::PsqlBindArray::addMin(), isc::dhcp::AllocEngine::getLifetimes6(), isc::dhcp::AllocEngine::getValidLft(), isc::dhcp::ClientClassDef::toElement(), and isc::dhcp::Network::toElement().

◆ getMax()

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

Returns a maximum allowed value.

Definition at line 112 of file triplet.h.

Referenced by isc::db::PsqlBindArray::addMax(), isc::dhcp::ClientClassDef::toElement(), and isc::dhcp::Network::toElement().

◆ getMin()

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

Returns a minimum allowed value.

Definition at line 85 of file triplet.h.

Referenced by isc::db::PsqlBindArray::addMin(), isc::dhcp::ClientClassDef::toElement(), and isc::dhcp::Network::toElement().

◆ operator=()

template<class T >
Triplet< T > & isc::util::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 48 of file triplet.h.


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