Kea
1.9.9-git
|
This class represents a named configuration parameter, e.g. More...
#include <stamped_value.h>
Public Member Functions | |
StampedValue (const std::string &name) | |
Constructor creating a null value. More... | |
StampedValue (const std::string &name, const ElementPtr &value) | |
Constructor creating a value from the Element . More... | |
StampedValue (const std::string &name, const std::string &value) | |
Constructor creating a string value. More... | |
bool | amNull () const |
Checks if the value is null. More... | |
bool | getBoolValue () const |
Returns value as a boolean. More... | |
double | getDoubleValue () const |
Returns value as a real number. More... | |
ConstElementPtr | getElementValue () const |
Returns the value as Element . More... | |
int64_t | getIntegerValue () const |
Returns value as signed integer. More... | |
std::string | getName () const |
Returns value name. More... | |
int | getType () const |
Returns a type of the value. More... | |
std::string | getValue () const |
Returns value as string. More... | |
Public Member Functions inherited from isc::data::StampedElement | |
StampedElement () | |
Constructor. More... | |
void | delServerTag (const std::string &server_tag) |
Deletes server tag. More... | |
isc::data::ElementPtr | getMetadata () const |
Returns an object representing metadata to be returned with objects from the configuration backend. More... | |
std::set< ServerTag > | getServerTags () const |
Returns server tags. More... | |
bool | hasAllServerTag () const |
Checks if the element has 'all' server tag. More... | |
bool | hasServerTag (const ServerTag &server_tag) const |
Checks if the element has the given server tag. More... | |
void | setServerTag (const std::string &server_tag) |
Adds new server tag. More... | |
Public Member Functions inherited from isc::data::BaseStampedElement | |
BaseStampedElement () | |
Constructor. More... | |
uint64_t | getId () const |
Returns element's database identifier. More... | |
boost::posix_time::ptime | getModificationTime () const |
Returns timestamp. More... | |
void | setId (const uint64_t id) |
Sets element's database identifier. More... | |
void | setModificationTime (const boost::posix_time::ptime ×tamp) |
Sets timestamp to the explicitly provided value. More... | |
void | updateModificationTime () |
Sets timestamp to the current time. More... | |
Static Public Member Functions | |
static StampedValuePtr | create (const std::string &name) |
Factory function creating a null value. More... | |
static StampedValuePtr | create (const std::string &name, const ElementPtr &value) |
Factory function creating a value from the Element . More... | |
static StampedValuePtr | create (const std::string &name, const std::string &value) |
Factory function creating a string value. More... | |
static StampedValuePtr | create (const std::string &name, const std::string &value, Element::types type) |
Factory function which attempts to convert provided string value to a given type. More... | |
Additional Inherited Members | |
Protected Attributes inherited from isc::data::BaseStampedElement | |
uint64_t | id_ |
Database identifier of the configuration element. More... | |
boost::posix_time::ptime | timestamp_ |
Holds timestamp value. More... | |
This class represents a named configuration parameter, e.g.
global parameter of the DHCP server.
Global configuration elements having simple types, e.g. DHCP timers, need to be associatied with modification timestamps. This association is made by deriving from StampedElement
. The values can be strings, integers, booleans or real numbers.
Because the strings are more flexible, configuration elements are always held as strings in the configuration backends. This class reflects a single value held in the database. The value can be return in its orginal type or can be returned as a string. Also the null values are allowed.
Definition at line 41 of file stamped_value.h.
isc::data::StampedValue::StampedValue | ( | const std::string & | name | ) |
Constructor creating a null value.
name | Name of the value. |
Definition at line 16 of file stamped_value.cc.
Referenced by create().
isc::data::StampedValue::StampedValue | ( | const std::string & | name, |
const ElementPtr & | value | ||
) |
isc::data::StampedValue::StampedValue | ( | const std::string & | name, |
const std::string & | value | ||
) |
Constructor creating a string value.
Creates stamped value from a string.
name | Name of the value. |
value | Value to be set. |
Definition at line 25 of file stamped_value.cc.
|
inline |
Checks if the value is null.
Definition at line 135 of file stamped_value.h.
|
static |
Factory function creating a null value.
name | Name of the value. |
Definition at line 31 of file stamped_value.cc.
References StampedValue().
Referenced by create().
|
static |
Factory function creating a value from the Element
.
name | Name of the value. |
value | Value encapsulated in the Element object. |
BadValue | if the value is null. |
TypeError | if the value is neither a string, integer, bool nor real. |
Definition at line 36 of file stamped_value.cc.
References StampedValue().
|
static |
Factory function creating a string value.
Creates stamped value from a string.
name | Name of the value. |
value | Value to be set. |
Definition at line 41 of file stamped_value.cc.
References StampedValue().
|
static |
Factory function which attempts to convert provided string value to a given type.
This factory function is useful in cases when the value is read as a string from a database. The string value has to be converted to the appropriate data type. The type is also known from the database.
name | Name of the value. |
value | Value given as string to be converted. |
type | Type of the value to convert to. |
Definition at line 46 of file stamped_value.cc.
References isc::data::Element::boolean, create(), isc::data::Element::create(), isc::data::Element::integer, isc_throw, isc::data::Element::real, isc::data::Element::string, and isc::data::Element::typeToName().
bool isc::data::StampedValue::getBoolValue | ( | ) | const |
Returns value as a boolean.
TypeError | if the value is not of Element::boolean type. |
Definition at line 148 of file stamped_value.cc.
References isc::data::Element::boolean.
double isc::data::StampedValue::getDoubleValue | ( | ) | const |
Returns value as a real number.
TypeError | if the value is not of Element::real type. |
Definition at line 154 of file stamped_value.cc.
References isc::data::Element::real.
|
inline |
Returns the value as Element
.
Definition at line 161 of file stamped_value.h.
int64_t isc::data::StampedValue::getIntegerValue | ( | ) | const |
Returns value as signed integer.
TypeError | if the value is not of Element::integer type. |
Definition at line 142 of file stamped_value.cc.
References isc::data::Element::integer.
|
inline |
int isc::data::StampedValue::getType | ( | ) | const |
Returns a type of the value.
Element::getType()
output. InvalidOperation | if the value is null. |
Definition at line 96 of file stamped_value.cc.
References isc_throw.
std::string isc::data::StampedValue::getValue | ( | ) | const |
Returns value as string.
It is allowed to call this function for all supported data types. They are converted to a string. For example, a real number of 1.4 will be returned as "1.4". The boolean true value will be returned as "1" etc.
InvalidOperation | if the value is null. |
Definition at line 107 of file stamped_value.cc.
References isc::data::Element::boolean, isc::data::Element::integer, isc_throw, isc::data::Element::real, and isc::data::Element::string.