![]() |
Kea
1.5.0
|
Simple class representing an optional value. More...
#include <optional_value.h>
Public Member Functions | |
| OptionalValue () | |
| Default constructor. More... | |
| OptionalValue (const T &value, const OptionalValueState &state=OptionalValueState(false)) | |
| Constructor. More... | |
| T | get () const |
| Retrieves the actual value. More... | |
| bool | isSpecified () const |
| Checks if the value is specified or unspecified. More... | |
| operator T () const | |
| Type cast operator. More... | |
| bool | operator!= (const T &value) const |
| Inequality operator. More... | |
| void | operator= (const T &value) |
| Specifies a new value value and marks it "specified". More... | |
| bool | operator== (const T &value) const |
| Equality operator. More... | |
| void | set (const T &value) |
| Sets the actual value. More... | |
| void | specify (const T &value) |
| Sets the new value and marks it specified. More... | |
| void | specify (const OptionalValueState &state) |
| Sets the value to "specified" or "unspecified". More... | |
Simple class representing an optional value.
This template class encapsulates a value of any type. An additional flag held by this class indicates if the value is "specified" or "unspecified". For example, a configuration parser for DHCP server may use this class to represent the value of the configuration parameter which may appear in the configuration file, but is not mandatory. The value of the OptionalValue may be initialized to "unspecified" initially. When the configuration parser finds that the appropriate parameter exists in the configuration file, the default value can be overridden and the value may be marked as "specified". If the parameter is not found, the value remains "unspecified" and the appropriate actions may be taken, e.g. the default value may be used.
This is a generic class and may be used in all cases when there is a need for the additional information to be carried along with the value. Alternative approach is to use a pointer which is only initialized if the actual value needs to be specified, but this may not be feasible in all cases.
| Type | of the encapsulated value. |
Definition at line 55 of file optional_value.h.
|
inline |
Default constructor.
Note that the type T must have a default constructor to use this constructor.
Definition at line 62 of file optional_value.h.
|
inlineexplicit |
Constructor.
Creates optional value. The value defaults to "unspecified".
| value | Default explicit value. |
| state | Specifies bool which determines if the value is initially specified or not (default is false). |
Definition at line 73 of file optional_value.h.
|
inline |
Retrieves the actual value.
Definition at line 79 of file optional_value.h.
Referenced by isc::dhcp::Iface::addUnicast(), isc::dhcp::Iface::countActive4(), isc::dhcp::Iface::getAddress4(), isc::dhcp::Iface::hasAddress(), isc::dhcp::IfaceMgr::hasOpenSocket(), isc::dhcp::IfaceMgr::openSocketFromAddress(), isc::dhcp::IfaceMgr::openSockets4(), isc::dhcp::IfaceMgr::openSockets6(), isc::util::operator<<(), and isc::dhcp::IfaceMgr::printIfaces().
|
inline |
Checks if the value is specified or unspecified.
Definition at line 110 of file optional_value.h.
Referenced by isc::dhcp::Iface::countActive4(), isc::dhcp::IfaceMgr::openSockets4(), and isc::dhcp::CqlHostExchange::prepareExchange().
|
inline |
Type cast operator.
This operator converts the optional value to the actual value being encapsulated.
Definition at line 145 of file optional_value.h.
|
inline |
Inequality operator.
| value | Actual value to compare to. |
Definition at line 135 of file optional_value.h.
|
inline |
Specifies a new value value and marks it "specified".
| value | New actual value. |
Definition at line 117 of file optional_value.h.
References isc::util::OptionalValue< T >::specify().
Here is the call graph for this function:
|
inline |
Equality operator.
| value | Actual value to compare to. |
Definition at line 126 of file optional_value.h.
|
inline |
Sets the actual value.
| value | New value. |
Definition at line 86 of file optional_value.h.
Referenced by isc::util::OptionalValue< T >::specify().
|
inline |
Sets the new value and marks it specified.
| value | New actual value. |
Definition at line 93 of file optional_value.h.
References isc::util::OptionalValue< T >::set().
Referenced by isc::util::OptionalValue< T >::operator=().
Here is the call graph for this function:
|
inline |
Sets the value to "specified" or "unspecified".
It does not alter the actual value. It only marks it "specified" or "unspecified".
| state | determines if a value is specified or not |
Definition at line 103 of file optional_value.h.
References isc::util::OptionalValueState::specified_.