Node.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 Node inline template implementation */
16 
17 // Custom includes
18 
19 #define prefix_ inline
20 //-/////////////////////////////////////////////////////////////////////////////////////////////////
21 
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
23 // senf::console::DirectoryNode
24 
25 template <class NodeType>
26 prefix_ NodeType & senf::console::DirectoryNode::add(std::string const & name,
27  boost::shared_ptr<NodeType> node)
28 {
29  SENF_ASSERT( ! node->parent(), "Node can only be added to tree once" );
30  node->name(name);
31  add(node);
32  return *node;
33 }
34 
35 template <class NodeType>
36 prefix_ NodeType & senf::console::DirectoryNode::
37 add(std::string const & name, NodeType & node,
38  typename boost::enable_if< boost::is_convertible<NodeType &, GenericNode &> >::type *)
39 {
40  // This makes objects with implicit conversion operators work (hi, ScopedDirectory ..)
41  add(name, static_cast<GenericNode &>(node).thisptr());
42  return node;
43 }
44 
45 template <class Factory>
46 prefix_ typename Factory::result_type senf::console::DirectoryNode::
47 add(std::string const & name, Factory const & factory,
48  typename boost::enable_if< boost::is_convertible<Factory const &, detail::NodeFactory const &> >::type *)
49 {
50  return factory.create(*this, name);
51 }
52 
53 //-/////////////////////////////////////////////////////////////////////////////////////////////////
54 #undef prefix_
55 
56 
57 // Local Variables:
58 // mode: c++
59 // fill-column: 100
60 // comment-column: 40
61 // c-file-style: "senf"
62 // indent-tabs-mode: nil
63 // ispell-local-dictionary: "american"
64 // compile-command: "scons -u test"
65 // End: