minor documentation fix
[senf.git] / Console / ObjectDirectory.hh
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 ObjectDirectory public header */
25
26 #ifndef HH_ObjectDirectory_
27 #define HH_ObjectDirectory_ 1
28
29 // Custom includes
30 #include <boost/utility.hpp>
31 #include <boost/type_traits/is_convertible.hpp>
32 #include "Node.hh"
33
34 //#include "ObjectDirectory.mpp"
35 ///////////////////////////////hh.p////////////////////////////////////////
36
37 namespace senf {
38 namespace console {
39
40     template <class Owner, class Object>
41     struct OwnerNodeCreateTraits
42     {
43         typedef BOOST_TYPEOF_TPL( senf_console_add_node( 
44                                       * static_cast<DirectoryNode *>(0),
45                                       * static_cast<Owner *>(0),
46                                       * static_cast<std::string const *>(0),
47                                       * static_cast<Object const *>(0)) ) result_type;
48
49         typedef typename boost::remove_reference<result_type>::type NodeType;
50
51         struct Creator {
52             static NodeType & create(DirectoryNode & node, Owner & owner, 
53                                      std::string const & name, Object const & ob);
54         };
55     };
56     
57     struct ObjectDirectoryBase {};
58
59     /** \brief
60       */
61     template <class Owner>
62     class ObjectDirectory : public ObjectDirectoryBase
63     {
64     public:
65         ///////////////////////////////////////////////////////////////////////////
66         // Types
67         
68         typedef Owner owner;
69
70         ///////////////////////////////////////////////////////////////////////////
71         ///\name Structors and default members
72         ///@{
73
74         ObjectDirectory(Owner * owner);
75         ~ObjectDirectory();
76
77         ///@}
78         ///////////////////////////////////////////////////////////////////////////
79
80         template <class Object>
81         typename OwnerNodeCreateTraits<Owner, Object>::NodeType & add(std::string const & name,
82                                                                       Object const & ob);
83
84         DirectoryNode & node() const;
85
86     protected:
87
88     private:
89         static SimpleCommandNode & create(DirectoryNode & node, Owner * owner, 
90                                           std::string const & name, 
91                                           SimpleCommandNode::Function const & fn);
92
93         DirectoryNode::ptr node_;
94         Owner * owner_;
95     };
96
97     template <class Owner, class Function>
98     SimpleCommandNode & senf_console_add_node(
99         DirectoryNode & node, Owner & owner, std::string const & name, Function const & fn);
100
101     template <class Owner>
102     SimpleCommandNode & senf_console_add_node(
103         DirectoryNode & node, Owner & owner, std::string const & name, 
104         void (Owner::*fn)(std::ostream & output, CommandNode::Arguments const & arguments));
105
106     template <class Node>
107     DirectoryNode & senf_console_add_node(
108         DirectoryNode & dir, std::string const & name, Node const & node, int, 
109         typename boost::enable_if< boost::is_convertible<Node*, ObjectDirectoryBase*> >::type * = 0);
110 }}
111
112 ///////////////////////////////hh.e////////////////////////////////////////
113 //#include "ObjectDirectory.cci"
114 //#include "ObjectDirectory.ct"
115 #include "ObjectDirectory.cti"
116 #endif
117
118 \f
119 // Local Variables:
120 // mode: c++
121 // fill-column: 100
122 // comment-column: 40
123 // c-file-style: "senf"
124 // indent-tabs-mode: nil
125 // ispell-local-dictionary: "american"
126 // compile-command: "scons -u test"
127 // End: