17 #include <boost/multi_index_container.hpp>
18 #include <boost/multi_index/hashed_index.hpp>
19 #include <boost/multi_index/ordered_index.hpp>
20 #include <boost/multi_index/sequenced_index.hpp>
21 #include <boost/multi_index/mem_fun.hpp>
22 #include <boost/multi_index/member.hpp>
23 #include <boost/shared_ptr.hpp>
86 const std::string& formatted_value =
"",
89 formatted_value_(formatted_value),
99 formatted_value_(), space_name_() {};
106 option_(desc.option_),
107 persistent_(desc.persistent_),
108 formatted_value_(desc.formatted_value_),
109 space_name_(desc.space_name_) {
117 if (
this != &other) {
119 data::StampedElement::operator=(other);
139 const std::string& formatted_value =
"",
148 static OptionDescriptorPtr
create(
bool persist);
210 typedef boost::multi_index_container<
214 boost::multi_index::indexed_by<
218 boost::multi_index::sequenced<>,
220 boost::multi_index::hashed_non_unique<
228 boost::multi_index::const_mem_fun<
235 boost::multi_index::member<
244 boost::multi_index::hashed_non_unique<
245 boost::multi_index::member<
253 boost::multi_index::ordered_non_unique<
254 boost::multi_index::const_mem_fun<
256 boost::posix_time::ptime,
263 boost::multi_index::hashed_non_unique<
264 boost::multi_index::tag<OptionIdIndexTag>,
265 boost::multi_index::const_mem_fun<data::BaseStampedElement, uint64_t,
278 typedef std::pair<OptionContainerTypeIndex::const_iterator,
285 typedef std::pair<OptionContainerPersistIndex::const_iterator,
378 void add(
const OptionPtr& option,
const bool persistent,
379 const std::string& option_space,
380 const uint64_t
id = 0);
390 void add(
const OptionDescriptor& desc,
const std::string& option_space);
405 void replace(
const OptionDescriptor& desc,
const std::string& option_space);
480 OptionDescriptor& opt_desc);
517 OptionContainerPtr
getAll(
const std::string& option_space)
const;
525 OptionContainerPtr
getAll(
const uint32_t vendor_id)
const;
543 template<
typename Selector>
544 OptionDescriptor
get(
const Selector& key,
545 const uint16_t option_code)
const {
548 OptionContainerPtr options =
getAll(key);
549 if (!options || options->empty()) {
550 return (OptionDescriptor(
false));
554 const OptionContainerTypeIndex& idx = options->get<1>();
555 OptionContainerTypeIndex::const_iterator od_itr = idx.find(option_code);
556 if (od_itr == idx.end()) {
557 return (OptionDescriptor(
false));
573 size_t del(
const std::string& option_space,
const uint16_t option_code);
581 size_t del(
const uint32_t vendor_id,
const uint16_t option_code);
604 size_t del(
const uint64_t
id);
659 void encapsulateInternal(
const std::string& option_space);
669 void encapsulateInternal(
const OptionPtr& option);
684 template <
typename Selector>
686 OptionDescriptor, Selector>& src_container,
688 OptionDescriptor, Selector>& dest_container)
const;
694 OptionSpaceCollection options_;
698 uint32_t> VendorOptionSpaceCollection;
700 VendorOptionSpaceCollection vendor_options_;
719 #endif // CFG_OPTION_H
std::list< std::string > getVendorIdsSpaceNames() const
Returns a list of option space names for configured vendor ids.
Simple container for option spaces holding various items.
OptionDescriptor(const OptionDescriptor &desc)
Copy constructor.
void setContext(const data::ConstElementPtr &ctx)
Sets user context.
OptionContainer::nth_index< 1 >::type OptionContainerTypeIndex
Type of the index #1 - option type.
This class represents configuration element which is associated with database identifier, modification timestamp and servers.
static bool createDescriptorOption(CfgOptionDefPtr cfg_def, const std::string &space, OptionDescriptor &opt_desc)
Creates an option descriptor's option based on a set of option defs.
boost::shared_ptr< CfgOption > CfgOptionPtr
Non-const pointer.
boost::shared_ptr< OptionDescriptor > OptionDescriptorPtr
A pointer to option descriptor.
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
bool operator!=(const CfgOption &other) const
Inequality operator.
OptionDescriptor(const OptionPtr &opt, bool persist, const std::string &formatted_value="", data::ConstElementPtr user_context=data::ConstElementPtr())
Constructor.
Base class for user context.
boost::shared_ptr< const CfgOption > ConstCfgOptionPtr
Const pointer.
bool equals(const CfgOption &other) const
Check if configuration is equal to other configuration.
std::list< Selector > getOptionSpaceNames() const
Get a list of existing option spaces.
boost::shared_ptr< Option > OptionPtr
static OptionDescriptorPtr create(const OptionPtr &opt, bool persist, const std::string &formatted_value="", data::ConstElementPtr user_context=data::ConstElementPtr())
Factory function creating an instance of the OptionDescriptor.
isc::data::ElementPtr toElementWithMetadata(const bool include_metadata) const
Unparse a configuration object with optionally including the metadata.
void add(const OptionPtr &option, const bool persistent, const std::string &option_space, const uint64_t id=0)
Adds instance of the option to the configuration.
boost::shared_ptr< Element > ElementPtr
void copyTo(CfgOption &other) const
Copies this configuration to another configuration.
StampedElement()
Constructor.
bool empty() const
Indicates the object is empty.
bool operator==(const OptionDescriptor &other) const
Equality operator.
boost::shared_ptr< CfgOptionDef > CfgOptionDefPtr
Non-const pointer.
size_t del(const std::string &option_space, const uint16_t option_code)
Deletes option for the specified option space and option code.
OptionContainerPtr getAll(const std::string &option_space) const
Returns all options for the specified option space.
std::pair< OptionContainerTypeIndex::const_iterator, OptionContainerTypeIndex::const_iterator > OptionContainerTypeRange
Pair of iterators to represent the range of options having the same option type value.
boost::posix_time::ptime getModificationTime() const
Returns timestamp.
void mergeTo(CfgOption &other) const
Merges this configuration to another configuration.
void merge(CfgOptionDefPtr cfg_def, CfgOption &other)
Merges another option configuration into this one.
OptionDescriptor & operator=(const OptionDescriptor &other)
Assignment operator.
std::string formatted_value_
Option value in textual (CSV) format.
CfgOption()
default constructor
Represents option data configuration for the DHCP server.
std::list< ConstCfgOptionPtr > CfgOptionList
Const pointer list.
bool persistent_
Persistence flag.
Abstract class for configuration Cfg_* classes.
std::pair< OptionContainerPersistIndex::const_iterator, OptionContainerPersistIndex::const_iterator > OptionContainerPersistRange
Pair of iterators to represent the range of options having the same persistency flag.
uint64_t getId() const
Returns element's database identifier.
boost::shared_ptr< const Element > ConstElementPtr
data::ConstElementPtr getContext() const
Returns const pointer to the user context.
void createOptions(CfgOptionDefPtr cfg_def)
Re-create the option in each descriptor based on given definitions.
std::list< uint32_t > getVendorIds() const
Returns a list of all configured vendor identifiers.
std::string space_name_
Option space name.
OptionPtr option_
Option instance.
Defines the logger used by the top-level component of kea-dhcp-ddns.
OptionDescriptor(bool persist)
Constructor.
bool operator==(const CfgOption &other) const
Equality operator.
void encapsulate()
Appends encapsulated options to top-level options.
uint16_t getType() const
Returns option type (0-255 for DHCPv4, 0-65535 for DHCPv6)
boost::multi_index_container< OptionDescriptor, boost::multi_index::indexed_by< boost::multi_index::sequenced<>, boost::multi_index::hashed_non_unique< KeyFromKeyExtractor< boost::multi_index::const_mem_fun< Option, uint16_t,&Option::getType >, boost::multi_index::member< OptionDescriptor, OptionPtr,&OptionDescriptor::option_ > > >, boost::multi_index::hashed_non_unique< boost::multi_index::member< OptionDescriptor, bool,&OptionDescriptor::persistent_ > >, boost::multi_index::ordered_non_unique< boost::multi_index::const_mem_fun< data::BaseStampedElement, boost::posix_time::ptime,&data::BaseStampedElement::getModificationTime > >, boost::multi_index::hashed_non_unique< boost::multi_index::tag< OptionIdIndexTag >, boost::multi_index::const_mem_fun< data::BaseStampedElement, uint64_t,&data::BaseStampedElement::getId > > >> OptionContainer
Multi index container for DHCP option descriptors.
This class represents configuration element which is associated with database identifier and the modi...
void replace(const OptionDescriptor &desc, const std::string &option_space)
Replaces the instance of an option within this collection.
boost::shared_ptr< OptionContainer > OptionContainerPtr
Pointer to the OptionContainer object.
bool operator!=(const OptionDescriptor &other) const
Inequality operator.
std::map< std::string, OptionSpacePtr > OptionSpaceCollection
A collection of option spaces.
OptionContainer::nth_index< 2 >::type OptionContainerPersistIndex
Type of the index #2 - option persistency flag.
bool equals(const OptionDescriptor &other) const
Checks if the one descriptor is equal to another.
std::list< std::string > getOptionSpaceNames() const
Returns a list of configured option space names.