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