Kea  2.3.1-git
isc::yang::TranslatorBasic Class Reference

Between YANG and JSON translator class for basic values. More...

#include <translator.h>

+ Inheritance diagram for isc::yang::TranslatorBasic:

Public Member Functions

 TranslatorBasic (sysrepo::S_Session session, const std::string &model)
 Constructor. More...
 
virtual ~TranslatorBasic ()
 Destructor. More...
 
void checkAndGetLeaf (isc::data::ElementPtr &storage, const std::string &xpath, const std::string &name)
 Retrieves an item and stores it in the specified storage. More...
 
void checkAndSetLeaf (isc::data::ConstElementPtr const &from, std::string const &xpath, std::string const &name, sr_type_t const type)
 Get an element from given ElementPtr node and set it in sysrepo at given xpath. More...
 
void delItem (const std::string &xpath)
 Delete basic value from YANG. More...
 
template<typename functor_t >
void forAll (std::string const &xpath, functor_t f)
 Run a function for a node and all its children. More...
 
isc::data::ElementPtr getItem (const std::string &xpath)
 Get and translate basic value from YANG to JSON. More...
 
isc::data::ElementPtr getItems (const std::string &xpath)
 Get and translate a list of basic values from YANG to JSON. More...
 
template<typename T >
isc::data::ElementPtr getList (std::string const &xpath, T &t, isc::data::ElementPtr(T::*f)(std::string const &xpath))
 Retrieve a list as ElementPtr from sysrepo from a certain xpath. More...
 
sysrepo::S_Vals getValuesFromItems (std::string const &xpath)
 Get the values of all siblings at a certain xpath. More...
 
void setItem (const std::string &xpath, isc::data::ConstElementPtr elem, sr_type_t type)
 Translate and set basic value from JSON to YANG. More...
 

Static Public Member Functions

static isc::data::ElementPtr value (sysrepo::S_Val s_val)
 Translate basic value from YANG to JSON. More...
 
static sysrepo::S_Val value (isc::data::ConstElementPtr elem, sr_type_t type)
 Translate basic value from JSON to YANG. More...
 

Protected Attributes

std::string model_
 The model. More...
 
sysrepo::S_Session session_
 The sysrepo session. More...
 

Detailed Description

Between YANG and JSON translator class for basic values.

Definition at line 19 of file translator.h.

Constructor & Destructor Documentation

◆ TranslatorBasic()

isc::yang::TranslatorBasic::TranslatorBasic ( sysrepo::S_Session  session,
const std::string &  model 
)

Constructor.

Parameters
sessionSysrepo session.
modelModel name (used and shared by derived classes).

Definition at line 41 of file translator.cc.

◆ ~TranslatorBasic()

isc::yang::TranslatorBasic::~TranslatorBasic ( )
virtual

Destructor.

Definition at line 45 of file translator.cc.

Member Function Documentation

◆ checkAndGetLeaf()

void isc::yang::TranslatorBasic::checkAndGetLeaf ( isc::data::ElementPtr storage,
const std::string &  xpath,
const std::string &  name 
)

Retrieves an item and stores it in the specified storage.

This will attempt to retrieve an item and, if exists, will store it in the storage.

Parameters
storageElementMap where result will be stored
xpathxpath location of data that will be extracted from sysrepo
namename of the parameter

Definition at line 274 of file translator.cc.

References getItem().

Referenced by isc::yang::TranslatorClass::getClassKea(), isc::yang::TranslatorConfig::getConfigControlKea(), isc::yang::TranslatorDatabase::getDatabaseKea(), isc::yang::TranslatorConfig::getDdnsKea(), isc::yang::TranslatorConfig::getExpiredKea(), isc::yang::TranslatorConfig::getServerKeaDhcp4(), isc::yang::TranslatorConfig::getServerKeaDhcp6(), isc::yang::TranslatorConfig::getServerKeaDhcpCommon(), and isc::yang::TranslatorSharedNetwork::getSharedNetworkKea().

+ Here is the call graph for this function:

◆ checkAndSetLeaf()

void isc::yang::TranslatorBasic::checkAndSetLeaf ( isc::data::ConstElementPtr const &  from,
std::string const &  xpath,
std::string const &  name,
sr_type_t const  type 
)

Get an element from given ElementPtr node and set it in sysrepo at given xpath.

Parameters
fromthe parent configuration node from which to take the value
xpaththe xpath to the YANG node without the last node
namethe name of the YANG node which should also match the map key in the JSON configuration
typethe sysrepo node type

Definition at line 283 of file translator.cc.

References setItem().

Referenced by isc::yang::TranslatorClass::setClassKea(), isc::yang::TranslatorDatabase::setDatabaseKea(), isc::yang::TranslatorConfig::setServerKeaDhcp4(), isc::yang::TranslatorConfig::setServerKeaDhcp6(), isc::yang::TranslatorConfig::setServerKeaDhcpCommon(), and isc::yang::TranslatorSharedNetwork::setSharedNetworkKea().

+ Here is the call graph for this function:

◆ delItem()

void isc::yang::TranslatorBasic::delItem ( const std::string &  xpath)

Delete basic value from YANG.

Parameters
xpathThe xpath of the basic value.

Definition at line 294 of file translator.cc.

References isc_throw, session_, and isc::Exception::what().

Referenced by isc::yang::TranslatorConfig::delConfigIetf6(), isc::yang::TranslatorConfig::delConfigKea(), isc::yang::TranslatorControlSocket::setControlSocketKea(), isc::yang::TranslatorDatabase::setDatabaseKea(), and isc::yang::TranslatorDatabases::setDatabasesKea().

+ Here is the call graph for this function:

◆ forAll()

template<typename functor_t >
void isc::yang::TranslatorBasic::forAll ( std::string const &  xpath,
functor_t  f 
)
inline

Run a function for a node and all its children.

Template Parameters
functor_ttypename of the function to be called
Parameters
xpaththe xpath to be travelled
fthe function to be called on the node itself and each descendant

Definition at line 122 of file translator.h.

References session_.

◆ getItem()

ElementPtr isc::yang::TranslatorBasic::getItem ( const std::string &  xpath)

◆ getItems()

ElementPtr isc::yang::TranslatorBasic::getItems ( const std::string &  xpath)

Get and translate a list of basic values from YANG to JSON.

Parameters
xpathThe xpath of the list of basic values.
Returns
The ListElement representing the leaf-list at xpath or null when not found.

Definition at line 124 of file translator.cc.

References getValuesFromItems(), isc_throw, value(), and isc::Exception::what().

Referenced by isc::yang::TranslatorHost::getHostKea(), isc::yang::TranslatorPdPool::getPdPoolKea(), isc::yang::TranslatorPool::getPoolKea(), isc::yang::TranslatorConfig::getServerKeaDhcp4(), isc::yang::TranslatorConfig::getServerKeaDhcp6(), isc::yang::TranslatorConfig::getServerKeaDhcpCommon(), and isc::yang::TranslatorSharedNetwork::getSharedNetworkKea().

+ Here is the call graph for this function:

◆ getList()

template<typename T >
isc::data::ElementPtr isc::yang::TranslatorBasic::getList ( std::string const &  xpath,
T &  t,
isc::data::ElementPtr(T::*)(std::string const &xpath)  f 
)
inline

Retrieve a list as ElementPtr from sysrepo from a certain xpath.

Template Parameters
Ttypename of the translator that holds the function that will be called on the xpath of each child from the list
Parameters
xpaththe xpath to the element to be retrieved from, usually a list
taddress of a translator instance that holds the function that will be called on the xpath of each child from the list
fthe function that will be called on the xpath of each child from the list

Definition at line 147 of file translator.h.

References isc::data::Element::createList(), and getValuesFromItems().

Referenced by isc::yang::TranslatorConfig::getHooksKea(), and isc::yang::TranslatorLogger::getOutputOptions().

+ Here is the call graph for this function:

◆ getValuesFromItems()

S_Vals isc::yang::TranslatorBasic::getValuesFromItems ( std::string const &  xpath)

Get the values of all siblings at a certain xpath.

Parameters
xpaththe xpath to the element to be retrieved from, usually a list
Returns
all the entries populated with values

Definition at line 309 of file translator.cc.

References isc_throw, session_, and isc::Exception::what().

Referenced by getItems(), and getList().

+ Here is the call graph for this function:

◆ setItem()

◆ value() [1/2]

ElementPtr isc::yang::TranslatorBasic::value ( sysrepo::S_Val  s_val)
static

Translate basic value from YANG to JSON.

Note
Please don't use this outside tests.
Parameters
s_valThe value.
Returns
The Element representing the sysrepo value.
Exceptions
NotImplementedwhen the value type is not supported.

Definition at line 49 of file translator.cc.

References isc_throw.

Referenced by getItem(), getItems(), and setItem().

◆ value() [2/2]

S_Val isc::yang::TranslatorBasic::value ( isc::data::ConstElementPtr  elem,
sr_type_t  type 
)
static

Translate basic value from JSON to YANG.

Note
Please don't use this outside tests.
Parameters
elemThe JSON element.
typeThe sysrepo type.

Definition at line 143 of file translator.cc.

References isc_throw.

Member Data Documentation

◆ model_

std::string isc::yang::TranslatorBasic::model_
protected

The model.

Definition at line 171 of file translator.h.

Referenced by isc::yang::TranslatorConfig::delConfigIetf6(), isc::yang::TranslatorConfig::delConfigKea(), isc::yang::TranslatorClass::getClass(), isc::yang::TranslatorClasses::getClasses(), isc::yang::TranslatorClass::getClassKea(), isc::yang::TranslatorConfig::getConfig(), isc::yang::TranslatorConfig::getConfigIetf6(), isc::yang::TranslatorControlSocket::getControlSocket(), isc::yang::TranslatorDatabase::getDatabase(), isc::yang::TranslatorDatabases::getDatabases(), isc::yang::TranslatorHost::getHost(), isc::yang::TranslatorHost::getHostKea(), isc::yang::TranslatorLogger::getLogger(), isc::yang::TranslatorLoggers::getLoggers(), isc::yang::TranslatorOptionData::getOptionData(), isc::yang::TranslatorOptionDataList::getOptionDataList(), isc::yang::TranslatorOptionDef::getOptionDef(), isc::yang::TranslatorOptionDefList::getOptionDefList(), isc::yang::TranslatorPdPool::getPdPool(), isc::yang::TranslatorPdPools::getPdPools(), isc::yang::TranslatorPool::getPool(), isc::yang::TranslatorPools::getPools(), isc::yang::TranslatorSharedNetwork::getSharedNetwork(), isc::yang::TranslatorSubnet::getSubnet(), isc::yang::TranslatorSubnet::getSubnetIetf6(), isc::yang::TranslatorSubnet::getSubnetKea(), isc::yang::TranslatorSubnets::getSubnets(), isc::yang::TranslatorClass::setClass(), isc::yang::TranslatorClasses::setClasses(), isc::yang::TranslatorClass::setClassKea(), isc::yang::TranslatorConfig::setConfig(), isc::yang::TranslatorConfig::setConfigIetf6(), isc::yang::TranslatorControlSocket::setControlSocket(), isc::yang::TranslatorDatabase::setDatabase(), isc::yang::TranslatorDatabases::setDatabases(), isc::yang::TranslatorHost::setHost(), isc::yang::TranslatorHost::setHostKea(), isc::yang::TranslatorHosts::setHosts(), isc::yang::TranslatorHosts::setHostsKea(), isc::yang::TranslatorLogger::setLogger(), isc::yang::TranslatorLoggers::setLoggers(), isc::yang::TranslatorOptionData::setOptionData(), isc::yang::TranslatorOptionDataList::setOptionDataList(), isc::yang::TranslatorOptionDef::setOptionDef(), isc::yang::TranslatorOptionDefList::setOptionDefList(), isc::yang::TranslatorPdPool::setPdPool(), isc::yang::TranslatorPdPools::setPdPools(), isc::yang::TranslatorPool::setPool(), isc::yang::TranslatorPools::setPools(), isc::yang::TranslatorSharedNetwork::setSharedNetwork(), isc::yang::TranslatorSharedNetworks::setSharedNetworks(), isc::yang::TranslatorSubnet::setSubnet(), isc::yang::TranslatorSubnet::setSubnetIetf6(), isc::yang::TranslatorSubnet::setSubnetKea(), and isc::yang::TranslatorSubnets::setSubnets().

◆ session_

sysrepo::S_Session isc::yang::TranslatorBasic::session_
protected

The sysrepo session.

Definition at line 168 of file translator.h.

Referenced by delItem(), forAll(), getItem(), getValuesFromItems(), and setItem().


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