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 inline non-template implementation */
29 #include "../Utils/senfassert.hh"
31 #define prefix_ inline
32 ///////////////////////////////cci.p///////////////////////////////////////
34 ///////////////////////////////////////////////////////////////////////////
35 // senf::console::GenericNode
37 prefix_ senf::console::GenericNode::~GenericNode()
40 prefix_ std::string const & senf::console::GenericNode::name()
46 prefix_ senf::console::GenericNode::GenericNode()
50 prefix_ void senf::console::GenericNode::name(std::string const & name)
55 prefix_ void senf::console::GenericNode::name(GenericNode & node, std::string const & name)
60 prefix_ boost::shared_ptr<senf::console::DirectoryNode> senf::console::GenericNode::parent()
63 return boost::static_pointer_cast<DirectoryNode>(
64 parent_ ? parent_->shared_from_this() : ptr() );
67 prefix_ senf::console::GenericNode::ptr senf::console::GenericNode::unlink()
69 SENF_ASSERT( parent() );
70 return parent()->remove(name());
73 prefix_ void senf::console::GenericNode::help(std::ostream & output)
79 prefix_ senf::console::GenericNode::ptr senf::console::GenericNode::thisptr()
81 return shared_from_this();
84 prefix_ senf::console::GenericNode::cptr senf::console::GenericNode::thisptr()
87 return shared_from_this();
90 ///////////////////////////////////////////////////////////////////////////
91 // senf::console::DirectoryNode
93 prefix_ std::auto_ptr<senf::console::DirectoryNode>
94 senf::console::DirectoryNode::create()
96 return std::auto_ptr<DirectoryNode>(new DirectoryNode());
99 prefix_ senf::console::DirectoryNode &
100 senf::console::DirectoryNode::operator[](std::string const & name)
103 return dynamic_cast<DirectoryNode&>(get(name));
106 prefix_ senf::console::CommandNode &
107 senf::console::DirectoryNode::operator()(std::string const & name)
110 return dynamic_cast<CommandNode&>(get(name));
113 prefix_ senf::console::DirectoryNode &
114 senf::console::DirectoryNode::mkdir(std::string const & name)
116 std::auto_ptr<DirectoryNode> node (create());
117 return add(name, node);
120 prefix_ senf::console::DirectoryNode::ChildrenRange senf::console::DirectoryNode::children()
123 return boost::make_iterator_range(children_.begin(), children_.end());
126 prefix_ senf::console::DirectoryNode::DirectoryNode()
129 prefix_ senf::console::DirectoryNode &
130 senf::console::DirectoryNode::doc(std::string const & doc)
136 prefix_ senf::console::DirectoryNode::ptr senf::console::DirectoryNode::thisptr()
138 return boost::static_pointer_cast<DirectoryNode>(shared_from_this());
141 prefix_ senf::console::DirectoryNode::cptr senf::console::DirectoryNode::thisptr()
144 return boost::static_pointer_cast<DirectoryNode const>(shared_from_this());
147 ///////////////////////////////////////////////////////////////////////////
148 // senf::console::CommandNode
150 prefix_ senf::console::CommandNode::ptr senf::console::CommandNode::thisptr()
152 return boost::static_pointer_cast<CommandNode>(shared_from_this());
155 prefix_ senf::console::CommandNode::cptr senf::console::CommandNode::thisptr()
158 return boost::static_pointer_cast<CommandNode const>(shared_from_this());
161 prefix_ senf::console::CommandNode::CommandNode()
164 ///////////////////////////////////////////////////////////////////////////
165 // senf::console::SimpleCommandNode
167 prefix_ void senf::console::SimpleCommandNode::operator()(std::ostream & output,
168 Arguments const & arguments)
170 fn_(output, arguments);
173 prefix_ senf::console::SimpleCommandNode::SimpleCommandNode(Function const & fn)
177 prefix_ std::auto_ptr<senf::console::SimpleCommandNode>
178 senf::console::SimpleCommandNode::create(Function const & fn)
180 return std::auto_ptr<SimpleCommandNode>(new SimpleCommandNode(fn));
183 prefix_ senf::console::SimpleCommandNode &
184 senf::console::SimpleCommandNode::doc(std::string const & doc)
190 ///////////////////////////////cci.e///////////////////////////////////////
197 // comment-column: 40
198 // c-file-style: "senf"
199 // indent-tabs-mode: nil
200 // ispell-local-dictionary: "american"
201 // compile-command: "scons -u test"