Utils/Console: Fix DirectoryNode::add(...) API
[senf.git] / senf / Utils / 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::ScopedDirectory<Owner>
36
37 template <class Owner>
38 prefix_ senf::console::ScopedDirectory<Owner>::ScopedDirectory(Owner * owner)
39     : owner_ (owner)
40 {
41     SENF_ASSERT(owner_);
42 }
43
44 template <class Owner>
45 template <class NodeType>
46 prefix_ NodeType & senf::console::ScopedDirectory<Owner>::add(std::string const & name,
47                                                               boost::shared_ptr<NodeType> othernode)
48 {
49     return node().add(name, othernode);
50 }
51
52 template <class Owner>
53 template <class NodeType>
54 prefix_ NodeType & senf::console::ScopedDirectory<Owner>::
55 add(std::string const & name, NodeType & othernode,
56     typename boost::enable_if< boost::is_convertible<NodeType &, GenericNode &> >::type *)
57 {
58     return node().add(name,othernode);
59 }
60
61 template <class Owner>
62 template <class Factory>
63 prefix_ typename Factory::result_type senf::console::ScopedDirectory<Owner>::
64 add(std::string const & name, Factory const & factory,
65     typename boost::enable_if< boost::is_convertible<Factory*, detail::OwnedNodeFactory*> >::type *)
66 {
67     return factory.create(*owner_, name, node());
68 }
69
70 template <class Owner>
71 template <class Factory>
72 prefix_ typename Factory::result_type senf::console::ScopedDirectory<Owner>::
73 add(std::string const & name, Factory const & factory,
74     typename boost::enable_if< boost::is_convertible<Factory*, detail::NodeFactory*> >::type *,
75     typename boost::disable_if< boost::is_convertible<Factory*, detail::OwnedNodeFactory*> >::type *)
76 {
77     return node().add(name, factory);
78 }
79
80 ///////////////////////////////////////////////////////////////////////////
81 // senf::console::ScopedDirectory<void>
82
83
84 template <class NodeType>
85 prefix_ NodeType & senf::console::ScopedDirectory<void>::add(std::string const & name,
86                                                              boost::shared_ptr<NodeType> othernode)
87 {
88     return node().add(name,othernode);
89 }
90
91 template <class NodeType>
92 prefix_ NodeType & senf::console::ScopedDirectory<void>::
93 add(std::string const & name, NodeType & othernode,
94     typename boost::enable_if< boost::is_convertible<NodeType &, GenericNode &> >::type *)
95 {
96     return node().add(name,othernode);
97 }
98
99 template <class Factory>
100 prefix_ typename Factory::result_type senf::console::ScopedDirectory<void>::
101 add(std::string const & name, Factory const & factory,
102     typename boost::enable_if< boost::is_convertible<Factory*, detail::NodeFactory*> >::type *)
103 {
104     return node().add(name,factory);
105 }
106
107 ///////////////////////////////cti.e///////////////////////////////////////
108 #undef prefix_
109
110 \f
111 // Local Variables:
112 // mode: c++
113 // fill-column: 100
114 // comment-column: 40
115 // c-file-style: "senf"
116 // indent-tabs-mode: nil
117 // ispell-local-dictionary: "american"
118 // compile-command: "scons -u test"
119 // End: