X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senf%2FUtils%2FConsole%2FParsedCommand.hh;h=4df9d4185a94d38b5bba397a392a29b35ab5322f;hb=93d9568d448749dc187e7622b733a4a3caa319df;hp=6c443ba0cd75497f72aa5918d959babeb4732251;hpb=b8a2a9d30d2c0aa986c6c86f9cc9288ead67ebdb;p=senf.git diff --git a/senf/Utils/Console/ParsedCommand.hh b/senf/Utils/Console/ParsedCommand.hh index 6c443ba..4df9d41 100644 --- a/senf/Utils/Console/ParsedCommand.hh +++ b/senf/Utils/Console/ParsedCommand.hh @@ -44,7 +44,7 @@ #include "ParsedCommand.ih" #include "ParsedCommand.mpp" -///////////////////////////////hh.p//////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////////////////////////// namespace senf { namespace console { @@ -104,7 +104,7 @@ namespace console { description = "numeric id of task to check, -1 for the current task." default_value = -1 ) ); senf::console::root() - .add("taskStatus", fty::Commande(static_cast( + .add("taskStatus", fty::Command(static_cast( &taskStatus)) .overloadDoc("Query status by name") .arg( name = "name", @@ -177,10 +177,6 @@ namespace console { { public: typedef boost::intrusive_ptr ptr; - -#ifdef DOXYGEN - static ptr create(Function fn); -#endif }; #ifndef DOXYGEN @@ -210,8 +206,6 @@ namespace console { typedef OverloadedCommandNode node_type; typedef OverloadedCommandNode & result_type; - OverloadedCommandNode & create(DirectoryNode & dir, std::string const & name) const; - protected: ParsedCommandAttributorBase(ParsedCommandOverloadBase::ptr overload, unsigned index); ParsedCommandAttributorBase(ParsedCommandAttributorBase const & other, unsigned index); @@ -227,10 +221,14 @@ namespace console { void shortDoc(std::string const & doc); private: + OverloadedCommandNode & create(DirectoryNode & dir, std::string const & name) const; + ParsedCommandOverloadBase::ptr overload_; unsigned index_; boost::optional doc_; boost::optional shortdoc_; + + friend class senf::console::DirectoryNode; }; /** \brief Non argument dependent ParsedCommandBase attributes @@ -260,7 +258,7 @@ namespace console { /** \brief Keyword argument tags The tags defined in this namespace are used as keyword arguments via the Boost.Parameter + href="http://www.boost.org/doc/libs/release/libs/parameter/doc/html/index.html">Boost.Parameter library. For the keyword tags, the standard C++ scoping rules apply @@ -313,6 +311,8 @@ namespace console { \endhtmlonly \see \ref senf::console::ParsedArgumentAttributor::arg() + + \ingroup console_commands */ namespace kw { BOOST_PARAMETER_KEYWORD(type, name) ///< Argument name @@ -487,7 +487,7 @@ namespace console { /**< This member changes the attributes for the current argument. The attributes are passed to arg() as keyword arguments using the Boost.Parameter + href="http://www.boost.org/doc/libs/release/libs/parameter/doc/html/index.html">Boost.Parameter library. \code ... @@ -577,6 +577,67 @@ namespace console { namespace factory { +#ifdef DOXYGEN + + /** \brief OverloadedCommandNode factory + + This factory will create new OverloadedCommandNode instances or add new overloads + to an existing OverloadedCommandNode. The factory supports automatic argument parsing. + + Commands are added to the tree using + \code + namespace fty = senf::console::factory; + node.add("name", fty::Command(function)); + \endcode + + The Command factory supports the following features: + \li Automatic argument parsing + \li Automatic binding of member functions. Pass the owning instance as second argument to + the factory + \li Conversion to a compatible signature. Pass the signature as template argument to the + factory + + If the signature of the command added matches + \code + void (std::ostream &, senf::console::ParsedCommandInfo const &) + \endcode + The command is added using manual argument parsing, otherwise it is added using automatic + argument parsing. + + See the List of all + members for additional attributes. + + \note This class is for exposition only, the real interface consists of several overloaded + factory functions. + + \see \ref console_manualparse \n + \ref console_autoparse + */ + class Command : public ParsedArgumentAttributor + { + public: + typedef OverloadedCommandNode node_type; + typedef unspecified result_type; + + Command(unspecified fn); ///< Create a node calling \a fn + template + Command(unspecified fn); ///< Create a node calling \a fn with signature \a Signature + /**< The given \a Signature must be compatible with \a fn + for each argument and the return value. */ + + Command(member_function_pointer fn, Owner const * owner); + ///< Create a node calling member function \a fn on \a owner + template + Command(member_function_pointer fn, Owner const * owner); + ///< Create a node calling member function \a fn on \a owner + /// with the given \a Signature + /**< The given \a Signature must be compatible with \a fn + for each argument and the return value. */ + + }; + +#else + template SimpleOverloadAttributor Command(boost::function fn, @@ -639,10 +700,11 @@ namespace factory { Command(Member memfn, Owner const * owner, typename boost::enable_if >::type * = 0); +#endif }}} -///////////////////////////////hh.e//////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////////////////////////// #include "ParsedCommand.cci" #include "ParsedCommand.ct" #include "ParsedCommand.cti"