dequeue a packet from the packet queue. If the
connector is active, the connector will request new
packets from the connected module. If the packet
- request cannot be fulfilled, this is considered to be a
- logic error in the module implementation and an
- exception is raised. */
+ request cannot be fulfilled an in-valid Packet is
+ returned. */
Packet read(); ///< Alias for operator()()
DirectoryNode & provideDirectory(DirectoryNode & dir, std::string const & name);
-#ifndef DOXYGEN
+/** \brief Console node factories
+
+ The senf::console::factory namespace (customarily aliased to \c fty in user code) contains
+ factories used to create new node types:
+ \code
+ namespace fty = senf::console::factory;
+
+ senf::console::DirectoryNode & dir (node.add("dirname", fty::Directory()));
+
+ dir.add("name", fty::Command<void(bool)>(&fn)
+ .arg("flag")
+ .doc("documentation"));
+ \endcode
+ The node is added by passing the factory instance to senf::console::DirectoryNode::add().
+
+ To further customize the node, you may call attributor members on the temporary factory class
+ instance. Since the attributor members always return a self-reference to the factory class
+ instance, attributor calls may be chained arbitrarily.
+
+ \see
+ \ref console_commands for details on the command nodes \n
+ \ref node_tree for details on the structural nodes (directory, link)
+
+ \note All factories are documented here as classes when in fact some are functions returning
+ internal classes.
+
+ \implementation It is not true, that all attributor members return a self reference. Some
+ attributor members will return a new object of slightly different type. However, the
+ behavior is as documented above.
+
+ \ingroup console_commands
+ */
namespace factory {
+ /** \brief SimpleCommandNode factory
+
+ This factory will create a SimpleCommandNode calling the given callback. A SimpleCommandNode
+ does not support overloading or automatic argument parsing.
+
+ \attention This class is of interest mostly for testing and as a simple CommandNode
+ example. Use senf::console::factory::Command instead.
+ */
class SimpleCommand
: public detail::NodeFactory
{
explicit SimpleCommand(SimpleCommandNode::Function fn);
- SimpleCommandNode & create(DirectoryNode & dir, std::string const & name) const;
-
SimpleCommand const & doc(std::string const & doc) const;
+ ///< Set simple command documentation
SimpleCommand const & shortdoc(std::string const & doc) const;
+ ///< Set simple command short documentation
private:
+ SimpleCommandNode & create(DirectoryNode & dir, std::string const & name) const;
+
SimpleCommandNode::ptr node_;
+
+ friend class senf::console::DirectoryNode;
};
+ /** \brief DirectoryNode factory
+
+ This factory will create new directory nodes. Use
+
+ \code
+ namespace fty = senf::console::factory;
+ node.add("mydir", fty::Directory())
+ \endcode
+
+ To add a directory \a mydir to \a node.
+
+ \see \ref node_tree
+ */
class Directory
: public detail::NodeFactory
{
Directory();
- DirectoryNode & create(DirectoryNode & dir, std::string const & name) const;
-
Directory const & doc(std::string const & doc) const;
+ ///< Set directory documentation
Directory const & shortdoc(std::string const & doc) const;
+ ///< Set directory short documentation
private:
+ DirectoryNode & create(DirectoryNode & dir, std::string const & name) const;
+
DirectoryNode::ptr node_;
+
+ friend class senf::console::DirectoryNode;
};
+ /** \brief LinkNode factory
+
+ This factory will create new link nodes. Use
+
+ \code
+ namespace fty = senf::console::factory;
+ node.add("mylink", fty::Link(targetNode))
+ \endcode
+
+ To add a link \a mylink to \a node pointing to \a targetNode
+
+ \see \ref node_tree
+ */
class Link
: public detail::NodeFactory
{
explicit Link(GenericNode & target);
+ private:
LinkNode & create(DirectoryNode & dir, std::string const & name) const;
- private:
LinkNode::ptr node_;
+
+ friend class senf::console::DirectoryNode;
};
}
-#endif
-
}}
///////////////////////////////hh.e////////////////////////////////////////
{
public:
typedef boost::intrusive_ptr<ParsedCommandOverload> ptr;
-
-#ifdef DOXYGEN
- static ptr create(Function fn);
-#endif
};
#ifndef DOXYGEN
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);
void shortDoc(std::string const & doc);
private:
+ OverloadedCommandNode & create(DirectoryNode & dir, std::string const & name) const;
+
ParsedCommandOverloadBase::ptr overload_;
unsigned index_;
boost::optional<std::string> doc_;
boost::optional<std::string> shortdoc_;
+
+ friend class senf::console::DirectoryNode;
};
/** \brief Non argument dependent ParsedCommandBase attributes
namespace factory {
+#ifdef DOXYGEN
+
+ /** \brief OverloadedCommandNode factory
+
+ This factory will create new OverloadedCommandNode instances <em>or add new overloads</em>
+ 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 <a href="classsenf_1_1console_1_1factory_1_1Command-members.html">List of all
+ members</a> 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 <class Signature>
+ 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 <class Signature>
+ 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 <class Signature>
SimpleOverloadAttributor
Command(boost::function<Signature> fn,
Command(Member memfn, Owner const * owner,
typename boost::enable_if<boost::is_member_function_pointer<Member> >::type * = 0);
+#endif
}}}
namespace factory {
- /** \brief Variable command attributes (const)
+#ifndef DOXYGEN
- \see VariableFactory
- */
template <class Variable>
class ConstVariableFactory
: public detail::NodeFactory
boost::optional<std::string> shortdoc_;
};
- /** \brief Variable command attributes
+#endif
+
+ /** \brief Variable node factory
Variable commands allow to register any arbitrary variable as a command node. The variable
will be registered as two command overloads: One which takes a single argument of the
variable.
It is also possible, to register a variable read-only. To achieve this, just wrap it with \c
- boost::cref(). Such a variable cannot be changed only queried. Therefore, it does not have
- the parser() and typeName() attributes.
+ boost::cref(). Such a variable only queried. Therefore, it does not have the parser() and
+ typeName() attributes.
\code
dir.add("const_var", fty::Variable(boost::cref(var)));
\endcode
- \ingroup console_commands
+ \note Even though the interface is documented as a class, in reality it is implemented using
+ factory functions returning instances of an internal factory class.
+
+ \see \ref console_variables
*/
+#ifdef DOXYGEN
+ class Variable
+#else
template <class Variable>
class VariableFactory
: public ConstVariableFactory<Variable>
+#endif
{
public:
typedef typename detail::SetVariable<Variable>::Traits::Overload SetOverload;
void handler(Variable const & oldValue);
\endcode */
- OverloadedCommandNode & create(DirectoryNode & dir, std::string const & name) const;
-
- explicit VariableFactory(Variable & var);
+ explicit VariableFactory(Variable & var); ///< Create Variable node
protected:
private:
+ OverloadedCommandNode & create(DirectoryNode & dir, std::string const & name) const;
+
typename SetOverload::ptr setOverload_;
Variable & var_;
+
+ friend class senf::console::DirectoryNode;
};
+#ifndef DOXYGEN
+
template <class Var>
VariableFactory<Var> Variable(Var & var);
template <class Var>
ConstVariableFactory<Var> Variable(boost::reference_wrapper<Var const> var);
+#endif
+
}}}
///////////////////////////////hh.e////////////////////////////////////////
sed -e 's/id="current"/class="current"/' \
| tidy -ascii -q --wrap 0 --show-warnings no --fix-uri no \
| sed -e 's/name="\([^"]*\)"\([^>]*\) id="\1"/name="\1"\2/g' \
+ -e 's/id="\([^"]*\)"\([^>]*\) name="\1"/name="\1"\2/g' \
| xsltproc --novalid --nonet --html --stringparam topdir "$reltopdir" \
"$base/html-munge.xsl" -
}