Socket/Protocols/INet: Fix INet6Address in6_addr constructor
[senf.git] / Console / ObjectDirectory.cti
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 ObjectDirectory inline template implementation */
25
26 //#include "ObjectDirectory.ih"
27
28 // Custom includes
29 #include <boost/bind.hpp>
30
31 #define prefix_ inline
32 ///////////////////////////////cti.p///////////////////////////////////////
33
34 ///////////////////////////////////////////////////////////////////////////
35 // senf::console::OwnerNodeCreateTraits<Owner,Object>::Creator
36
37 template <class Owner, class Object>
38 prefix_ typename senf::console::OwnerNodeCreateTraits<Owner,Object>::NodeType &
39 senf::console::OwnerNodeCreateTraits<Owner,Object>::Creator::create(DirectoryNode & node,
40                                                                     Owner & owner,
41                                                                     std::string const & name,
42                                                                     Object const & ob)
43 {
44     return senf_console_add_node(node, owner, name, ob);
45 }
46
47 ///////////////////////////////////////////////////////////////////////////
48 // senf::console::ObjectDirectory<Owner>
49
50 template <class Owner>
51 prefix_ senf::console::ObjectDirectory<Owner>::ObjectDirectory(Owner * owner)
52     : node_ (DirectoryNode::create()), owner_ (owner)
53 {}
54
55 template <class Owner>
56 prefix_ senf::console::ObjectDirectory<Owner>::~ObjectDirectory()
57 {
58     node_->unlink();
59 }
60
61 template <class Owner>
62 template <class Object>
63 prefix_ typename senf::console::OwnerNodeCreateTraits<Owner, Object>::NodeType &
64 senf::console::ObjectDirectory<Owner>::add(std::string const & name, Object const & ob)
65 {
66     return OwnerNodeCreateTraits<Owner, Object>::Creator::create(*node_, *owner_, name, ob);
67 }
68
69 template <class Owner>
70 prefix_ senf::console::GenericNode::ptr
71 senf::console::ObjectDirectory<Owner>::remove(std::string const & name)
72 {
73    return node().remove(name);
74 }
75
76 template <class Owner>
77 prefix_ senf::console::DirectoryNode &
78 senf::console::ObjectDirectory<Owner>::operator[](std::string const & name)
79     const
80 {
81     return node()[name];
82 }
83
84 template <class Owner>
85 prefix_ senf::console::CommandNode &
86 senf::console::ObjectDirectory<Owner>::operator()(std::string const & name)
87     const
88 {
89     return node()(name);
90 }
91
92 template <class Owner>
93 prefix_ senf::console::GenericNode &
94 senf::console::ObjectDirectory<Owner>::get(std::string const & name)
95     const
96 {
97     return node().get(name);
98 }
99
100 template <class Owner>
101 prefix_ senf::console::DirectoryNode &
102 senf::console::ObjectDirectory<Owner>::mkdir(std::string const & name)
103 {
104     return node().mkdir(name);
105 }
106
107 template <class Owner>
108 prefix_ senf::console::DirectoryNode::ChildrenRange
109 senf::console::ObjectDirectory<Owner>::children()
110     const
111 {
112     return node().children();
113 }
114
115 template <class Owner>
116 prefix_ senf::console::DirectoryNode &
117 senf::console::ObjectDirectory<Owner>::doc(std::string const & doc)
118 {
119     return node.doc(doc);
120 }
121
122 template <class Owner>
123 prefix_ senf::console::DirectoryNode & senf::console::ObjectDirectory<Owner>::node()
124     const
125 {
126     return *node_;
127 }
128
129 template <class Owner, class Function>
130 prefix_ senf::console::SimpleCommandNode & senf::console::
131 senf_console_add_node(DirectoryNode & node, Owner & , std::string const & name,
132                       Function const & fn)
133 {
134     return node.add(name,fn);
135 }
136
137 template <class Owner>
138 prefix_ senf::console::SimpleCommandNode & senf::console::
139 senf_console_add_node(DirectoryNode & node, Owner & owner, std::string const & name,
140                       void (Owner::*fn)(std::ostream & output, 
141                                         CommandNode::Arguments const & arguments))
142 {
143     return node.add(name, boost::bind(fn,boost::ref(owner),_1,_2));
144 }
145
146 template <class Node>
147 prefix_ senf::console::DirectoryNode & senf::console::
148 senf_console_add_node(DirectoryNode & dir, std::string const & name, Node const & node, int,
149                       typename boost::enable_if< boost::is_convertible<Node*, ObjectDirectoryBase*> >::type *)
150 {
151     return dir.add(name, node.node().thisptr());
152 }
153
154 ///////////////////////////////cti.e///////////////////////////////////////
155 #undef prefix_
156
157 \f
158 // Local Variables:
159 // mode: c++
160 // fill-column: 100
161 // comment-column: 40
162 // c-file-style: "senf"
163 // indent-tabs-mode: nil
164 // ispell-local-dictionary: "american"
165 // compile-command: "scons -u test"
166 // End: