Kea  2.1.7-git
isc::dhcp::OptionSpaceContainer< ContainerType, ItemType, Selector > Class Template Reference

Simple container for option spaces holding various items. More...

#include <option_space_container.h>

+ Inheritance diagram for isc::dhcp::OptionSpaceContainer< ContainerType, ItemType, Selector >:

Public Types

typedef boost::shared_ptr< ContainerType > ItemsContainerPtr
 Pointer to the container. More...
 

Public Member Functions

void addItem (const ItemType &item, const Selector &option_space)
 Adds a new item to the option_space. More...
 
void clearItems ()
 Remove all items from the container. More...
 
uint64_t deleteItems (const uint64_t id)
 Remove all options or option definitions with a given database identifier. More...
 
bool empty () const
 Indicates the container is empty. More...
 
bool equals (const OptionSpaceContainer &other) const
 Check if two containers are equal. More...
 
ItemsContainerPtr getItems (const Selector &option_space) const
 Get all items for the particular option space. More...
 
std::list< Selector > getOptionSpaceNames () const
 Get a list of existing option spaces. More...
 

Detailed Description

template<typename ContainerType, typename ItemType, typename Selector>
class isc::dhcp::OptionSpaceContainer< ContainerType, ItemType, Selector >

Simple container for option spaces holding various items.

This helper class is used to store items of various types that are grouped by option space names. Each option space is mapped to a container that holds items which specifically can be OptionDefinition objects or Subnet::OptionDescriptor structures.

Template Parameters
ContainerTypeof the container holding items within option space.
ItemTypetype of the item being held by the container.
Selectora string (for option spaces) or uint32_t (for vendor options)

Definition at line 32 of file option_space_container.h.

Member Typedef Documentation

◆ ItemsContainerPtr

template<typename ContainerType, typename ItemType, typename Selector>
typedef boost::shared_ptr<ContainerType> isc::dhcp::OptionSpaceContainer< ContainerType, ItemType, Selector >::ItemsContainerPtr

Pointer to the container.

Definition at line 36 of file option_space_container.h.

Member Function Documentation

◆ addItem()

template<typename ContainerType, typename ItemType, typename Selector>
void isc::dhcp::OptionSpaceContainer< ContainerType, ItemType, Selector >::addItem ( const ItemType &  item,
const Selector &  option_space 
)
inline

Adds a new item to the option_space.

Parameters
itemreference to the item being added.
option_spacename or vendor-id of the option space

Definition at line 49 of file option_space_container.h.

Referenced by isc::dhcp::OptionDefSpaceContainer::addItem().

◆ clearItems()

template<typename ContainerType, typename ItemType, typename Selector>
void isc::dhcp::OptionSpaceContainer< ContainerType, ItemType, Selector >::clearItems ( )
inline

Remove all items from the container.

Definition at line 94 of file option_space_container.h.

Referenced by isc::dhcp::CfgOptionDef::copyTo(), and isc::dhcp::CfgOption::copyTo().

◆ deleteItems()

template<typename ContainerType, typename ItemType, typename Selector>
uint64_t isc::dhcp::OptionSpaceContainer< ContainerType, ItemType, Selector >::deleteItems ( const uint64_t  id)
inline

Remove all options or option definitions with a given database identifier.

Note that there are cases when there will be multiple options or option definitions having the same id (typically id of 0). When configuration backend is in use it sets the unique ids from the database. In cases when the configuration backend is not used, the ids default to 0. Passing the id of 0 would result in deleting all options or option definitions that were not added via the database.

Parameters
idIdentifier of the items to be deleted.
Returns
Number of deleted options or option definitions.

Definition at line 112 of file option_space_container.h.

◆ empty()

template<typename ContainerType, typename ItemType, typename Selector>
bool isc::dhcp::OptionSpaceContainer< ContainerType, ItemType, Selector >::empty ( ) const
inline

Indicates the container is empty.

Returns
true when the container is empty

Definition at line 41 of file option_space_container.h.

◆ equals()

template<typename ContainerType, typename ItemType, typename Selector>
bool isc::dhcp::OptionSpaceContainer< ContainerType, ItemType, Selector >::equals ( const OptionSpaceContainer< ContainerType, ItemType, Selector > &  other) const
inline

Check if two containers are equal.

This method checks if option space container contains exactly the same selectors and that there are exactly the same items added for each selector. The order of items doesn't matter.

Parameters
otherOther container to compare to.
Returns
true if containers are equal, false otherwise.

Definition at line 132 of file option_space_container.h.

◆ getItems()

template<typename ContainerType, typename ItemType, typename Selector>
ItemsContainerPtr isc::dhcp::OptionSpaceContainer< ContainerType, ItemType, Selector >::getItems ( const Selector &  option_space) const
inline

Get all items for the particular option space.

Warning
when there are no items for the specified option space an empty container is created and returned. However this container is not added to the list of option spaces.
Parameters
option_spacename or vendor-id of the option space.
Returns
pointer to the container holding items.

Definition at line 67 of file option_space_container.h.

Referenced by isc::dhcp::LibDHCP::setRuntimeOptionDefs().

◆ getOptionSpaceNames()

template<typename ContainerType, typename ItemType, typename Selector>
std::list<Selector> isc::dhcp::OptionSpaceContainer< ContainerType, ItemType, Selector >::getOptionSpaceNames ( ) const
inline

Get a list of existing option spaces.

Returns
a list of option spaces.
Todo:
This function is likely to be removed once we create a structure of OptionSpaces defined through the configuration manager.

Definition at line 83 of file option_space_container.h.

Referenced by isc::dhcp::CfgOptionDef::equals(), isc::dhcp::CfgOptionDef::merge(), and isc::dhcp::LibDHCP::setRuntimeOptionDefs().


The documentation for this class was generated from the following file: