GCC Code Coverage Report


Directory: ./
File: pdserv/src/msrproto/DirectoryNode.h
Date: 2025-08-17 04:10:43
Exec Total Coverage
Lines: 2 2 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 /*****************************************************************************
2 *
3 * Copyright 2010 Richard Hacker (lerichi at gmx dot net)
4 *
5 * This file is part of the pdserv library.
6 *
7 * The pdserv 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
9 * by the Free Software Foundation, either version 3 of the License, or (at
10 * your option) any later version.
11 *
12 * The pdserv 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 pdserv library. If not, see <http://www.gnu.org/licenses/>.
19 *
20 ****************************************************************************/
21
22 #ifndef DIRECTORYNODE_H
23 #define DIRECTORYNODE_H
24
25 #include <string>
26 #include <queue>
27 #include <map>
28
29 namespace PdServ {
30 class Session;
31 }
32
33 namespace MsrProto {
34
35 class Variable;
36 class XmlElement;
37
38 class DirectoryNode {
39 public:
40 DirectoryNode(DirectoryNode* parent = 0,
41 const std::string& name = std::string());
42 virtual ~DirectoryNode();
43
44 void list(PdServ::Session *, XmlElement& parent,
45 const std::string& path, size_t pos, bool hex,
46 bool derived) const;
47 std::string path() const;
48
49 void dump() const;
50
51 // Method on a parent to insert a node
52 void insert(DirectoryNode* node, const std::string& path);
53
54 // Method on a parent to insert a node at a specific position
55 void pathInsert(Variable* node, const std::string& path);
56 void traditionalPathInsert(Variable* node,
57 const std::string& path,
58 char& hidden, char& persistent);
59
60 DirectoryNode* create(const std::string& name);
61
62 const DirectoryNode* find(const std::string&, size_t pos) const;
63
64 protected:
65
66 virtual bool hasChildren(const Variable* parent) const;
67
68 270 size_t childCount() const {
69 270 return children.size();
70 }
71
72 // Insert the last node as a leaf
73 virtual void insertLeaf(DirectoryNode* child);
74
75 // Method on parent to adopt a child
76 void adopt(DirectoryNode* child, const std::string& path);
77
78 // Method on a node to set the name and ancestory
79 void rename(const std::string* name, DirectoryNode* parent);
80
81
82 private:
83 DirectoryNode * parent;
84 const std::string* name;
85
86 typedef std::map<std::string, DirectoryNode*> ChildMap;
87 ChildMap children;
88
89 typedef std::queue<std::string> DirQ;
90 void insert(Variable* node, DirQ&);
91
92 bool isRoot() const;
93 static std::string split(const std::string& path, size_t& pos);
94 };
95
96 }
97
98 #endif // DIRECTORYNODE_H
99