some unimportant clean-ups ;)
[senf.git] / Utils / Console / Node.hh
index 137c8b0..fcd44d0 100644 (file)
 #include <boost/range/iterator_range.hpp>
 #include <boost/typeof/typeof.hpp>
 #include <boost/type_traits/remove_reference.hpp>
+#include <boost/any.hpp>
 #include "../../Utils/Exception.hh"
 #include "../../Utils/mpl.hh"
 #include "../../Utils/Logger/SenfLog.hh"
@@ -296,6 +297,9 @@ namespace console {
         bool isLink() const;            ///< \c true, if this is a link node
         bool isCommand() const;         ///< \c true, if this is a command node
 
+        GenericNode const & followLink() const; ///< Follow link if \c this node is a link node
+        GenericNode & followLink();     ///< Follow link if \c this node is a link node
+
     protected:
         GenericNode();
 
@@ -432,6 +436,7 @@ namespace console {
         static ptr create();            ///< Create node object.
                                         /**< You should normally use either mkdir() or
                                              ScopedDirectory instead of create() */
+        ~DirectoryNode();
 
         ///\}
         ///////////////////////////////////////////////////////////////////////////
@@ -491,7 +496,7 @@ namespace console {
                                         ///< \c true, if there is a child with name \a name
 
         GenericNode & get(std::string const & name) const;
-                                        ///< Get child node
+                                        ///< Get child node automatically dereferencing links
                                         /**< \throws UnknownNodeNameException if a child \a name
                                                  does not exist */
         GenericNode & getLink(std::string const & name) const;
@@ -500,7 +505,7 @@ namespace console {
                                                  does not exist */
 
         DirectoryNode & getDirectory(std::string const & name) const;
-                                        ///< Get directory child node
+                                        ///< Get directory child node (dereferencing links)
                                         /**< Same as operator[]
                                              \throws UnknownNodeNameException if a child \a name
                                                  does not exist.
@@ -508,7 +513,7 @@ namespace console {
                                                  directory node. */
 
         DirectoryNode & operator[](std::string const & name) const;
-                                        ///< Get directory child node
+                                        ///< Get directory child node (dereferencing links)
                                         /**< Same as getDirectory
                                              \throws UnknownNodeNameException if a child \a name
                                                  does not exist.
@@ -516,7 +521,7 @@ namespace console {
                                                  directory node. */
 
         CommandNode & getCommand(std::string const & name) const;
-                                        ///< Get command child node
+                                        ///< Get command child node (dereferencing links)
                                         /**< Same as operator()
                                              \throws UnknownNodeNameException if a child \a name
                                                  does not exist
@@ -524,7 +529,7 @@ namespace console {
                                                  command node. */
 
         CommandNode & operator()(std::string const & name) const;
-                                        ///< Get command child node
+                                        ///< Get command child node (dereferencing links)
                                         /**< Same as getCommand()
                                              \throws UnknownNodeNameException if a child \a name
                                                  does not exist
@@ -603,7 +608,15 @@ namespace console {
 
         void execute(std::ostream & output, ParseCommandInfo const & command) const;
                                         ///< Execute the command
-                                        /**< Same as operator()()
+                                        /**< \param[in] output stream where result messages may be
+                                                 written to
+                                             \param[in] arguments command arguments. This is a
+                                                 range of ranges of Token instances. */
+
+        void execute(boost::any & rv, std::ostream & output, ParseCommandInfo const & command) 
+            const;
+                                        ///< Execute the command
+                                        /**< \param[out] rv command return value
                                              \param[in] output stream where result messages may be
                                                  written to
                                              \param[in] arguments command arguments. This is a
@@ -616,6 +629,8 @@ namespace console {
                                                  written to
                                              \param[in] arguments command arguments. This is a
                                                  range of ranges of Token instances. */
+        void operator()(boost::any & rv, std::ostream & output, ParseCommandInfo const & command)
+            const;
 
         ptr thisptr();
         cptr thisptr() const;
@@ -626,10 +641,10 @@ namespace console {
 #ifndef DOXYGEN
     private:
 #endif
-        virtual void v_execute(std::ostream & output, ParseCommandInfo const & command) const = 0;
+        virtual void v_execute(boost::any & rv, std::ostream & os, ParseCommandInfo const & command)
+            const = 0;
                                         ///< Called to execute the command
-                                        /**< \param[in] output stream where result messages may be
-                                                 written to
+                                        /**< \param[out] rv return value holder
                                              \param[in] arguments command arguments. This is a
                                                  range of ranges of Token instances. */
 
@@ -683,7 +698,8 @@ namespace console {
 
     private:
         virtual void v_help(std::ostream & output) const;
-        virtual void v_execute(std::ostream & output, ParseCommandInfo const & command) const;
+        virtual void v_execute(boost::any & rv, std::ostream & os, ParseCommandInfo const & command)
+            const;
 
 
         Function fn_;