2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-30 13:37:55 +00:00

[#2601] rename TranslatorBasic to Translator

This commit is contained in:
Andrei Pavel
2022-11-07 09:52:21 +02:00
committed by Razvan Becheriu
parent d6f69df968
commit ec27d6a73c
25 changed files with 143 additions and 142 deletions

View File

@@ -713,8 +713,8 @@ NetconfAgent::logChanges(Session sess, string_view const& model) {
msg << " (list)";
} else {
optional<string> const str(
TranslatorBasic::translateToYang(TranslatorBasic::translateFromYang(change.node),
LeafBaseType::Unknown));
Translator::translateToYang(Translator::translateFromYang(change.node),
LeafBaseType::Unknown));
if (str) {
msg << " = " << *str;
}

View File

@@ -62,7 +62,7 @@ public:
virtual ~ConfigTest() = default;
void SetUp() override {
translator_.reset(new TranslatorBasic(session_, model_));
translator_.reset(new Translator(session_, model_));
cleanModelData();
}
@@ -181,7 +181,7 @@ public:
/// @brief The sysrepo session.
Session session_;
std::unique_ptr<TranslatorBasic> translator_;
std::unique_ptr<Translator> translator_;
}; // ConfigTest
struct ConfigTestKeaV4 : ConfigTest {

View File

@@ -20,7 +20,7 @@ using namespace isc::yang::test;
using namespace libyang;
using namespace sysrepo;
struct TranslatorBasicTest : ::testing::Test {
struct TranslatorTest : ::testing::Test {
void SetUp() override {
SysrepoSetup::cleanSharedMemory();
cleanUp();
@@ -42,27 +42,27 @@ private:
session.deleteItem("/keatest-module:presence-container");
session.applyChanges();
}
}; // TranslatorBasicTest
}; // TranslatorTest
namespace {
// Test constructor.
TEST_F(TranslatorBasicTest, constructor) {
TEST_F(TranslatorTest, constructor) {
// Get a session.
Session sess(Connection{}.sessionStart());
sess.switchDatastore(sysrepo::Datastore::Candidate);
// Get a translator object.
std::unique_ptr<TranslatorBasic> t_obj;
EXPECT_NO_THROW_LOG(t_obj.reset(new TranslatorBasic(sess, "")));
std::unique_ptr<Translator> t_obj;
EXPECT_NO_THROW_LOG(t_obj.reset(new Translator(sess, "")));
}
// Test basic YANG to JSON value conversion using sysrepo test models.
TEST_F(TranslatorBasicTest, getItem) {
TEST_F(TranslatorTest, getItem) {
// Get a translator object to play with.
Session sess(Connection{}.sessionStart());
sess.switchDatastore(sysrepo::Datastore::Candidate);
std::unique_ptr<TranslatorBasic> t_obj;
ASSERT_NO_THROW_LOG(t_obj.reset(new TranslatorBasic(sess, "")));
std::unique_ptr<Translator> t_obj;
ASSERT_NO_THROW_LOG(t_obj.reset(new Translator(sess, "")));
string value;
ConstElementPtr elem;
string xpath;
@@ -237,100 +237,100 @@ TEST_F(TranslatorBasicTest, getItem) {
}
// Test JSON to basic YANG value conversion using the static method.
TEST_F(TranslatorBasicTest, valueTo) {
TEST_F(TranslatorTest, valueTo) {
optional<string> value;
// Null.
ConstElementPtr elem;
EXPECT_NO_THROW_LOG(value = TranslatorBasic::translateToYang(elem, LeafBaseType::String));
EXPECT_NO_THROW_LOG(value = Translator::translateToYang(elem, LeafBaseType::String));
EXPECT_EQ(nullopt, value);
EXPECT_FALSE(elem);
// Container.
elem = Element::createMap();
EXPECT_THROW_MSG(TranslatorBasic::translateToYang(elem, LeafBaseType::Unknown), NotImplemented,
"TranslatorBasic::value(): map element");
EXPECT_THROW_MSG(Translator::translateToYang(elem, LeafBaseType::Unknown), NotImplemented,
"Translator::value(): map element");
// List.
elem = Element::createList();
EXPECT_THROW_MSG(TranslatorBasic::translateToYang(elem, LeafBaseType::Unknown), NotImplemented,
"TranslatorBasic::value(): list element");
EXPECT_THROW_MSG(Translator::translateToYang(elem, LeafBaseType::Unknown), NotImplemented,
"Translator::value(): list element");
// String.
string str("foo");
elem = Element::create(str);
EXPECT_NO_THROW_LOG(value = TranslatorBasic::translateToYang(elem, LeafBaseType::String));
EXPECT_NO_THROW_LOG(value = Translator::translateToYang(elem, LeafBaseType::String));
EXPECT_EQ(elem->stringValue(), value);
// Bool.
elem = Element::create(false);
EXPECT_NO_THROW_LOG(value = TranslatorBasic::translateToYang(elem, LeafBaseType::Bool));
EXPECT_NO_THROW_LOG(value = Translator::translateToYang(elem, LeafBaseType::Bool));
EXPECT_EQ(elem->str(), value);
// Unsigned 8 bit integer.
elem = Element::create(123);
EXPECT_NO_THROW_LOG(value = TranslatorBasic::translateToYang(elem, LeafBaseType::Uint8));
EXPECT_NO_THROW_LOG(value = Translator::translateToYang(elem, LeafBaseType::Uint8));
EXPECT_EQ(elem->str(), value);
elem.reset();
// Unsigned 16 bit integer.
elem = Element::create(12345);
EXPECT_NO_THROW_LOG(value = TranslatorBasic::translateToYang(elem, LeafBaseType::Uint16));
EXPECT_NO_THROW_LOG(value = Translator::translateToYang(elem, LeafBaseType::Uint16));
EXPECT_EQ(elem->str(), value);
elem.reset();
// Unsigned 32 bit integer.
elem = Element::create(123456789);
EXPECT_NO_THROW_LOG(value = TranslatorBasic::translateToYang(elem, LeafBaseType::Uint32));
EXPECT_NO_THROW_LOG(value = Translator::translateToYang(elem, LeafBaseType::Uint32));
EXPECT_EQ(elem->str(), value);
elem.reset();
// Signed 8 bit integer.
elem = Element::create(-123);
EXPECT_NO_THROW_LOG(value = TranslatorBasic::translateToYang(elem, LeafBaseType::Int8));
EXPECT_NO_THROW_LOG(value = Translator::translateToYang(elem, LeafBaseType::Int8));
EXPECT_EQ(elem->str(), value);
elem.reset();
// Signed 16 bit integer.
elem = Element::create(-12345);
EXPECT_NO_THROW_LOG(value = TranslatorBasic::translateToYang(elem, LeafBaseType::Int16));
EXPECT_NO_THROW_LOG(value = Translator::translateToYang(elem, LeafBaseType::Int16));
EXPECT_EQ(elem->str(), value);
elem.reset();
// Signed 32 bit integer.
elem = Element::create(-123456789);
EXPECT_NO_THROW_LOG(value = TranslatorBasic::translateToYang(elem, LeafBaseType::Int32));
EXPECT_NO_THROW_LOG(value = Translator::translateToYang(elem, LeafBaseType::Int32));
EXPECT_EQ(elem->str(), value);
elem.reset();
// Identity reference.
elem = Element::create(str);
EXPECT_NO_THROW_LOG(value = TranslatorBasic::translateToYang(elem, LeafBaseType::IdentityRef));
EXPECT_NO_THROW_LOG(value = Translator::translateToYang(elem, LeafBaseType::IdentityRef));
EXPECT_EQ(elem->stringValue(), value);
// Enumeration item.
EXPECT_NO_THROW_LOG(value = TranslatorBasic::translateToYang(elem, LeafBaseType::Enum));
EXPECT_NO_THROW_LOG(value = Translator::translateToYang(elem, LeafBaseType::Enum));
EXPECT_EQ(elem->stringValue(), value);
// Binary.
elem = Element::create(string("foobar"));
EXPECT_NO_THROW_LOG(value = TranslatorBasic::translateToYang(elem, LeafBaseType::Binary));
EXPECT_NO_THROW_LOG(value = Translator::translateToYang(elem, LeafBaseType::Binary));
EXPECT_EQ("Zm9vYmFy", value);
// Decimal 64.
double d64(.1234);
elem = Element::create(d64);
EXPECT_NO_THROW_LOG(value = TranslatorBasic::translateToYang(elem, LeafBaseType::Dec64));
EXPECT_NO_THROW_LOG(value = Translator::translateToYang(elem, LeafBaseType::Dec64));
EXPECT_EQ(elem->str(), value);
}
// Test JSON to basic YANG value conversion using sysrepo test models.
TEST_F(TranslatorBasicTest, setItem) {
TEST_F(TranslatorTest, setItem) {
// Get a translator object to play with.
Session sess(Connection{}.sessionStart());
sess.switchDatastore(sysrepo::Datastore::Candidate);
std::unique_ptr<TranslatorBasic> t_obj;
ASSERT_NO_THROW_LOG(t_obj.reset(new TranslatorBasic(sess, "")));
std::unique_ptr<Translator> t_obj;
ASSERT_NO_THROW_LOG(t_obj.reset(new Translator(sess, "")));
ElementPtr elem;
string xpath;
@@ -519,12 +519,12 @@ TEST_F(TranslatorBasicTest, setItem) {
}
// Test YANG list item retrieval.
TEST_F(TranslatorBasicTest, list) {
TEST_F(TranslatorTest, list) {
// Get a translator object to play with.
Session sess(Connection{}.sessionStart());
sess.switchDatastore(sysrepo::Datastore::Candidate);
std::unique_ptr<TranslatorBasic> t_obj;
ASSERT_NO_THROW_LOG(t_obj.reset(new TranslatorBasic(sess, "")));
std::unique_ptr<Translator> t_obj;
ASSERT_NO_THROW_LOG(t_obj.reset(new Translator(sess, "")));
string xpath;
// Empty list.

View File

@@ -240,7 +240,7 @@ void sanityCheckConfig(const std::string& model, const YRTree& tree) {
sess.switchDatastore(sysrepo::Datastore::Candidate);
// Cleanup.
TranslatorBasic translator(sess, model);
Translator translator(sess, model);
if (model == "keatest-module") {
translator.deleteItem("/keatest-module:container");
translator.deleteItem("/keatest-module:kernel-modules");

View File

@@ -99,7 +99,7 @@ YangRepr::YangReprItem::get(const string& xpath, Session session) {
// Get the underlying type.
type = data_node->schema().asLeaf().valueType().asLeafRef().resolvedType().base();
}
value = TranslatorBasic::translateToYang(TranslatorBasic::translateFromYang(data_node),
value = Translator::translateToYang(Translator::translateFromYang(data_node),
type);
val_xpath = string(data_node->path());
} catch (Error const& ex) {
@@ -113,7 +113,7 @@ YangRepr::Tree
YangRepr::get(Session session) const {
Tree result;
try {
TranslatorBasic tb(session, model_);
Translator tb(session, model_);
string const xpath0("/" + model_ + ":*//.");
tb.forAll(xpath0, [&](libyang::DataNode const& node) {
string const& xpath(node.path());

View File

@@ -24,14 +24,14 @@ using namespace sysrepo;
namespace isc {
namespace yang {
TranslatorBasic::TranslatorBasic(Session session, const string& model)
Translator::Translator(Session session, const string& model)
: session_(session), model_(model) {
}
void
TranslatorBasic::checkAndGetLeaf(ElementPtr& storage,
DataNode const& data_node,
string const& name) const {
Translator::checkAndGetLeaf(ElementPtr& storage,
DataNode const& data_node,
string const& name) const {
ElementPtr const& x(getItem(data_node, name));
if (x) {
storage->set(name, x);
@@ -39,10 +39,10 @@ TranslatorBasic::checkAndGetLeaf(ElementPtr& storage,
}
void
TranslatorBasic::checkAndGetDivergingLeaf(ElementPtr& storage,
DataNode const& data_node,
string const& name,
string const& yang_name) const {
Translator::checkAndGetDivergingLeaf(ElementPtr& storage,
DataNode const& data_node,
string const& name,
string const& yang_name) const {
ElementPtr const& x(getItem(data_node, yang_name));
if (x) {
storage->set(name, x);
@@ -50,9 +50,9 @@ TranslatorBasic::checkAndGetDivergingLeaf(ElementPtr& storage,
}
void
TranslatorBasic::checkAndGetAndJsonifyLeaf(ElementPtr& storage,
DataNode const& data_node,
string const& name) const {
Translator::checkAndGetAndJsonifyLeaf(ElementPtr& storage,
DataNode const& data_node,
string const& name) const {
ElementPtr const& x(getItem(data_node, name));
if (x) {
storage->set(name, Element::fromJSON(x->stringValue()));
@@ -60,9 +60,9 @@ TranslatorBasic::checkAndGetAndJsonifyLeaf(ElementPtr& storage,
}
void
TranslatorBasic::checkAndJsonifyAndSetLeaf(ConstElementPtr const& from,
string const& xpath,
string const& name) {
Translator::checkAndJsonifyAndSetLeaf(ConstElementPtr const& from,
string const& xpath,
string const& name) {
ConstElementPtr const& x(from->get(name));
if (x) {
ElementPtr const& json(Element::create(x->str()));
@@ -70,31 +70,31 @@ TranslatorBasic::checkAndJsonifyAndSetLeaf(ConstElementPtr const& from,
}
}
void TranslatorBasic::checkAndSetLeaf(ConstElementPtr const& from,
string const& xpath,
string const& name,
LeafBaseType const type) {
void Translator::checkAndSetLeaf(ConstElementPtr const& from,
string const& xpath,
string const& name,
LeafBaseType const type) {
ConstElementPtr const& x(from->get(name));
if (x) {
setItem(xpath + "/" + name, x, type);
}
}
void TranslatorBasic::checkAndSetDivergingLeaf(ConstElementPtr const& from,
string const& xpath,
string const& name,
string const& yang_name,
LeafBaseType const type) {
void Translator::checkAndSetDivergingLeaf(ConstElementPtr const& from,
string const& xpath,
string const& name,
string const& yang_name,
LeafBaseType const type) {
ConstElementPtr const& x(from->get(name));
if (x) {
setItem(xpath + "/" + yang_name, x, type);
}
}
void TranslatorBasic::checkAndSetLeafList(ConstElementPtr const& from,
string const& xpath,
string const& name,
LeafBaseType const type) {
void Translator::checkAndSetLeafList(ConstElementPtr const& from,
string const& xpath,
string const& name,
LeafBaseType const type) {
ConstElementPtr const& leaf_list(from->get(name));
if (leaf_list && !leaf_list->empty()) {
for (ElementPtr const& leaf : leaf_list->listValue()) {
@@ -103,8 +103,8 @@ void TranslatorBasic::checkAndSetLeafList(ConstElementPtr const& from,
}
}
void TranslatorBasic::checkAndSetUserContext(ConstElementPtr const& from,
string const& xpath) {
void Translator::checkAndSetUserContext(ConstElementPtr const& from,
string const& xpath) {
ConstElementPtr const& user_context(Adaptor::getContext(from));
if (user_context) {
setItem(xpath + "/user-context", Element::create(user_context->str()),
@@ -113,7 +113,7 @@ void TranslatorBasic::checkAndSetUserContext(ConstElementPtr const& from,
}
string
TranslatorBasic::decode64(string const& input) {
Translator::decode64(string const& input) {
vector<uint8_t> binary;
decodeBase64(input, binary);
string result;
@@ -123,7 +123,7 @@ TranslatorBasic::decode64(string const& input) {
}
void
TranslatorBasic::deleteItem(string const& xpath) {
Translator::deleteItem(string const& xpath) {
/// @todo: Remove this if convenient. It is not strictly required and only done to detect
/// missing schema nodes and throw an exception to keep old behavior.
try {
@@ -148,7 +148,7 @@ TranslatorBasic::deleteItem(string const& xpath) {
string
TranslatorBasic::encode64(string const& input) {
Translator::encode64(string const& input) {
vector<uint8_t> binary;
binary.resize(input.size());
memmove(&binary[0], input.c_str(), binary.size());
@@ -156,7 +156,7 @@ TranslatorBasic::encode64(string const& input) {
}
DataNode
TranslatorBasic::findXPath(string const& xpath) {
Translator::findXPath(string const& xpath) {
optional<DataNode> const& data_node(getData(xpath));
if (!data_node) {
isc_throw(NetconfError, "no data");
@@ -169,7 +169,7 @@ TranslatorBasic::findXPath(string const& xpath) {
}
optional<DataNode>
TranslatorBasic::getData(string const& xpath) const {
Translator::getData(string const& xpath) const {
/// @todo: Remove this if convenient. It is not strictly required and only done to detect
/// missing schema nodes and throw an exception to keep old behavior.
try {
@@ -192,7 +192,8 @@ TranslatorBasic::getData(string const& xpath) const {
}
ElementPtr
TranslatorBasic::getItem(DataNode const& data_node, string const& xpath) const {
Translator::getItem(DataNode const& data_node,
string const& xpath) const {
try {
Set<DataNode> const& nodes(data_node.findXPath(xpath));
if (nodes.empty()) {
@@ -227,7 +228,7 @@ TranslatorBasic::getItem(DataNode const& data_node, string const& xpath) const {
}
ElementPtr
TranslatorBasic::getItemFromAbsoluteXpath(string const& xpath) const {
Translator::getItemFromAbsoluteXpath(string const& xpath) const {
optional<DataNode> const& data_node(getData(xpath));
if (!data_node) {
/// @todo:
@@ -238,9 +239,9 @@ TranslatorBasic::getItemFromAbsoluteXpath(string const& xpath) const {
}
void
TranslatorBasic::getMandatoryLeaf(ElementPtr& storage,
DataNode const& data_node,
string const& name) const {
Translator::getMandatoryLeaf(ElementPtr& storage,
DataNode const& data_node,
string const& name) const {
ElementPtr const& x(getItem(data_node, name));
if (!x) {
isc_throw(MissingNode, name);
@@ -250,10 +251,10 @@ TranslatorBasic::getMandatoryLeaf(ElementPtr& storage,
void
TranslatorBasic::getMandatoryDivergingLeaf(ElementPtr& storage,
DataNode const& data_node,
string const& name,
string const& yang_name) const {
Translator::getMandatoryDivergingLeaf(ElementPtr& storage,
DataNode const& data_node,
string const& name,
string const& yang_name) const {
ElementPtr const& x(getItem(data_node, yang_name));
if (!x) {
isc_throw(MissingNode, yang_name);
@@ -262,7 +263,7 @@ TranslatorBasic::getMandatoryDivergingLeaf(ElementPtr& storage,
}
void
TranslatorBasic::setItem(const string& xpath, ConstElementPtr elem,
Translator::setItem(const string& xpath, ConstElementPtr elem,
LeafBaseType type) {
optional<string> const value(translateToYang(elem, type));
try {
@@ -275,10 +276,10 @@ TranslatorBasic::setItem(const string& xpath, ConstElementPtr elem,
}
void
TranslatorBasic::setMandatoryLeaf(ConstElementPtr const& from,
string const& xpath,
string const& name,
LeafBaseType const type) {
Translator::setMandatoryLeaf(ConstElementPtr const& from,
string const& xpath,
string const& name,
LeafBaseType const type) {
ConstElementPtr const& x(from->get(name));
if (!x) {
isc_throw(MissingNode, "xpath: " << xpath << ", name: " << name);
@@ -287,11 +288,11 @@ TranslatorBasic::setMandatoryLeaf(ConstElementPtr const& from,
}
void
TranslatorBasic::setMandatoryDivergingLeaf(ConstElementPtr const& from,
string const& xpath,
string const& name,
string const& yang_name,
LeafBaseType const type) {
Translator::setMandatoryDivergingLeaf(ConstElementPtr const& from,
string const& xpath,
string const& name,
string const& yang_name,
LeafBaseType const type) {
ConstElementPtr const& x(from->get(name));
if (!x) {
isc_throw(MissingNode, "xpath: " << xpath << ", name: " << name);
@@ -300,7 +301,7 @@ TranslatorBasic::setMandatoryDivergingLeaf(ConstElementPtr const& from,
}
ElementPtr
TranslatorBasic::translateFromYang(optional<DataNode> data_node) {
Translator::translateFromYang(optional<DataNode> data_node) {
NodeType const node_type(data_node->schema().nodeType());
if (node_type == NodeType::Leaf || node_type == NodeType::Leaflist) {
DataNodeTerm const& leaf(data_node->asTerm());
@@ -322,8 +323,8 @@ TranslatorBasic::translateFromYang(optional<DataNode> data_node) {
}
optional<string>
TranslatorBasic::translateToYang(ConstElementPtr const& element,
LeafBaseType const type) {
Translator::translateToYang(ConstElementPtr const& element,
LeafBaseType const type) {
if (!element) {
// A null ElementPtr is how we signal that this item requires no value.
// Useful when setting YANG lists which is the only way to set their
@@ -331,10 +332,10 @@ TranslatorBasic::translateToYang(ConstElementPtr const& element,
return nullopt;
} else if (element->getType() == Element::map) {
/// @todo: implement
isc_throw(NotImplemented, "TranslatorBasic::value(): map element");
isc_throw(NotImplemented, "Translator::value(): map element");
} else if (element->getType() == Element::list) {
/// @todo: implement
isc_throw(NotImplemented, "TranslatorBasic::value(): list element");
isc_throw(NotImplemented, "Translator::value(): list element");
}
if (type == LeafBaseType::Enum ||
type == LeafBaseType::String ||

View File

@@ -17,16 +17,16 @@ namespace isc {
namespace yang {
/// @brief Between YANG and JSON translator class for basic values.
class TranslatorBasic {
class Translator {
public:
/// @brief Constructor.
///
/// @param session Sysrepo session.
/// @param model Model name (used and shared by derived classes).
TranslatorBasic(sysrepo::Session session, const std::string& model);
Translator(sysrepo::Session session, const std::string& model);
/// @brief Destructor.
virtual ~TranslatorBasic() = default;
virtual ~Translator() = default;
/// @brief Retrieves a child YANG data node identified by name from the
/// given parent YANG container node and stores it in the specified storage.
@@ -337,7 +337,7 @@ protected:
/// @brief The model.
std::string model_;
}; // TranslatorBasic
}; // Translator
} // namespace yang
} // namespace isc

View File

@@ -20,7 +20,7 @@ namespace isc {
namespace yang {
TranslatorClass::TranslatorClass(Session session, const string& model)
: TranslatorBasic(session, model),
: Translator(session, model),
TranslatorOptionData(session, model),
TranslatorOptionDataList(session, model),
TranslatorOptionDef(session, model),
@@ -142,7 +142,7 @@ TranslatorClass::setClassKea(string const& xpath, ConstElementPtr elem) {
}
TranslatorClasses::TranslatorClasses(Session session, const string& model)
: TranslatorBasic(session, model),
: Translator(session, model),
TranslatorOptionData(session, model),
TranslatorOptionDataList(session, model),
TranslatorOptionDef(session, model),

View File

@@ -21,7 +21,7 @@ namespace isc {
namespace yang {
TranslatorConfig::TranslatorConfig(Session session, const string& model)
: TranslatorBasic(session, model),
: Translator(session, model),
TranslatorControlSocket(session, model),
TranslatorDatabase(session, model),
TranslatorDatabases(session, model),

View File

@@ -21,7 +21,7 @@ namespace yang {
TranslatorControlSocket::TranslatorControlSocket(Session session,
const string& model)
: TranslatorBasic(session, model) {
: Translator(session, model) {
}
ElementPtr

View File

@@ -65,7 +65,7 @@ namespace yang {
/// - kea-dhcp6-server
/// - kea-dhcp-ddns
/// - kea-ctrl-agent
class TranslatorControlSocket : virtual public TranslatorBasic {
class TranslatorControlSocket : virtual public Translator {
public:
/// @brief Constructor.
///

View File

@@ -20,7 +20,7 @@ namespace isc {
namespace yang {
TranslatorDatabase::TranslatorDatabase(Session session, const string& model)
: TranslatorBasic(session, model) {
: Translator(session, model) {
}
ElementPtr
@@ -131,7 +131,7 @@ TranslatorDatabase::setDatabaseKea(string const& xpath,
TranslatorDatabases::TranslatorDatabases(Session session,
const string& model)
: TranslatorBasic(session, model),
: Translator(session, model),
TranslatorDatabase(session, model) {
}

View File

@@ -101,7 +101,7 @@ namespace yang {
/// Supports the following models:
/// - kea-dhcp4-server
/// - kea-dhcp6-server
class TranslatorDatabase : virtual public TranslatorBasic {
class TranslatorDatabase : virtual public Translator {
public:
/// @brief Constructor.
///

View File

@@ -20,7 +20,7 @@ namespace isc {
namespace yang {
TranslatorHost::TranslatorHost(Session session, const string& model)
: TranslatorBasic(session, model),
: Translator(session, model),
TranslatorOptionData(session, model),
TranslatorOptionDataList(session, model) {
}
@@ -128,7 +128,7 @@ TranslatorHost::setHostKea(string const& xpath, ConstElementPtr elem) {
}
TranslatorHosts::TranslatorHosts(Session session, const string& model)
: TranslatorBasic(session, model),
: Translator(session, model),
TranslatorOptionData(session, model),
TranslatorOptionDataList(session, model),
TranslatorHost(session, model) {

View File

@@ -20,7 +20,7 @@ namespace isc {
namespace yang {
TranslatorLogger::TranslatorLogger(Session session, const string& model)
: TranslatorBasic(session, model) {
: Translator(session, model) {
}
ElementPtr
@@ -139,7 +139,7 @@ TranslatorLogger::setOutputOptions(string const& xpath, ConstElementPtr elem) {
}
TranslatorLoggers::TranslatorLoggers(Session session, const string& model)
: TranslatorBasic(session, model),
: Translator(session, model),
TranslatorLogger(session, model) {
}

View File

@@ -90,7 +90,7 @@ namespace yang {
/// - kea-dhcp6-server
/// - kea-dhcp-ddns
/// - kea-ctrl-agent
class TranslatorLogger : virtual public TranslatorBasic {
class TranslatorLogger : virtual public Translator {
public:
/// @brief Constructor.
///

View File

@@ -21,7 +21,7 @@ namespace yang {
TranslatorOptionData::TranslatorOptionData(Session session,
const string& model)
: TranslatorBasic(session, model) {
: Translator(session, model) {
}
ElementPtr
@@ -100,7 +100,7 @@ TranslatorOptionData::setOptionDataKea(string const& xpath,
TranslatorOptionDataList::TranslatorOptionDataList(Session session,
const string& model)
: TranslatorBasic(session, model),
: Translator(session, model),
TranslatorOptionData(session, model) {
}

View File

@@ -72,7 +72,7 @@ namespace yang {
/// YANG and JSON.
///
/// Currently supports on kea-dhcp[46]-server, not yet ietf-dhcpv6-server.
class TranslatorOptionData : virtual public TranslatorBasic {
class TranslatorOptionData : virtual public Translator {
public:
/// @brief Constructor.
///

View File

@@ -21,7 +21,7 @@ namespace yang {
TranslatorOptionDef::TranslatorOptionDef(Session session,
const string& model)
: TranslatorBasic(session, model) {
: Translator(session, model) {
}
ElementPtr
@@ -102,7 +102,7 @@ TranslatorOptionDef::setOptionDefKea(string const& xpath,
TranslatorOptionDefList::TranslatorOptionDefList(Session session,
const string& model)
: TranslatorBasic(session, model),
: Translator(session, model),
TranslatorOptionDef(session, model) {
}

View File

@@ -76,7 +76,7 @@ namespace yang {
///
/// Currently supports kea-dhcp[46]-server models.
/// @todo: Support for ietf-dhcpv6-server model.
class TranslatorOptionDef : virtual public TranslatorBasic {
class TranslatorOptionDef : virtual public Translator {
public:
/// @brief Constructor.
///

View File

@@ -22,7 +22,7 @@ namespace isc {
namespace yang {
TranslatorPdPool::TranslatorPdPool(Session session, const string& model)
: TranslatorBasic(session, model),
: Translator(session, model),
TranslatorOptionData(session, model),
TranslatorOptionDataList(session, model) {
}
@@ -234,7 +234,7 @@ TranslatorPdPool::setPdPoolKea(string const& xpath, ConstElementPtr elem) {
}
TranslatorPdPools::TranslatorPdPools(Session session, const string& model)
: TranslatorBasic(session, model),
: Translator(session, model),
TranslatorOptionData(session, model),
TranslatorOptionDataList(session, model),
TranslatorPdPool(session, model) {

View File

@@ -25,7 +25,7 @@ namespace isc {
namespace yang {
TranslatorPool::TranslatorPool(Session session, const string& model)
: TranslatorBasic(session, model),
: Translator(session, model),
TranslatorOptionData(session, model),
TranslatorOptionDataList(session, model) {
}
@@ -225,7 +225,7 @@ TranslatorPool::getAddresses(const string& prefix,
}
TranslatorPools::TranslatorPools(Session session, const string& model)
: TranslatorBasic(session, model),
: Translator(session, model),
TranslatorOptionData(session, model),
TranslatorOptionDataList(session, model),
TranslatorPool(session, model) {

View File

@@ -21,7 +21,7 @@ namespace yang {
TranslatorSharedNetwork::TranslatorSharedNetwork(Session session,
const string& model)
: TranslatorBasic(session, model),
: Translator(session, model),
TranslatorOptionData(session, model),
TranslatorOptionDataList(session, model),
TranslatorPool(session, model),
@@ -232,7 +232,7 @@ TranslatorSharedNetwork::setSharedNetworkKea(string const& xpath,
TranslatorSharedNetworks::TranslatorSharedNetworks(Session session,
const string& model)
: TranslatorBasic(session, model),
: Translator(session, model),
TranslatorOptionData(session, model),
TranslatorOptionDataList(session, model),
TranslatorPool(session, model),

View File

@@ -21,7 +21,7 @@ namespace isc {
namespace yang {
TranslatorSubnet::TranslatorSubnet(Session session, const string& model)
: TranslatorBasic(session, model),
: Translator(session, model),
TranslatorOptionData(session, model),
TranslatorOptionDataList(session, model),
TranslatorPool(session, model),
@@ -333,7 +333,7 @@ TranslatorSubnet::setSubnetKea(string const& xpath, ConstElementPtr elem) {
}
TranslatorSubnets::TranslatorSubnets(Session session, const string& model)
: TranslatorBasic(session, model),
: Translator(session, model),
TranslatorOptionData(session, model),
TranslatorOptionDataList(session, model),
TranslatorPool(session, model),

View File

@@ -16,7 +16,7 @@ data between YANG and JSON that is understandable by Kea.
An essential concept is the idea of translator. It is a primitive that is able
to convert certain data structure between YANG and JSON. It is envisaged
that more complex translators will use other translators to handle more
complex data structures. For details, see @ref isc::yang::TranslatorBasic.
complex data structures. For details, see @ref isc::yang::Translator.
It is also envisioned that translators could do the translation automatically by
relying on capabilities of iterating through data, retrieving data type
information and value information from nodes through the libyang and sysrepo
@@ -43,24 +43,24 @@ All translators take a Session pointer (a structure provided by Sysrepo that
is responsible for maintaining a connection) in constructors and derive from
the basic / base class and recursively from translators for embedded parts.
@c isc::yang::TranslatorBasic provides some methods:
- @c isc::yang::TranslatorBasic::checkAndGetLeaf() is a convenience wrapper
over @c isc::yang::TranslatorBasic::getItem().
- @c isc::yang::TranslatorBasic::checkAndSetLeaf() is a convenience wrapper
over @c isc::yang::TranslatorBasic::setItem().
- @c isc::yang::TranslatorBasic::deleteItem() deletes the data node found at
@c isc::yang::Translator provides some methods:
- @c isc::yang::Translator::checkAndGetLeaf() is a convenience wrapper
over @c isc::yang::Translator::getItem().
- @c isc::yang::Translator::checkAndSetLeaf() is a convenience wrapper
over @c isc::yang::Translator::setItem().
- @c isc::yang::Translator::deleteItem() deletes the data node found at
given xpth.
- @c isc::yang::TranslatorBasic::forAll() iterates over the node found at
- @c isc::yang::Translator::forAll() iterates over the node found at
given xpath and all its descendants and calls the given function.
- @c isc::yang::TranslatorBasic::getItem() retrieves and translates a leaf
- @c isc::yang::Translator::getItem() retrieves and translates a leaf
from YANG to JSON.
- @c isc::yang::TranslatorBasic::getList() retrieves a list from Sysrepo and
- @c isc::yang::Translator::getList() retrieves a list from Sysrepo and
translates it form YANG to JSON.
- @c isc::yang::TranslatorBasic::setItem() translates a leaf from JSON to
- @c isc::yang::Translator::setItem() translates a leaf from JSON to
YANG and sets it in Sysrepo.
- @c isc::yang::TranslatorBasic::translateFromYang(optional<DataNode>, string) translates a YANG
- @c isc::yang::Translator::translateFromYang(optional<DataNode>, string) translates a YANG
leaf to a JSON node.
- @c isc::yang::TranslatorBasic::translateToYang(ConstElementPtr, LeafBaseType)
- @c isc::yang::Translator::translateToYang(ConstElementPtr, LeafBaseType)
translates a JSON leaf to a string.
@section yangTranslatorPool Pool translator
@@ -78,7 +78,7 @@ Note pools show two shortcomings in IETF modules:
- prefix and start - end forms of pool ranges are both mandatory.
(reported to authors' so should be fixed in the next version).
All structure translators depend on @c isc::yang::TranslatorBasic and
All structure translators depend on @c isc::yang::Translator and
some of them depend on other structures, for instance
@c isc::yang::TranslatorPool depends on
@c isc::yang::TranslatorOptionDataList which itself, as all list translators,