Kea  2.3.1-git
isc::data Namespace Reference

Classes

class  BaseStampedElement
 This class represents configuration element which is associated with database identifier and the modification timestamp. More...
 
class  BoolElement
 
struct  CfgToElement
 Abstract class for configuration Cfg_* classes. More...
 
class  DoubleElement
 
class  Element
 The Element class represents a piece of data, used by the command channel and configuration parts. More...
 
class  ElementValue
 Template class for converting a value encapsulated in the Element object into a simple type. More...
 
class  ElementValue< asiolink::IOAddress >
 The ElementValue specialization for IOAddress. More...
 
class  ElementValue< bool >
 The ElementValue specialization for boolean. More...
 
class  ElementValue< double >
 The ElementValue specialization for double. More...
 
class  ElementValue< std::string >
 The ElementValue specialization for string. More...
 
struct  HierarchyTraversalTest
 Structure holding the test functions used to traverse the element hierarchy. More...
 
class  IntElement
 Notes: IntElement type is changed to int64_t. More...
 
class  JSONError
 A standard Data module exception that is thrown if a parse error is encountered when constructing an Element from a string. More...
 
class  ListElement
 
class  MapElement
 
class  NullElement
 
class  ServerTag
 Represents a server tag. More...
 
struct  SimpleDefault
 This array defines a single entry of default values. More...
 
class  SimpleParser
 A simple parser. More...
 
class  StampedElement
 This class represents configuration element which is associated with database identifier, modification timestamp and servers. More...
 
class  StampedValue
 This class represents a named configuration parameter, e.g. More...
 
struct  StampedValueModificationTimeIndexTag
 Tag for the index for access by modification time. More...
 
struct  StampedValueNameIndexTag
 Tag for the index for access by value name. More...
 
class  StringElement
 
class  TypeError
 A standard Data module exception that is thrown if a function is called for an Element that has a wrong type (e.g. More...
 
struct  UserContext
 Base class for user context. More...
 

Typedefs

typedef boost::shared_ptr< const ElementConstElementPtr
 
typedef boost::shared_ptr< ElementElementPtr
 
typedef std::map< std::string, HierarchyTraversalTestFunctionMap
 Mapping between a container name and functions used to match elements inside the container. More...
 
typedef std::vector< FunctionMapHierarchyDescriptor
 Hierarchy descriptor of the containers in a specific Element hierarchy tree. More...
 
typedef std::function< bool(const std::string &)> IsKeyTestFunc
 Function used to check if the key is used for identification. More...
 
typedef std::function< bool(ElementPtr &, ElementPtr &)> MatchTestFunc
 Function used to check if two MapElements refer to the same configuration data. More...
 
typedef std::function< bool(ElementPtr &)> NoDataTestFunc
 Function used to check if the data provided for the element contains only information used for identification, or it contains extra useful data. More...
 
typedef std::vector< std::string > ParamsList
 This defines a list of all parameters that are derived (or inherited) between contexts. More...
 
typedef std::vector< SimpleDefaultSimpleDefaults
 This specifies all default values in a given scope (e.g. a subnet). More...
 
typedef std::map< std::string, isc::data::Element::typesSimpleKeywords
 This specifies all accepted keywords with their types. More...
 
typedef std::vector< std::string > SimpleRequiredKeywords
 This specifies all required keywords. More...
 
typedef boost::shared_ptr< StampedValueStampedValuePtr
 Pointer to the stamped value. More...
 
Definition of the multi index container for @c StampedValue.
typedef boost::multi_index_container< StampedValuePtr, boost::multi_index::indexed_by< boost::multi_index::hashed_non_unique< boost::multi_index::tag< StampedValueNameIndexTag >, boost::multi_index::const_mem_fun< StampedValue, std::string, &StampedValue::getName > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< StampedValueModificationTimeIndexTag >, boost::multi_index::const_mem_fun< BaseStampedElement, boost::posix_time::ptime, &BaseStampedElement::getModificationTime > > >> StampedValueCollection
 Multi index container for StampedValue. More...
 

Functions

ElementPtr copy (ConstElementPtr from, int level=100)
 Copy the data up to a nesting level. More...
 
void extend (const std::string &container, const std::string &extension, ElementPtr &element, ElementPtr &other, HierarchyDescriptor &hierarchy, std::string key, size_t idx=0, bool alter=false)
 Extends data by adding the specified 'extension' elements from 'other' inside the 'container' element (recursively). More...
 
bool isEquivalent (ConstElementPtr a, ConstElementPtr b)
 Compares the data with other using unordered lists. More...
 
bool isNull (ConstElementPtr p)
 Checks whether the given ElementPtr is a NULL pointer. More...
 
void merge (ElementPtr element, ConstElementPtr other)
 Merges the data from other into element. More...
 
void mergeDiffAdd (ElementPtr &element, ElementPtr &other, HierarchyDescriptor &hierarchy, std::string key, size_t idx=0)
 Merges the diff data by adding the missing elements from 'other' to 'element' (recursively). More...
 
void mergeDiffDel (ElementPtr &element, ElementPtr &other, HierarchyDescriptor &hierarchy, std::string key, size_t idx=0)
 Merges the diff data by removing the data present in 'other' from 'element' (recursively). More...
 
bool operator!= (const Element &a, const Element &b)
 
bool operator< (Element const &a, Element const &b)
 
std::ostream & operator<< (std::ostream &out, const Element::Position &pos)
 Insert Element::Position as a string into stream. More...
 
std::ostream & operator<< (std::ostream &os, const ServerTag &server_tag)
 Insert the ServerTag as a string into stream. More...
 
std::ostream & operator<< (std::ostream &out, const Element &e)
 Insert the Element as a string into stream. More...
 
bool operator== (const Element &a, const Element &b)
 
void prettyPrint (ConstElementPtr element, std::ostream &out, unsigned indent=0, unsigned step=2)
 Pretty prints the data into stream. More...
 
std::string prettyPrint (ConstElementPtr element, unsigned indent=0, unsigned step=2)
 Pretty prints the data into string. More...
 
void removeIdentical (ElementPtr a, ConstElementPtr b)
 Remove all values from the first ElementPtr that are equal in the second. More...
 
ConstElementPtr removeIdentical (ConstElementPtr a, ConstElementPtr b)
 Create a new ElementPtr from the first ElementPtr, removing all values that are equal in the second. More...
 

Typedef Documentation

◆ ConstElementPtr

typedef boost::shared_ptr<const Element> isc::data::ConstElementPtr

Definition at line 27 of file data.h.

◆ ElementPtr

typedef boost::shared_ptr<Element> isc::data::ElementPtr

Definition at line 24 of file data.h.

◆ FunctionMap

typedef std::map<std::string, HierarchyTraversalTest> isc::data::FunctionMap

Mapping between a container name and functions used to match elements inside the container.

Definition at line 842 of file data.h.

◆ HierarchyDescriptor

Hierarchy descriptor of the containers in a specific Element hierarchy tree.

The position inside the vector indicates the level at which the respective containers are located.

e.g. { { { "pools", { ... , ... } }, { "pd-pools", { ... , ... } }, { "option-data", { ... , ... } } }, { { "option-data", { ... , ... } } } } At first subnet level the 'pools', 'pd-pools' and 'option-data' containers can be found. At second subnet level the 'option-data' container can be found (obviously only inside 'pools' and 'pd-pools' containers).

Definition at line 857 of file data.h.

◆ IsKeyTestFunc

typedef std::function<bool (const std::string&)> isc::data::IsKeyTestFunc

Function used to check if the key is used for identification.

Definition at line 830 of file data.h.

◆ MatchTestFunc

typedef std::function<bool (ElementPtr&, ElementPtr&)> isc::data::MatchTestFunc

Function used to check if two MapElements refer to the same configuration data.

It can check if the two MapElements have the same or have equivalent value for some members. e.g. ( left->get("prefix")->stringValue() == right->get("prefix")->stringValue() && left->get("prefix-len")->intValue() == right->get("prefix-len")->intValue() && left->get("delegated-len")->intValue() == right->get("delegated-len")->intValue() )

Definition at line 823 of file data.h.

◆ NoDataTestFunc

typedef std::function<bool (ElementPtr&)> isc::data::NoDataTestFunc

Function used to check if the data provided for the element contains only information used for identification, or it contains extra useful data.

Definition at line 827 of file data.h.

◆ ParamsList

typedef std::vector<std::string> isc::data::ParamsList

This defines a list of all parameters that are derived (or inherited) between contexts.

Definition at line 43 of file lib/cc/simple_parser.h.

◆ SimpleDefaults

This specifies all default values in a given scope (e.g. a subnet).

Definition at line 39 of file lib/cc/simple_parser.h.

◆ SimpleKeywords

typedef std::map<std::string, isc::data::Element::types> isc::data::SimpleKeywords

This specifies all accepted keywords with their types.

Definition at line 36 of file lib/cc/simple_parser.h.

◆ SimpleRequiredKeywords

typedef std::vector<std::string> isc::data::SimpleRequiredKeywords

This specifies all required keywords.

Definition at line 33 of file lib/cc/simple_parser.h.

◆ StampedValueCollection

typedef boost::multi_index_container< StampedValuePtr, boost::multi_index::indexed_by< boost::multi_index::hashed_non_unique< boost::multi_index::tag<StampedValueNameIndexTag>, boost::multi_index::const_mem_fun< StampedValue, std::string, &StampedValue::getName > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag<StampedValueModificationTimeIndexTag>, boost::multi_index::const_mem_fun< BaseStampedElement, boost::posix_time::ptime, &BaseStampedElement::getModificationTime > > >> isc::data::StampedValueCollection

Multi index container for StampedValue.

Definition at line 230 of file stamped_value.h.

◆ StampedValuePtr

typedef boost::shared_ptr<StampedValue> isc::data::StampedValuePtr

Pointer to the stamped value.

Definition at line 23 of file stamped_value.h.

Function Documentation

◆ copy()

◆ extend()

void isc::data::extend ( const std::string &  container,
const std::string &  extension,
ElementPtr element,
ElementPtr other,
HierarchyDescriptor hierarchy,
std::string  key,
size_t  idx = 0,
bool  alter = false 
)

Extends data by adding the specified 'extension' elements from 'other' inside the 'container' element (recursively).

Both elements must be the same Element type. Raises a TypeError if elements are not the same Element type.

Parameters
containerThe container holding the data that must be extended.
extensionThe name of the element that contains the data that must be added (if not already present) in order to extend the initial data.
elementThe element from which new data is added.
otherThe element containing the data which needs to be added.
hierarchyThe hierarchy describing the elements relations and identification keys.
keyThe container holding the current element.
idxThe level inside the hierarchy the current element is located.
alterThe flag which indicates if the current element should be updated.

Definition at line 1308 of file data.cc.

References isc_throw.

◆ isEquivalent()

bool isc::data::isEquivalent ( ConstElementPtr  a,
ConstElementPtr  b 
)

Compares the data with other using unordered lists.

This comparison function handles lists (JSON arrays) as unordered multi sets (multi means an item can occurs more than once as soon as it occurs the same number of times).

Definition at line 1482 of file data.cc.

Referenced by isc::test::runToElementTest().

◆ isNull()

bool isc::data::isNull ( ConstElementPtr  p)

Checks whether the given ElementPtr is a NULL pointer.

Parameters
pThe ElementPtr to check
Returns
true if it is NULL, false if not.

Definition at line 1088 of file data.cc.

Referenced by isc::data::MapElement::empty(), isc::hooks::HooksConfig::equal(), isc::hooks::HooksConfig::toElement(), isc::d2::D2CfgContext::toElement(), and isc::dhcp::SrvConfig::toElement().

◆ merge()

void isc::data::merge ( ElementPtr  element,
ConstElementPtr  other 
)

Merges the data from other into element.

(on the first level). Both elements must be MapElements. Every string, value pair in other is copied into element (the ElementPtr of value is copied, this is not a new object) Unless the value is a NullElement, in which case the key is removed from element, rather than setting the value to the given NullElement. This way, we can remove values from for instance maps with configuration data (which would then result in reverting back to the default). Raises a TypeError if either ElementPtr is not a MapElement

Definition at line 1139 of file data.cc.

References isc_throw.

Referenced by isc::data::MapElement::empty(), isc::process::ConfigControlInfo::getConfigDatabases(), isc::dhcp::SrvConfig::merge(), isc::dhcp::CfgOption::operator!=(), isc::dhcp::SrvConfig::operator!=(), isc::netconf::NetconfParser::parse(), isc::agent::AgentParser::parse(), isc::d2::D2Parser::parse(), isc::dhcp::Dhcp4Parser::parse(), isc::dhcp::Dhcp6Parser::parse(), isc::dhcp::Subnet4::toElement(), and isc::dhcp::Subnet6::toElement().

◆ mergeDiffAdd()

void isc::data::mergeDiffAdd ( ElementPtr element,
ElementPtr other,
HierarchyDescriptor hierarchy,
std::string  key,
size_t  idx = 0 
)

Merges the diff data by adding the missing elements from 'other' to 'element' (recursively).

Both elements must be the same Element type. Raises a TypeError if elements are not the same Element type.

Note
for non map and list elements the values are updated with the new values for maps:
  • non map and list elements are added/updated with the new values
  • list and map elements are processed recursively for lists:
  • regardless of the element type, all elements from 'other' are added to 'element'
Parameters
elementThe element to which new data is added.
otherThe element containing the data which needs to be added.
hierarchyThe hierarchy describing the elements relations and identification keys.
keyThe container holding the current element.
idxThe level inside the hierarchy the current element is located.

Definition at line 1157 of file data.cc.

References isc_throw.

◆ mergeDiffDel()

void isc::data::mergeDiffDel ( ElementPtr element,
ElementPtr other,
HierarchyDescriptor hierarchy,
std::string  key,
size_t  idx = 0 
)

Merges the diff data by removing the data present in 'other' from 'element' (recursively).

Both elements must be the same Element type. Raises a TypeError if elements are not the same Element type. for non map and list elements the values are set to NullElement for maps:

  • non map and list elements are removed from the map
  • list and map elements are processed recursively for lists:
  • regardless of the element type, all elements from 'other' matching elements in 'element' are removed
Parameters
elementThe element from which new data is removed.
otherThe element containing the data which needs to be removed.
hierarchyThe hierarchy describing the elements relations and identification keys.
keyThe container holding the current element.
idxThe level inside the hierarchy the current element is located.

Definition at line 1218 of file data.cc.

References isc::data::Element::find(), isc_throw, and isc::data::Element::remove().

+ Here is the call graph for this function:

◆ operator!=()

bool isc::data::operator!= ( const Element a,
const Element b 
)

◆ operator<()

bool isc::data::operator< ( Element const &  a,
Element const &  b 
)

◆ operator<<() [1/3]

std::ostream & isc::data::operator<< ( std::ostream &  out,
const Element::Position pos 
)

Insert Element::Position as a string into stream.

This operator converts the Element::Position into a string and inserts it into the output stream out.

Parameters
outA std::ostream object on which the insertion operation is performed.
posThe Element::Position structure to insert.
Returns
A reference to the same std::ostream object referenced by parameter out after the insertion operation.

Definition at line 45 of file data.cc.

References isc::data::Element::Position::str().

Referenced by isc::data::ServerTag::operator<().

+ Here is the call graph for this function:

◆ operator<<() [2/3]

std::ostream & isc::data::operator<< ( std::ostream &  os,
const ServerTag server_tag 
)

Insert the ServerTag as a string into stream.

Parameters
osstream to insert server tag into.
server_tagserver tag to be converted to text and inserted into a stream.
Returns
Reference to the stream object with inserted server tag.

Definition at line 47 of file server_tag.cc.

References isc::data::ServerTag::get().

+ Here is the call graph for this function:

◆ operator<<() [3/3]

std::ostream & isc::data::operator<< ( std::ostream &  out,
const Element e 
)

Insert the Element as a string into stream.

This method converts the ElementPtr into a string with Element::str() and inserts it into the output stream out.

This function overloads the global operator<< to behave as described in ostream::operator<< but applied to ElementPtr objects.

Parameters
outA std::ostream object on which the insertion operation is performed.
eThe ElementPtr object to insert.
Returns
A reference to the same std::ostream object referenced by parameter out after the insertion operation.

Definition at line 205 of file data.cc.

References isc::data::Element::str().

+ Here is the call graph for this function:

◆ operator==()

◆ prettyPrint() [1/2]

void isc::data::prettyPrint ( ConstElementPtr  element,
std::ostream &  out,
unsigned  indent = 0,
unsigned  step = 2 
)

Pretty prints the data into stream.

This operator converts the ConstElementPtr into a string and inserts it into the output stream out with an initial indentation indent and add at each level step spaces. For maps if there is a comment property it is printed first.

Parameters
elementA ConstElementPtr to pretty print
outA std::ostream on which the print operation is performed
indentAn initial number of spaces to add each new line
stepA number of spaces to add to indentation at a new level

Definition at line 1487 of file data.cc.

References isc_throw, and prettyPrint().

Referenced by isc::netconf::NetconfAgent::change(), isc::dhcp::Memfile_LeaseMgr::checkLimits4(), isc::dhcp::Memfile_LeaseMgr::checkLimits6(), isc::netconf::StdoutControlSocket::configSet(), isc::netconf::NetconfAgent::done(), isc::dhcp::ClassLeaseCounter::getLeaseClientClasses(), isc::netconf::NetconfAgent::keaConfig(), isc::test::runToElementTest(), isc::process::Daemon::writeConfigFile(), and isc::netconf::NetconfAgent::yangConfig().

+ Here is the call graph for this function:

◆ prettyPrint() [2/2]

std::string isc::data::prettyPrint ( ConstElementPtr  element,
unsigned  indent = 0,
unsigned  step = 2 
)

Pretty prints the data into string.

This operator converts the ConstElementPtr into a string with an initial indentation indent and add at each level step spaces. For maps if there is a comment property it is printed first.

Parameters
elementA ConstElementPtr to pretty print
indentAn initial number of spaces to add each new line
stepA number of spaces to add to indentation at a new level
Returns
a string where element was pretty printed

Definition at line 1572 of file data.cc.

Referenced by prettyPrint().

◆ removeIdentical() [1/2]

void isc::data::removeIdentical ( ElementPtr  a,
ConstElementPtr  b 
)

Remove all values from the first ElementPtr that are equal in the second.

Both ElementPtrs MUST be MapElements The use for this function is to end up with a MapElement that only contains new and changed values (for ModuleCCSession and configuration update handlers) Raises a TypeError if a or b are not MapElements

Definition at line 1093 of file data.cc.

References isc_throw.

Referenced by isc::data::MapElement::empty().

◆ removeIdentical() [2/2]

ConstElementPtr isc::data::removeIdentical ( ConstElementPtr  a,
ConstElementPtr  b 
)

Create a new ElementPtr from the first ElementPtr, removing all values that are equal in the second.

Both ElementPtrs MUST be MapElements. The returned ElementPtr will be a MapElement that only contains new and changed values (for ModuleCCSession and configuration update handlers). Raises a TypeError if a or b are not MapElements

Definition at line 1116 of file data.cc.

References isc_throw.