Console: Added Module
[senf.git] / Console / Node.cci
1 // $Id$
2 //
3 // Copyright (C) 2008 
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Stefan Bund <g0dil@berlios.de>
7 //
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.
12 //
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.
17 //
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.
22
23 /** \file
24     \brief Node inline non-template implementation */
25
26 //#include "Node.ih"
27
28 // Custom includes
29 #include "../Utils/senfassert.hh"
30
31 #define prefix_ inline
32 ///////////////////////////////cci.p///////////////////////////////////////
33
34 ///////////////////////////////////////////////////////////////////////////
35 // senf::console::GenericNode
36
37 prefix_ std::string const & senf::console::GenericNode::name()
38     const
39 {
40     return name_;
41 }
42
43 prefix_ senf::console::GenericNode::GenericNode(std::string const & name, bool managed)
44     : name_ (name), managed_ (managed)
45 {}
46
47 prefix_ void senf::console::GenericNode::name(std::string const & name)
48 {
49     name_ = name;
50 }
51
52 prefix_ void senf::console::GenericNode::name(GenericNode & node, std::string const & name)
53 {
54     node.name_ = name;
55 }
56
57 prefix_ senf::console::DirectoryNode & senf::console::GenericNode::parent()
58     const
59 {
60     SENF_ASSERT( parent_ );
61     return *parent_;
62 }
63
64 prefix_ bool senf::console::GenericNode::managed()
65     const
66 {
67     return managed_;
68 }
69
70 prefix_ bool senf::console::GenericNode::release()
71 {
72     // Beware ! call release() first so the call is not short-circuited way !
73     return intrusive_refcount_base::release() && managed_;
74 }
75
76 ///////////////////////////////////////////////////////////////////////////
77 // senf::console::DirectoryNode
78
79 prefix_ void senf::console::DirectoryNode::add(std::auto_ptr<GenericNode> node, bool uniquify)
80 {
81     SENF_ASSERT( node->managed() );
82     add(GenericNode::ptr(node.release()), uniquify);
83 }
84
85 prefix_ void senf::console::DirectoryNode::add(GenericNode & node, bool uniquify)
86 {
87     SENF_ASSERT( ! node.managed() );
88     add(GenericNode::ptr(&node),uniquify);
89 }
90
91 prefix_ senf::console::DirectoryNode &
92 senf::console::DirectoryNode::operator[](std::string const & name)
93     const
94 {
95     return dynamic_cast<DirectoryNode&>(lookup(name));
96 }
97
98 prefix_ senf::console::CommandNode &
99 senf::console::DirectoryNode::operator()(std::string const & name)
100     const
101 {
102     return dynamic_cast<CommandNode&>(lookup(name));
103 }
104
105 prefix_ senf::console::DirectoryNode::DirectoryNode(std::string const & name, bool managed)
106     : GenericNode(name, managed)
107 {}
108
109 ///////////////////////////////////////////////////////////////////////////
110 // senf::console::CommandNode
111
112 prefix_ senf::console::CommandNode::CommandNode(std::string const & name, bool managed)
113     : GenericNode(name, managed)
114 {}
115
116 ///////////////////////////////cci.e///////////////////////////////////////
117 #undef prefix_
118
119 \f
120 // Local Variables:
121 // mode: c++
122 // fill-column: 100
123 // comment-column: 40
124 // c-file-style: "senf"
125 // indent-tabs-mode: nil
126 // ispell-local-dictionary: "american"
127 // compile-command: "scons -u test"
128 // End: