4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
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.
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.
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.
24 \brief ObjectDirectory public header */
26 #ifndef HH_ObjectDirectory_
27 #define HH_ObjectDirectory_ 1
30 #include <boost/utility.hpp>
31 #include <boost/type_traits/is_convertible.hpp>
34 //#include "ObjectDirectory.mpp"
35 ///////////////////////////////hh.p////////////////////////////////////////
40 template <class Owner, class Object>
41 struct OwnerNodeCreateTraits
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;
49 typedef typename boost::remove_reference<result_type>::type NodeType;
52 static NodeType & create(DirectoryNode & node, Owner & owner,
53 std::string const & name, Object const & ob);
57 struct ObjectDirectoryBase {};
61 template <class Owner>
62 class ObjectDirectory : public ObjectDirectoryBase
65 ///////////////////////////////////////////////////////////////////////////
70 ///////////////////////////////////////////////////////////////////////////
71 ///\name Structors and default members
74 ObjectDirectory(Owner * owner);
78 ///////////////////////////////////////////////////////////////////////////
80 template <class Object>
81 typename OwnerNodeCreateTraits<Owner, Object>::NodeType & add(std::string const & name,
84 DirectoryNode & node() const;
89 static SimpleCommandNode & create(DirectoryNode & node, Owner * owner,
90 std::string const & name,
91 SimpleCommandNode::Function const & fn);
93 DirectoryNode::ptr node_;
97 template <class Owner, class Function>
98 SimpleCommandNode & senf_console_add_node(
99 DirectoryNode & node, Owner & owner, std::string const & name, Function const & fn);
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));
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);
112 ///////////////////////////////hh.e////////////////////////////////////////
113 //#include "ObjectDirectory.cci"
114 //#include "ObjectDirectory.ct"
115 #include "ObjectDirectory.cti"
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"