Kea  1.9.9-git
translator.h
Go to the documentation of this file.
1 // Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 
7 #ifndef ISC_TRANSLATOR_H
8 #define ISC_TRANSLATOR_H 1
9 
10 #include <cc/data.h>
11 #include <yang/sysrepo_error.h>
12 
13 #ifndef HAVE_SYSREPO
14 #error "config.h must be included before translator.h"
15 #endif
16 
17 #ifndef HAVE_PRE_0_7_6_SYSREPO
18 #include <sysrepo-cpp/Session.hpp>
19 #else
20 #include <sysrepo-cpp/Session.h>
21 #endif
22 
23 namespace isc {
24 namespace yang {
25 
28 public:
29 
34 #ifndef HAVE_PRE_0_7_6_SYSREPO
35  TranslatorBasic(sysrepo::S_Session session, const std::string& model);
36 #else
37  TranslatorBasic(S_Session session, const std::string& model);
38 #endif
39 
41  virtual ~TranslatorBasic();
42 
50 #ifndef HAVE_PRE_0_7_6_SYSREPO
51  static isc::data::ElementPtr value(sysrepo::S_Val s_val);
52 #else
53  static isc::data::ElementPtr value(S_Val s_val);
54 #endif
55 
65  isc::data::ElementPtr getItem(const std::string& xpath);
66 
72  isc::data::ElementPtr getItems(const std::string& xpath);
73 
80 #ifndef HAVE_PRE_0_7_6_SYSREPO
81  static sysrepo::S_Val value(isc::data::ConstElementPtr elem,
82  sr_type_t type);
83 #else
84  static S_Val value(isc::data::ConstElementPtr elem, sr_type_t type);
85 #endif
86 
92  void setItem(const std::string& xpath, isc::data::ConstElementPtr elem,
93  sr_type_t type);
94 
98  void delItem(const std::string& xpath);
99 
101 
106 #ifndef HAVE_PRE_0_7_6_SYSREPO
107  sysrepo::S_Iter_Value getIter(const std::string& xpath);
108 #else
109  S_Iter_Value getIter(const std::string& xpath);
110 #endif
111 
117 #ifndef HAVE_PRE_0_7_6_SYSREPO
118  std::string getNext(sysrepo::S_Iter_Value iter);
119 #else
120  std::string getNext(S_Iter_Value iter);
121 #endif
122 
123 protected:
125 #ifndef HAVE_PRE_0_7_6_SYSREPO
126  sysrepo::S_Session session_;
127 #else
128  S_Session session_;
129 #endif
130 
132  std::string model_;
133 };
134 
135 }; // end of namespace isc::yang
136 }; // end of namespace isc
137 
138 #endif // ISC_TRANSLATOR_H
isc::data::ElementPtr getItems(const std::string &xpath)
Get and translate a list of basic values from YANG to JSON.
Definition: translator.cc:126
Between YANG and JSON translator class for basic values.
Definition: translator.h:27
virtual ~TranslatorBasic()
Destructor.
Definition: translator.cc:47
boost::shared_ptr< Element > ElementPtr
Definition: data.h:20
static isc::data::ElementPtr value(sysrepo::S_Val s_val)
Translate basic value from YANG to JSON.
Definition: translator.cc:52
sysrepo::S_Iter_Value getIter(const std::string &xpath)
List iterator methods keeping the session private.
Definition: translator.cc:316
void setItem(const std::string &xpath, isc::data::ConstElementPtr elem, sr_type_t type)
Translate and set basic value from JSON to YANG.
Definition: translator.cc:288
std::string model_
The model.
Definition: translator.h:132
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:23
std::string getNext(sysrepo::S_Iter_Value iter)
Get xpath of the next YANG list item.
Definition: translator.cc:321
TranslatorBasic(sysrepo::S_Session session, const std::string &model)
Constructor.
Definition: translator.cc:43
void delItem(const std::string &xpath)
Delete basic value from YANG.
Definition: translator.cc:304
Defines the logger used by the top-level component of kea-dhcp-ddns.
isc::data::ElementPtr getItem(const std::string &xpath)
Get and translate basic value from YANG to JSON.
Definition: translator.cc:111
sysrepo::S_Session session_
The sysrepo session.
Definition: translator.h:126