7#ifndef OPTION_SPACE_CONTAINER_H
8#define OPTION_SPACE_CONTAINER_H
31template<
typename ContainerType,
typename ItemType,
typename Selector>
42 return (option_space_map_.empty());
49 void addItem(
const ItemType& item,
const Selector& option_space) {
54 static_cast<void>(items->push_back(item));
55 option_space_map_[option_space] = items;
68 const typename OptionSpaceMap::const_iterator& items =
69 option_space_map_.find(option_space);
70 if (items == option_space_map_.end()) {
73 return (items->second);
84 std::list<Selector> names;
85 for (
typename OptionSpaceMap::const_iterator space =
86 option_space_map_.begin();
87 space != option_space_map_.end(); ++space) {
88 names.push_back(space->first);
95 option_space_map_.clear();
113 uint64_t num_deleted = 0;
114 for (
auto const& space : option_space_map_) {
115 auto container = space.second;
116 auto& index = container->template get<OptionIdIndexTag>();
117 num_deleted += index.erase(
id);
120 return (num_deleted);
133 for (
typename OptionSpaceMap::const_iterator it =
134 option_space_map_.begin(); it != option_space_map_.end();
137 typename OptionSpaceMap::const_iterator other_it =
138 other.option_space_map_.find(it->first);
139 if (other_it == other.option_space_map_.end()) {
145 if (it->second->size() != other_it->second->size()) {
150 for (
typename ContainerType::const_iterator items_it =
152 items_it != it->second->end(); ++items_it) {
154 bool match_found =
false;
155 for (
typename ContainerType::const_iterator other_items_it =
156 other_it->second->begin();
157 other_items_it != other_it->second->end();
159 if (items_it->equals(*other_items_it)) {
176 typedef std::map<Selector, ItemsContainerPtr> OptionSpaceMap;
177 OptionSpaceMap option_space_map_;
Simple container for option spaces holding various items.
boost::shared_ptr< ContainerType > ItemsContainerPtr
Pointer to the container.
uint64_t deleteItems(const uint64_t id)
Remove all options or option definitions with a given database identifier.
void addItem(const ItemType &item, const Selector &option_space)
Adds a new item to the option_space.
bool empty() const
Indicates the container is empty.
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.
bool equals(const OptionSpaceContainer &other) const
Check if two containers are equal.
Defines the logger used by the top-level component of kea-lfc.
A tag for accessing DHCP options and definitions by id.