X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FConsole%2FNode.hh;h=4cd15d1031874e7459164930372fb476a147d8c1;hb=1d95912e59f822e19e4972727fa2fa6db6b2bf63;hp=6caef96215d5a9c40b1f3e9e39978b532fcbe2df;hpb=79e54eda6a7fb5ac3fa5b37f408dd386454c5bbd;p=senf.git diff --git a/Utils/Console/Node.hh b/Utils/Console/Node.hh index 6caef96..4cd15d1 100644 --- a/Utils/Console/Node.hh +++ b/Utils/Console/Node.hh @@ -206,6 +206,7 @@ #include #include #include +#include #include "../../Utils/Exception.hh" #include "../../Utils/mpl.hh" #include "../../Utils/Logger/SenfLog.hh" @@ -223,6 +224,7 @@ namespace console { class CommandNode; DirectoryNode & root(); + void dump(std::ostream & os, DirectoryNode & dir=root()); /** \brief Config/console node tree base-class @@ -277,7 +279,8 @@ namespace console { bool active() const; ///< \c true, if node is attached to the root() node - void help(std::ostream & output) const; /// Write help info to \a output + void help(std::ostream & output) const; ///< Write help info to \a output + std::string shorthelp() const; ///< Get short (one-line) documentation ptr thisptr(); ///< Get smart pointer to node cptr thisptr() const; ///< Get smart pointer to node (const) @@ -311,8 +314,12 @@ namespace console { #endif virtual void v_help(std::ostream & output) const = 0; ///< Provide help information - /**< This member must be implemented in derived classes - to provide node specific help information. */ + /**< This member must be implemented in derived classes to + provide node specific help information. */ + virtual std::string v_shorthelp() const = 0; + ///< Provide short documentation + /**< This member must be implemented in derived classes to + provide node specific documentation. */ private: std::string name_; @@ -358,6 +365,7 @@ namespace console { explicit LinkNode(GenericNode & node); virtual void v_help(std::ostream &) const; + virtual std::string v_shorthelp() const; GenericNode::ptr node_; }; @@ -435,6 +443,7 @@ namespace console { static ptr create(); ///< Create node object. /**< You should normally use either mkdir() or ScopedDirectory instead of create() */ + ~DirectoryNode(); ///\} /////////////////////////////////////////////////////////////////////////// @@ -536,6 +545,8 @@ namespace console { DirectoryNode & mkdir(std::string const & name); ///< Create sub-directory node + DirectoryNode & provideDirectory(std::string const & name); + ///< Return subdirectory, possibly creating it ChildrenRange children() const; ///< Return iterator range over all children. /**< The returned range is sorted by child name. */ @@ -552,6 +563,7 @@ namespace console { /////////////////////////////////////////////////////////////////////////// DirectoryNode & doc(std::string const & doc); ///< Set node documentation + DirectoryNode & shortdoc(std::string const & doc); ///< Set node short documentation ptr thisptr(); cptr thisptr() const; @@ -562,9 +574,11 @@ namespace console { private: void add(GenericNode::ptr node); virtual void v_help(std::ostream & output) const; + virtual std::string v_shorthelp() const; ChildMap children_; std::string doc_; + std::string shortdoc_; friend DirectoryNode & root(); }; @@ -606,7 +620,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 @@ -619,6 +641,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; @@ -629,10 +653,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. */ @@ -680,17 +704,21 @@ namespace console { cptr thisptr() const; SimpleCommandNode & doc(std::string const & doc); + SimpleCommandNode & shortdoc(std::string const & doc); protected: SimpleCommandNode(Function const & fn); private: virtual void v_help(std::ostream & output) const; - virtual void v_execute(std::ostream & output, ParseCommandInfo const & command) const; + virtual std::string v_shorthelp() const; + virtual void v_execute(boost::any & rv, std::ostream & os, ParseCommandInfo const & command) + const; Function fn_; std::string doc_; + std::string shortdoc_; }; #ifndef DOXYGEN @@ -698,6 +726,9 @@ namespace console { SimpleCommandNode & senf_console_add_node(DirectoryNode & node, std::string const & name, SimpleCommandNode::Function fn, int); + DirectoryNode & senf_console_add_node(DirectoryNode & node, std::string const & name, + DirectoryNode & dir, int); + #endif }}