replaced some tabs with spaces
[senf.git] / Scheduler / Console / ScopedDirectory.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 ScopedDirectory inline template implementation */
25
26 //#include "ScopedDirectory.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>::result_type
39 senf::console::OwnerNodeCreateTraits<Owner,Object>::Creator::create(DirectoryNode & node,
40                                                                     Owner & owner,
41                                                                     std::string const & name,
42                                                                     Object & ob)
43 {
44     return senf_console_add_node(node, owner, name, ob, 0);
45 }
46
47 ///////////////////////////////////////////////////////////////////////////
48 // senf::console::ScopedDirectory<Owner>
49
50 template <class Owner>
51 prefix_ senf::console::ScopedDirectory<Owner>::ScopedDirectory(Owner * owner)
52     : owner_ (owner)
53 {
54     SENF_ASSERT(owner_);
55 }
56
57 template <class Owner>
58 template <class Object>
59 prefix_ typename senf::console::OwnerNodeCreateTraits<Owner, Object>::result_type
60 senf::console::ScopedDirectory<Owner>::add(std::string const & name, Object const & ob)
61 {
62     return OwnerNodeCreateTraits<Owner, Object const>::Creator::create(node(), *owner_, name, ob);
63 }
64
65 template <class Owner>
66 template <class Object>
67 prefix_ typename senf::console::OwnerNodeCreateTraits<Owner, Object>::result_type
68 senf::console::ScopedDirectory<Owner>::add(std::string const & name, Object & ob)
69 {
70     return OwnerNodeCreateTraits<Owner, Object>::Creator::create(node(), *owner_, name, ob);
71 }
72
73 #ifndef DOXYGEN
74
75 template <class Owner, class Function>
76 prefix_ senf::console::SimpleCommandNode & senf::console::
77 senf_console_add_node(DirectoryNode & node, Owner & , std::string const & name,
78                       SimpleCommandNode::Function fn, int)
79 {
80     return node.add(name,fn);
81 }
82
83 template <class Owner>
84 prefix_ senf::console::SimpleCommandNode & senf::console::
85 senf_console_add_node(DirectoryNode & node, Owner & owner, std::string const & name,
86                       void (Owner::*fn)(std::ostream &, ParseCommandInfo const &), int)
87 {
88     return node.add(name, boost::bind(fn,boost::ref(owner),_1,_2));
89 }
90
91 template <class Node>
92 prefix_ senf::console::DirectoryNode & senf::console::
93 senf_console_add_node(DirectoryNode & dir, std::string const & name, Node const & node, int,
94                       typename boost::enable_if< boost::is_convertible<Node*, ScopedDirectoryBase*> >::type *)
95 {
96     return dir.add(name, node.node().thisptr());
97 }
98
99 #endif
100
101 ///////////////////////////////////////////////////////////////////////////
102 // senf::console::ScopedDirectory<void>
103
104 template <class Object>
105 prefix_ typename senf::console::NodeCreateTraits<Object>::result_type
106 senf::console::ScopedDirectory<void>::add(std::string const & name, Object const & ob)
107 {
108     return node().add(name, ob);
109 }
110
111 template <class Object>
112 prefix_ typename senf::console::NodeCreateTraits<Object>::result_type
113 senf::console::ScopedDirectory<void>::add(std::string const & name, Object & ob)
114 {
115     return node().add(name, ob);
116 }
117
118 ///////////////////////////////cti.e///////////////////////////////////////
119 #undef prefix_
120
121 \f
122 // Local Variables:
123 // mode: c++
124 // fill-column: 100
125 // comment-column: 40
126 // c-file-style: "senf"
127 // indent-tabs-mode: nil
128 // ispell-local-dictionary: "american"
129 // compile-command: "scons -u test"
130 // End: