4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief Node public header */
31 #include <boost/intrusive_ptr.hpp>
32 #include <boost/utility.hpp>
33 #include "../Utils/intrusive_refcount.hh"
34 #include "../Utils/Exception.hh"
37 ///////////////////////////////hh.p////////////////////////////////////////
48 : public intrusive_refcount_t<GenericNode>
51 ///////////////////////////////////////////////////////////////////////////
54 typedef boost::intrusive_ptr<GenericNode> ptr;
56 ///////////////////////////////////////////////////////////////////////////
58 std::string const & name() const;
59 DirectoryNode & parent() const;
63 explicit GenericNode(std::string const & name, bool managed = false);
65 void name(std::string const & name);
66 static void name(GenericNode & node, std::string const & name);
67 void parent(DirectoryNode * parent);
74 DirectoryNode * parent_;
76 friend class intrusive_refcount_base;
81 class DirectoryNode : public GenericNode
84 typedef boost::intrusive_ptr<DirectoryNode> ptr;
86 void add(std::auto_ptr<GenericNode> node, bool uniquify = true);
87 void add(GenericNode & node, bool uniquify = true);
89 DirectoryNode & operator[](std::string const & name) const;
90 CommandNode & operator()(std::string const & name) const;
93 explicit DirectoryNode(std::string const & name, bool managed = false);
96 void add(GenericNode::ptr node, bool uniquify);
97 GenericNode & lookup(std::string const & name) const;
99 typedef std::map<std::string, GenericNode::ptr> ChildMap;
103 struct DuplicateNodeNameException : public senf::Exception
104 { DuplicateNodeNameException() : senf::Exception("Duplicate node name") {}};
106 struct UnknownNodeNameException : public senf::Exception
107 { UnknownNodeNameException() : senf::Exception("Unknown node name") {}};
111 class CommandNode : public GenericNode
114 typedef boost::intrusive_ptr<CommandNode> ptr;
117 explicit CommandNode(std::string const & name, bool managed = false);
125 ///////////////////////////////hh.e////////////////////////////////////////
128 //#include "Node.cti"
135 // comment-column: 40
136 // c-file-style: "senf"
137 // indent-tabs-mode: nil
138 // ispell-local-dictionary: "american"
139 // compile-command: "scons -u test"