namespace isc {
namespace yang {
-/// @brief Exception from the sysrepo library for connection.
+/// @brief An exception thrown when connection with sysrepo is broken
class SysrepoConnectionError : public Exception {
public:
SysrepoConnectionError(const char* file, size_t line, const char* what) :
isc::Exception(file, line, what) {}
};
-/// @brief Connection to the sysrepo library. Provision, i.e. currently unused.
+/// @brief A class that represents a connection to Sysrepo
class SysrepoConnection {
public:
- // @brief Constructor.
+
+ /// @brief constructor
+ ///
+ /// Currently does nothing. You need to explicitly call connect()
SysrepoConnection();
- // @brief Destructor.
+ /// @brief Destructor
+ ///
+ /// Discards any pending data, unlocks datastore and stops session.
virtual ~SysrepoConnection();
// @brief Get a connection and a session.
void connect();
- // @brief Commit a session.
+ /// @brief Commits any pending data.
void commit();
private:
- // @brief The session.
+
+ /// @brief pointer to a session
+ ///
+ /// May be null if the session is not established.
S_Session session_;
};
case SR_UINT8_T:
return (Element::create(static_cast<long long>(s_val->data()->get_uint8())));
+
case SR_UINT16_T:
return (Element::create(static_cast<long long>(s_val->data()->get_uint16())));
try {
s_val = session_->get_item(xpath.c_str());
} catch (const sysrepo_exception& ex) {
- isc_throw(SysrepoError,
- "sysrepo error getting item at '" << xpath
+ isc_throw(SysrepoError, "sysrepo error getting item at '" << xpath
<< "': " << ex.what());
}
if (!s_val) {
/// @brief Get xpath of the next Yang list item.
///
- /// @param iter The iterator.
- /// @return The xpath of the next element. Null when at the end of the list.
+ /// @param iter The iterator pointing to the previous element
+ /// @return The xpath of the next element. Empty string when at the end of the list.
std::string getNext(S_Iter_Value iter);
protected: