24 const std::list<std::string>& names =
26 for (
auto const& name : names) {
28 for (
auto const& def : *defs) {
31 new_config.
add(new_def);
41 const std::list<std::string>&
45 if (names.size() != other_names.size()) {
50 for (
auto const& name : names) {
56 if (defs->size() != defs->size()) {
60 for (
auto const& def : *defs) {
63 if (!other_def || (*other_def != *def)) {
78 "option definition must not be NULL");
80 const std::string& option_space = def->getOptionSpaceName();
83 if (
get(option_space, def->getCode())) {
85 << def->getCode() <<
"' already exists in option"
86 " space '" << option_space <<
"'");
87 }
else if (
get(option_space, def->getName())) {
89 << def->getName() <<
"' already exists in option"
90 " space '" << option_space <<
"'");
95 << def->getCode() <<
"' in standard option space '"
96 << option_space <<
"'");
99 << def->getName() <<
"' in standard option space '"
100 << option_space <<
"'");
103 option_definitions_.
addItem(def);
109 return (option_definitions_.
getItems(option_space));
114 const uint16_t option_code)
const {
120 if (defs && !defs->empty()) {
126 if (std::distance(range.first, range.second) > 0) {
127 return (*range.first);
136 const std::string& option_name)
const {
142 if (defs && !defs->empty()) {
148 if (std::distance(range.first, range.second) > 0) {
149 return (*range.first);
171 const std::list<std::string>& names =
173 for (
auto const& name : names) {
175 for (
auto const& def : *defs) {
179 def->contextToElement(map);
185 std::string data_type =
189 bool array_type = def->getArrayType();
192 std::string encapsulates = def->getEncapsulatedSpace();
196 def->getRecordFields();
197 if (!fields.empty()) {
198 std::ostringstream oss;
200 for (
auto const& field : fields) {
214 if (include_metadata) {
215 map->set(
"metadata", def->getMetadata());
238 for (
auto const& tmp_def : *(
getAll(space))) {
239 if ((other.
get(space, tmp_def->getName())) ||
240 (other.
get(space, tmp_def->getCode()))) {
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
static ElementPtr create(const Position &pos=ZERO_POSITION())
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.
Represents option definitions used by the DHCP server.
void add(const OptionDefinitionPtr &def)
Add new option definition.
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
isc::data::ElementPtr toElementWithMetadata(const bool include_metadata) const
Unparse a configuration object with optionally including the metadata.
uint64_t del(const uint64_t id)
Deletes all option definitions having a given database id.
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.
bool equals(const CfgOptionDef &other) const
Check if configuration is equal to other configuration.
void merge(CfgOptionDef &other)
Merges specified option definitions from a configuration into this configuration.
OptionDefinitionPtr get(const std::string &option_space, const uint16_t option_code) const
Return option definition for a particular option space and code.
void copyTo(CfgOptionDef &new_config) const
Copies this configuration to a new configuration.
Exception to be thrown when the particular option definition duplicates existing option definition.
static OptionDefinitionPtr getOptionDef(const std::string &space, const uint16_t code)
Return the first option definition matching a particular option code.
static const std::string & getDataTypeName(const OptionDataType data_type)
Return option data type name from the data type enumerator.
void addItem(const OptionDefinitionPtr &def)
Adds a new option definition to the container.
Base class representing a DHCP option definition.
std::vector< OptionDataType > RecordFieldsCollection
List of fields within the record.
uint64_t deleteItems(const uint64_t id)
Remove all options or option definitions with a given database identifier.
void clearItems()
Remove all items from the container.
std::list< Selector > getOptionSpaceNames() const
Get a list of existing option spaces.
ItemsContainerPtr getItems(const Selector &option_space) const
Get all items for the particular option space.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< Element > ElementPtr
boost::shared_ptr< OptionDefinition > OptionDefinitionPtr
Pointer to option definition object.
std::pair< OptionDefContainerNameIndex::const_iterator, OptionDefContainerNameIndex::const_iterator > OptionDefContainerNameRange
Pair of iterators to represent the range of options definitions having the same option name.
OptionDefContainer::nth_index< 2 >::type OptionDefContainerNameIndex
Type of the index #2 - option name.
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.
OptionDefContainer::nth_index< 1 >::type OptionDefContainerTypeIndex
Type of the index #1 - option type.
boost::shared_ptr< OptionDefContainer > OptionDefContainerPtr
Pointer to an option definition container.
Defines the logger used by the top-level component of kea-lfc.