191 #ifndef HH_SENF_Utils_Console_Node_ 192 #define HH_SENF_Utils_Console_Node_ 1 196 #include <boost/shared_ptr.hpp> 197 #include <boost/weak_ptr.hpp> 198 #include <boost/enable_shared_from_this.hpp> 199 #include <boost/range/iterator_range.hpp> 200 #include <boost/any.hpp> 251 :
public boost::enable_shared_from_this<GenericNode>
258 typedef boost::shared_ptr<GenericNode>
ptr;
259 typedef boost::shared_ptr<GenericNode const>
cptr;
266 std::string
const &
name()
const;
267 boost::shared_ptr<DirectoryNode> parent()
const;
271 std::string path()
const;
283 void rename(std::string
const & newName);
292 void help(std::ostream & output)
const;
293 std::string shorthelp()
const;
296 cptr thisptr()
const;
308 bool isDirectory()
const;
310 bool isCommand()
const;
318 void name(std::string
const &
name);
325 virtual void v_help(std::ostream & output)
const = 0;
329 virtual std::string v_shorthelp()
const = 0;
355 typedef boost::shared_ptr<LinkNode>
ptr;
356 typedef boost::shared_ptr<LinkNode const>
cptr;
377 virtual void v_help(std::ostream &)
const;
378 virtual std::string v_shorthelp()
const;
409 typedef std::map<std::string, GenericNode::ptr> ChildMap;
414 typedef boost::shared_ptr<DirectoryNode>
ptr;
415 typedef boost::shared_ptr<DirectoryNode const>
cptr;
438 template <
class NodeType>
439 NodeType & add(std::string
const &
name, boost::shared_ptr<NodeType> node);
447 template <
class NodeType>
448 NodeType & add(std::string
const &
name, NodeType & node,
449 typename boost::enable_if< boost::is_convertible<NodeType &, GenericNode &> >::type * = 0);
451 template <
class Factory>
452 typename Factory::result_type add(std::string
const &
name, Factory
const & factory,
453 typename boost::enable_if< boost::is_convertible<Factory const &, detail::NodeFactory const &> >::type * = 0);
472 bool hasChild(std::string
const & name)
const;
479 GenericNode & getLink(std::string
const & name)
const;
484 DirectoryNode & getDirectory(std::string
const & name)
const;
500 CommandNode & getCommand(std::string
const & name)
const;
508 CommandNode & operator()(std::string
const & name)
const;
516 ChildrenRange children()
const;
519 ChildrenRange completions(std::string
const & s)
const;
530 cptr thisptr()
const;
537 virtual void v_help(std::ostream & output)
const;
538 virtual std::string v_shorthelp()
const;
542 std::string shortdoc_;
570 typedef boost::shared_ptr<CommandNode>
ptr;
571 typedef boost::shared_ptr<CommandNode const>
cptr;
576 void execute(std::ostream & output,
ParseCommandInfo const & command)
const;
583 void execute(boost::any & rv, std::ostream & output,
ParseCommandInfo const & command)
592 void operator()(std::ostream & output,
ParseCommandInfo const & command)
const;
599 void operator()(boost::any & rv, std::ostream & output,
ParseCommandInfo const & command)
603 cptr thisptr()
const;
611 virtual void v_execute(boost::any & rv, std::ostream & os,
ParseCommandInfo const & command)
642 typedef boost::shared_ptr<SimpleCommandNode>
ptr;
643 typedef boost::shared_ptr<SimpleCommandNode const>
cptr;
644 typedef boost::weak_ptr<SimpleCommandNode>
weak_ptr;
646 typedef boost::function<void (std::ostream &, ParseCommandInfo const &)>
Function;
655 static ptr create(Function
const & fn);
661 cptr thisptr()
const;
670 virtual void v_help(std::ostream & output)
const;
671 virtual std::string v_shorthelp()
const;
672 virtual void v_execute(boost::any & rv, std::ostream & os,
ParseCommandInfo const & command)
678 std::string shortdoc_;
737 SimpleCommand const & shortdoc(std::string
const & doc)
const;
770 Directory const & doc(std::string
const & doc)
const;
772 Directory const & shortdoc(std::string
const & doc)
const;
boost::shared_ptr< SimpleCommandNode const > cptr
SimpleCommandNode node_type
#define SENF_LOG_CLASS_AREA()
boost::shared_ptr< DirectoryNode > ptr
Config/console tree directory node.
boost::shared_ptr< LinkNode > ptr
boost::iterator_range< ChildMap::const_iterator > ChildrenRange
boost::weak_ptr< SimpleCommandNode > weak_ptr
boost::weak_ptr< GenericNode > weak_ptr
SimpleCommandNode & result_type
boost::shared_ptr< LinkNode const > cptr
boost::weak_ptr< CommandNode > weak_ptr
DirectoryNode & return_type
SimpleCommandNode & return_type
boost::shared_ptr< CommandNode const > cptr
Single parsed console command.
boost::function< void(std::ostream &, ParseCommandInfo const &)> Function
void dump(std::ostream &os, DirectoryNode &dir=root())
Dump console directory structure.
boost::shared_ptr< GenericNode const > cptr
Most simple CommandNode implementation.
Config/console tree link node.
ChildMap::const_iterator child_iterator
void moveChildren(DirectoryNode &from, DirectoryNode &to)
SimpleCommandNode factory.
DirectoryNode & root()
Get console root node.
SimpleCommandNode node_type
DirectoryNode & result_type
Config/console tree command node.
boost::shared_ptr< CommandNode > ptr
unspecified_keyword_type name
Argument name.
UnknownNodeNameException()
boost::weak_ptr< LinkNode > weak_ptr
boost::weak_ptr< DirectoryNode > weak_ptr
Config/console node tree base-class.
DirectoryNode & provideDirectory(DirectoryNode &dir, std::string const &name)
boost::shared_ptr< DirectoryNode const > cptr
boost::shared_ptr< GenericNode > ptr
boost::shared_ptr< SimpleCommandNode > ptr
Exception: Unknown node name.