blob: 88bccae552eaed1f49d182debb9b300c7acbcb9e [file] [log] [blame]
Václav Kubernát624a8872018-03-02 17:28:47 +01001/*
2 * Copyright (C) 2018 CESNET, https://photonics.cesnet.cz/
3 *
4 * Written by Václav Kubernát <kubervac@fit.cvut.cz>
5 *
6*/
7
8#pragma once
9
10#include <stdexcept>
11#include <unordered_map>
12#include <unordered_set>
13
14class InvalidNodeException : public std::invalid_argument {
15public:
16 using std::invalid_argument::invalid_argument;
17 ~InvalidNodeException() override;
18
19};
20
21/*! \class CTree
22 * \brief The class representing the tree, that the user traverses.
23 *
24 * This class holds the current position in the tree and handles changing the position,
25 * including checking what nodes are available.
26 * */
27class CTree {
28public:
29 bool checkNode(const std::string& location, const std::string& node) const;
30 void changeNode(const std::string& node);
31 void initDefault();
32 std::string currentNode() const;
33
34private:
35 void addNode(const std::string& location, const std::string& node);
36 const std::unordered_set<std::string>& children(const std::string& node) const;
37
38 std::unordered_map<std::string, std::unordered_set<std::string>> m_nodes;
39 std::string m_curDir;
40};