ScopedDirectory.cti
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
14 /** \file
15  \brief ScopedDirectory inline template implementation */
16 
17 //#include "ScopedDirectory.ih"
18 
19 // Custom includes
20 
21 #define prefix_ inline
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
23 
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 // senf::console::ScopedDirectory<Owner>
26 
27 template <class Owner>
28 prefix_ senf::console::ScopedDirectory<Owner>::ScopedDirectory(Owner * owner)
29  : owner_ (owner)
30 {
31  SENF_ASSERT(owner_, "ScopedDirectory owner is mandatory");
32 }
33 
34 template <class Owner>
35 template <class NodeType>
36 prefix_ NodeType & senf::console::ScopedDirectory<Owner>::add(std::string const & name,
37  boost::shared_ptr<NodeType> othernode)
38 {
39  return node().add(name, othernode);
40 }
41 
42 template <class Owner>
43 template <class NodeType>
44 prefix_ NodeType & senf::console::ScopedDirectory<Owner>::
45 add(std::string const & name, NodeType & othernode,
46  typename boost::enable_if< boost::is_convertible<NodeType &, GenericNode &> >::type *)
47 {
48  return node().add(name,othernode);
49 }
50 
51 template <class Owner>
52 template <class Factory>
53 prefix_ typename Factory::result_type senf::console::ScopedDirectory<Owner>::
54 add(std::string const & name, Factory const & factory,
55  typename boost::enable_if< boost::is_convertible<Factory*, detail::OwnedNodeFactory*> >::type *)
56 {
57  return factory.create(*owner_, name, node());
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::NodeFactory*> >::type *,
65  typename boost::disable_if< boost::is_convertible<Factory*, detail::OwnedNodeFactory*> >::type *)
66 {
67  return node().add(name, factory);
68 }
69 
70 //-/////////////////////////////////////////////////////////////////////////////////////////////////
71 // senf::console::ScopedDirectory<void>
72 
73 
74 template <class NodeType>
75 prefix_ NodeType & senf::console::ScopedDirectory<void>::add(std::string const & name,
76  boost::shared_ptr<NodeType> othernode)
77 {
78  return node().add(name,othernode);
79 }
80 
81 template <class NodeType>
82 prefix_ NodeType & senf::console::ScopedDirectory<void>::
83 add(std::string const & name, NodeType & othernode,
84  typename boost::enable_if< boost::is_convertible<NodeType &, GenericNode &> >::type *)
85 {
86  return node().add(name,othernode);
87 }
88 
89 template <class Factory>
90 prefix_ typename Factory::result_type senf::console::ScopedDirectory<void>::
91 add(std::string const & name, Factory const & factory,
92  typename boost::enable_if< boost::is_convertible<Factory*, detail::NodeFactory*> >::type *)
93 {
94  return node().add(name,factory);
95 }
96 
97 //-/////////////////////////////////////////////////////////////////////////////////////////////////
98 #undef prefix_
99 
100 
101 // Local Variables:
102 // mode: c++
103 // fill-column: 100
104 // comment-column: 40
105 // c-file-style: "senf"
106 // indent-tabs-mode: nil
107 // ispell-local-dictionary: "american"
108 // compile-command: "scons -u test"
109 // End: