24 const std::list<std::string>& names =
25 option_definitions_.getOptionSpaceNames();
26 for (std::list<std::string>::const_iterator name = names.begin();
27 name != names.end(); ++name) {
29 for (OptionDefContainer::const_iterator def = defs->begin();
30 def != defs->end(); ++def) {
33 new_config.
add(new_def);
41 const std::list<std::string>& names = option_definitions_.getOptionSpaceNames();
43 const std::list<std::string>&
47 if (names.size() != other_names.size()) {
52 for (std::list<std::string>::const_iterator name = names.begin();
53 name != names.end(); ++name) {
59 if (defs->size() != defs->size()) {
63 for (OptionDefContainer::const_iterator def = defs->begin();
64 def != defs->end(); ++def) {
66 other_def = other.
get(*name, (*def)->getCode());
68 if (!other_def || (*other_def != **def)) {
83 "option definition must not be NULL");
85 const std::string& option_space = def->getOptionSpaceName();
88 if (
get(option_space, def->getCode())) {
90 << def->getCode() <<
"' already exists in option"
91 " space '" << option_space <<
"'");
92 }
else if (
get(option_space, def->getName())) {
94 << def->getName() <<
"' already exists in option"
95 " space '" << option_space <<
"'");
98 }
else if (LibDHCP::getOptionDef(option_space, def->getCode())) {
100 << def->getCode() <<
"' in standard option space '"
101 << option_space <<
"'");
102 }
else if (LibDHCP::getOptionDef(option_space, def->getName())) {
104 << def->getName() <<
"' in standard option space '"
105 << option_space <<
"'");
108 option_definitions_.addItem(def);
112 CfgOptionDef::getAll(
const std::string& option_space)
const {
114 return (option_definitions_.getItems(option_space));
118 CfgOptionDef::get(
const std::string& option_space,
119 const uint16_t option_code)
const {
125 if (defs && !defs->empty()) {
131 if (std::distance(range.first, range.second) > 0) {
132 return (*range.first);
140 CfgOptionDef::get(
const std::string& option_space,
141 const std::string& option_name)
const {
147 if (defs && !defs->empty()) {
153 if (std::distance(range.first, range.second) > 0) {
154 return (*range.first);
162 CfgOptionDef::del(
const uint64_t
id) {
163 return (option_definitions_.deleteItems(
id));
167 CfgOptionDef::toElement()
const {
168 return (toElementWithMetadata(
false));
172 CfgOptionDef::toElementWithMetadata(
const bool include_metadata)
const {
176 const std::list<std::string>& names =
177 option_definitions_.getOptionSpaceNames();
178 for (std::list<std::string>::const_iterator name = names.begin();
179 name != names.end(); ++name) {
181 for (OptionDefContainer::const_iterator def = defs->begin();
182 def != defs->end(); ++def) {
186 (*def)->contextToElement(map);
192 std::string data_type =
193 OptionDataTypeUtil::getDataTypeName((*def)->getType());
196 bool array_type = (*def)->getArrayType();
199 std::string encapsulates = (*def)->getEncapsulatedSpace();
203 (*def)->getRecordFields();
204 if (!fields.empty()) {
205 std::ostringstream oss;
206 for (OptionDefinition::RecordFieldsCollection::const_iterator
207 field = fields.begin();
208 field != fields.end(); ++field) {
209 if (field != fields.begin()) {
212 oss << OptionDataTypeUtil::getDataTypeName(*field);
220 if (include_metadata) {
221 map->set(
"metadata", (*def)->getMetadata());
243 for (
auto space : option_definitions_.getOptionSpaceNames()) {
244 for (
auto my_def : *(getAll(space))) {
245 if ((other.
get(space, my_def->getName())) ||
246 (other.
get(space, my_def->getCode()))) {
Base class representing a DHCP option definition.
std::vector< OptionDataType > RecordFieldsCollection
List of fields within the record.
OptionDefinitionPtr get(const std::string &option_space, const uint16_t option_code) const
Return option definition for a particular option space and code.
void add(const OptionDefinitionPtr &def)
Add new option definition.
std::list< Selector > getOptionSpaceNames() const
Get a list of existing option spaces.
OptionDefContainer::nth_index< 1 >::type OptionDefContainerTypeIndex
Type of the index #1 - option type.
boost::shared_ptr< Element > ElementPtr
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
static ElementPtr createList(const Position &pos=ZERO_POSITION())
Creates an empty ListElement type ElementPtr.
std::pair< OptionDefContainerTypeIndex::const_iterator, OptionDefContainerTypeIndex::const_iterator > OptionDefContainerTypeRange
Pair of iterators to represent the range of options definitions having the same option type value...
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
Exception to be thrown when the particular option definition duplicates existing option definition...
Represents option definitions used by the DHCP server.
boost::shared_ptr< OptionDefContainer > OptionDefContainerPtr
Pointer to an option definition container.
const OptionDefSpaceContainer & getContainer() const
Returns reference to container holding option definitions.
OptionDefContainerPtr getAll(const std::string &option_space) const
Return option definitions for particular option space.
void clearItems()
Remove all items from the container.
Defines the logger used by the top-level component of kea-dhcp-ddns.
void merge(ElementPtr element, ConstElementPtr other)
Merges the data from other into element.
static ElementPtr create(const Position &pos=ZERO_POSITION())
boost::shared_ptr< OptionDefinition > OptionDefinitionPtr
Pointer to option definition object.
void copyTo(CfgOptionDef &new_config) const
Copies this configuration to a new configuration.
OptionDefContainer::nth_index< 2 >::type OptionDefContainerNameIndex
Type of the index #2 - option name.
std::pair< OptionDefContainerNameIndex::const_iterator, OptionDefContainerNameIndex::const_iterator > OptionDefContainerNameRange
Pair of iterators to represent the range of options definitions having the same option name...