Kea 2.7.5
stamped_value.h
Go to the documentation of this file.
1// Copyright (C) 2018-2024 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef STAMPED_VALUE_H
8#define STAMPED_VALUE_H
9
10#include <cc/data.h>
11#include <cc/stamped_element.h>
12#include <boost/multi_index/hashed_index.hpp>
13#include <boost/multi_index/mem_fun.hpp>
14#include <boost/multi_index/ordered_index.hpp>
15#include <boost/multi_index_container.hpp>
16#include <boost/shared_ptr.hpp>
17#include <cstdint>
18#include <string>
19
20namespace isc {
21namespace data {
22
23class StampedValue;
24
26typedef boost::shared_ptr<StampedValue> StampedValuePtr;
27
42public:
43
47 StampedValue(const std::string& name);
48
57 StampedValue(const std::string& name, const ElementPtr& value);
58
65 StampedValue(const std::string& name, const std::string& value);
66
70 static StampedValuePtr create(const std::string& name);
71
80 static StampedValuePtr create(const std::string& name,
81 const ElementPtr& value);
82
89 static StampedValuePtr create(const std::string& name,
90 const std::string& value);
91
103 static StampedValuePtr create(const std::string& name,
104 const std::string& value,
105 Element::types type);
106
112 int getType() const;
113
117 std::string getName() const {
118 return (name_);
119 }
120
130 std::string getValue() const;
131
135 bool amNull() const {
136 return (!value_);
137 }
138
144 int64_t getIntegerValue() const;
145
151 bool getBoolValue() const;
152
158 double getDoubleValue() const;
159
162 return (value_);
163 }
164
165private:
166
175 void validateConstruct() const;
176
187 void validateAccess(Element::types type) const;
188
190 std::string name_;
191
193 ElementPtr value_;
194};
195
198
199
202
205
207typedef boost::multi_index_container<
209 boost::multi_index::indexed_by<
210 // Index used to access value by name.
211 boost::multi_index::hashed_non_unique<
212 boost::multi_index::tag<StampedValueNameIndexTag>,
213 boost::multi_index::const_mem_fun<
215 std::string,
217 >
218 >,
219
220 // Index used to access value by modification time.
221 boost::multi_index::ordered_non_unique<
222 boost::multi_index::tag<StampedValueModificationTimeIndexTag>,
223 boost::multi_index::const_mem_fun<
225 boost::posix_time::ptime,
227 >
228 >
229 >
231
233
234} // end of namespace isc::data
235} // end of namespace isc
236
237#endif
This class represents configuration element which is associated with database identifier and the modi...
boost::posix_time::ptime getModificationTime() const
Returns timestamp.
types
The types that an Element can hold.
Definition data.h:139
This class represents configuration element which is associated with database identifier,...
This class represents a named configuration parameter, e.g.
double getDoubleValue() const
Returns value as a real number.
bool getBoolValue() const
Returns value as a boolean.
StampedValue(const std::string &name)
Constructor creating a null value.
std::string getValue() const
Returns value as string.
int getType() const
Returns a type of the value.
int64_t getIntegerValue() const
Returns value as signed integer.
static StampedValuePtr create(const std::string &name)
Factory function creating a null value.
std::string getName() const
Returns value name.
bool amNull() const
Checks if the value is null.
ConstElementPtr getElementValue() const
Returns the value as Element.
boost::shared_ptr< StampedValue > StampedValuePtr
Pointer to the stamped value.
boost::multi_index_container< StampedValuePtr, boost::multi_index::indexed_by< boost::multi_index::hashed_non_unique< boost::multi_index::tag< StampedValueNameIndexTag >, boost::multi_index::const_mem_fun< StampedValue, std::string, &StampedValue::getName > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< StampedValueModificationTimeIndexTag >, boost::multi_index::const_mem_fun< BaseStampedElement, boost::posix_time::ptime, &BaseStampedElement::getModificationTime > > > > StampedValueCollection
Multi index container for StampedValue.
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:29
boost::shared_ptr< Element > ElementPtr
Definition data.h:28
Defines the logger used by the top-level component of kea-lfc.
Tag for the index for access by modification time.
Tag for the index for access by value name.