|
template<class NodeType > |
NodeType & | add (std::string const &name, boost::shared_ptr< NodeType > node) |
|
template<class NodeType > |
NodeType & | add (std::string const &name, NodeType &node, typename boost::enable_if< boost::is_convertible< NodeType &, GenericNode &> >::type *=0) |
|
template<class Factory > |
Factory::result_type | add (std::string const &name, Factory const &factory, typename boost::enable_if< boost::is_convertible< Factory *, detail::OwnedNodeFactory *> >::type *=0) |
|
template<class Factory > |
Factory::result_type | add (std::string const &name, Factory const &factory, typename boost::enable_if< boost::is_convertible< Factory *, detail::NodeFactory *> >::type *=0, typename boost::disable_if< boost::is_convertible< Factory *, detail::OwnedNodeFactory *> >::type *=0) |
|
DirectoryNode & | node () const |
| Access the proxied DirectoryNode. More...
|
|
| operator DirectoryNode & () const |
| Access the proxied DirectoryNode. More...
|
|
GenericNode::ptr | remove (std::string const &name) |
|
bool | hasChild (std::string const &name) const |
|
DirectoryNode & | getDirectory (std::string const &name) const |
|
DirectoryNode & | operator[] (std::string const &name) const |
|
CommandNode & | getCommand (std::string const &name) const |
|
CommandNode & | operator() (std::string const &name) const |
|
GenericNode & | get (std::string const &name) const |
|
DirectoryNode::ChildrenRange | children () const |
|
DirectoryNode & | doc (std::string const &doc) |
|
std::string const & | name () const |
|
bool | active () const |
|
std::string | path () const |
|
std::string | path (DirectoryNode const &root) const |
|
boost::shared_ptr< DirectoryNode > | parent () const |
|
GenericNode::ptr | unlink () |
|
void | help (std::ostream &output) const |
|
std::string | shorthelp () const |
|
template<class Owner>
class senf::console::ScopedDirectory< Owner >
DirectoryNode member proxy.
ScopedDirectory is used whenever a class wants to manage it's own directory. The class allows to declare the directory as a public member object. This allows the user of the class to register the directory in the command tree. By using the proxy, the node is automatically detached from the tree (and thereby destroyed) when the object (and thereby the proxy) is destroyed.
class MyClass
{
public:
ScopedDirectory<MyClass> configDir;
MyClass() : configDir(this)
{
configDir.add(...);
}
};
The ScopedDirectory proxy implements 'add()' to add new children to the proxied
DirectoryNode. All add() variants supported by DirectoryNode are supported by
ScopedDirectory.
- Idea:
- This proxy could be made obsolete by allowing to allocate node objects statically. This could be achieved by moving back to an intrusive_ptr implementation for normal pointing needs with an added twist: Give each node a smart_ptr member pointing to itself with a null deleter. This allows to create weak_ptr's to the nodes which will automatically expire when the node is deleted (either statically or by the intrusive_ptr).
Definition at line 30 of file LazyDirectory.hh.