GCC Code Coverage Report


Directory: ./
File: pdserv-1.1.0/src/msrproto/DirectoryNode.h
Date: 2024-12-15 04:08:34
Exec Total Coverage
Lines: 0 2 0.0%
Branches: 0 0 -%

Line Branch Exec Source
1 /*****************************************************************************
2 *
3 * $Id$
4 *
5 * Copyright 2010 Richard Hacker (lerichi at gmx dot net)
6 *
7 * This file is part of the pdserv library.
8 *
9 * The pdserv library is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License as published
11 * by the Free Software Foundation, either version 3 of the License, or (at
12 * your option) any later version.
13 *
14 * The pdserv library is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17 * License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with the pdserv library. If not, see <http://www.gnu.org/licenses/>.
21 *
22 *****************************************************************************/
23
24 #ifndef DIRECTORYNODE_H
25 #define DIRECTORYNODE_H
26
27 #include <string>
28 #include <queue>
29 #include <map>
30
31 namespace PdServ {
32 class Variable;
33 class Session;
34 }
35
36 namespace MsrProto {
37
38 class Variable;
39 class XmlElement;
40
41 class DirectoryNode {
42 public:
43 DirectoryNode(DirectoryNode* parent = 0,
44 const std::string& name = std::string());
45 virtual ~DirectoryNode();
46
47 void list(PdServ::Session *, XmlElement& parent,
48 const std::string& path, size_t pos = 0) const;
49 std::string path() const;
50
51 void dump() const;
52
53 // Method on a parent to insert a node
54 void insert(DirectoryNode* node, const std::string& path);
55
56 // Method on a parent to insert a node at a specific position
57 void pathInsert(Variable* node, const std::string& path);
58 void traditionalPathInsert(Variable* node,
59 const std::string& path, char& hidden);
60
61 DirectoryNode* create(const std::string& name);
62
63 const DirectoryNode* find(const std::string&, size_t pos) const;
64
65 protected:
66
67 size_t childCount() const {
68 return children.size();
69 }
70
71 // Insert the last node as a leaf
72 virtual void insertLeaf(DirectoryNode* child);
73
74 // Method on parent to adopt a child
75 void adopt(DirectoryNode* child, const std::string& path);
76
77 // Method on a node to set the name and ancestory
78 void rename(const std::string* name, DirectoryNode* parent);
79
80
81 private:
82 DirectoryNode * parent;
83 const std::string* name;
84
85 typedef std::map<std::string, DirectoryNode*> ChildMap;
86 ChildMap children;
87
88 typedef std::queue<std::string> DirQ;
89 void insert(Variable* node, DirQ&);
90
91 void erase();
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