GCC Code Coverage Report


Directory: ./
File: src/msrproto/DirNode.h
Date: 2024-11-05 15:23:15
Exec Total Coverage
Lines: 3 3 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 /*****************************************************************************
2 *
3 * Copyright (C) 2015-2016 Richard Hacker (lerichi at gmx dot net)
4 *
5 * This file is part of the PdCom library.
6 *
7 * The PdCom library is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * The PdCom library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 * License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with the PdCom library. If not, see <http://www.gnu.org/licenses/>.
19 *
20 *****************************************************************************/
21
22 #ifndef PD_DIRNODE_H
23 #define PD_DIRNODE_H
24
25 #include <list>
26 #include <memory>
27 #include <string>
28 #include <vector>
29
30 namespace PdCom { namespace impl { namespace MsrProto {
31 class DirNode : public std::enable_shared_from_this<DirNode>
32 {
33 public:
34 DirNode(bool isDir = 1);
35 148 virtual ~DirNode() = default;
36
37 std::string path() const;
38 std::string name() const;
39
40 typedef std::list<std::shared_ptr<DirNode>> List;
41 void getChildren(List &list) const;
42 void getAllChildren(List &list) const;
43
44 bool hasChildren() const;
45
46 void insert(std::shared_ptr<DirNode> n, const char *path);
47 std::shared_ptr<DirNode> find(const std::string &path);
48
49 private:
50 DirNode *m_parent;
51 std::string m_name;
52
53 struct LessThan
54 {
55 bool operator()(const DirNode *n, const std::string &name) const
56 {
57 return n->m_name < name;
58 }
59 213 bool operator()(
60 std::shared_ptr<DirNode> const &n,
61 const std::string &name) const
62 {
63 213 return n->m_name < name;
64 }
65 };
66 typedef std::vector<std::shared_ptr<DirNode>> NodeVector;
67 NodeVector children;
68
69 // Value is set if a <listing> command returned a <dir> tag
70 bool directory;
71
72 std::shared_ptr<DirNode> getRootNode();
73 };
74
75 }}} // namespace PdCom::impl::MsrProto
76
77 #endif // PD_DIRNODE_H
78