X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Console%2FScopedDirectory.hh;h=cd5b9b4e2856ece133615e3281736368005e6f7c;hb=456ee576285b76aa46240f8001f426757810dcc1;hp=6c27f40c691c5c4f4e12356db2dfb8fea0510e29;hpb=be33ff96c5b89738694da272d8610564cce48bfb;p=senf.git diff --git a/Console/ScopedDirectory.hh b/Console/ScopedDirectory.hh index 6c27f40..cd5b9b4 100644 --- a/Console/ScopedDirectory.hh +++ b/Console/ScopedDirectory.hh @@ -49,14 +49,17 @@ namespace console { * static_cast(0), * static_cast(0), * static_cast(0), - * static_cast(0)) ) result_type; + * static_cast(0), + * static_cast(0)) ) base_type; + typedef typename senf::remove_cvref::type value_type; - typedef typename boost::remove_reference::type NodeType; + typedef typename value_type::node_type NodeType; + typedef typename value_type::return_type result_type; /// Internal struct Creator { - static NodeType & create(DirectoryNode & node, Owner & owner, - std::string const & name, Object const & ob); + static result_type create(DirectoryNode & node, Owner & owner, + std::string const & name, Object & ob); }; }; @@ -72,6 +75,7 @@ namespace console { ///\{ GenericNode::ptr remove(std::string const & name); + bool hasChild(std::string const & name) const; DirectoryNode & getDirectory(std::string const & name) const; DirectoryNode & operator[](std::string const & name) const; CommandNode & getCommand(std::string const & name) const; @@ -144,8 +148,8 @@ namespace console { /////////////////////////////////////////////////////////////////////////// template - typename OwnerNodeCreateTraits::NodeType & add(std::string const & name, - Object const & ob); + typename OwnerNodeCreateTraits::result_type add(std::string const & name, + Object const & ob); ///< Create new child node /**< Adds a new child node to the (proxied) DirectoryNode. How the node is added is configured @@ -153,30 +157,41 @@ namespace console { implementation just forwards the call to the proxied directory node. */ + template + typename OwnerNodeCreateTraits::result_type add(std::string const & name, + Object & ob); + ///< Create new child node + /**< \see add() */ + protected: private: Owner * owner_; }; +#ifndef DOXYGEN + template <> class ScopedDirectory : public ScopedDirectoryBase { public: template - typename NodeCreateTraits::NodeType & add(std::string const & name, - Object const & ob); + typename NodeCreateTraits::result_type add(std::string const & name, + Object const & ob); + + template + typename NodeCreateTraits::result_type add(std::string const & name, + Object & ob); }; -#ifndef DOXYGEN template SimpleCommandNode & senf_console_add_node( - DirectoryNode & node, Owner & owner, std::string const & name, Function const & fn); + DirectoryNode & node, Owner & owner, std::string const & name, Function const & fn, ...); template SimpleCommandNode & senf_console_add_node( DirectoryNode & node, Owner & owner, std::string const & name, - void (Owner::*fn)(std::ostream &, ParseCommandInfo const &)); + void (Owner::*fn)(std::ostream &, ParseCommandInfo const &), int); template DirectoryNode & senf_console_add_node(