senf::console::ScopedDirectory< Owner > Class Template Reference

DirectoryNode member proxy. More...

#include <senf/Utils/Console/LazyDirectory.hh>

Inheritance diagram for senf::console::ScopedDirectory< Owner >:

Public Types

typedef Owner owner
 

Public Member Functions

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)
 
- Public Member Functions inherited from senf::console::ScopedDirectoryBase
DirectoryNodenode () 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
 
DirectoryNodegetDirectory (std::string const &name) const
 
DirectoryNodeoperator[] (std::string const &name) const
 
CommandNodegetCommand (std::string const &name) const
 
CommandNodeoperator() (std::string const &name) const
 
GenericNodeget (std::string const &name) const
 
DirectoryNode::ChildrenRange children () const
 
DirectoryNodedoc (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< DirectoryNodeparent () const
 
GenericNode::ptr unlink ()
 
void help (std::ostream &output) const
 
std::string shorthelp () const
 

Structors and default members

 ScopedDirectory (Owner *owner)
 

Additional Inherited Members

- Protected Member Functions inherited from senf::console::ScopedDirectoryBase
 ScopedDirectoryBase ()
 
 ~ScopedDirectoryBase ()
 

Detailed Description

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.

Member Typedef Documentation

◆ owner

template<class Owner>
typedef Owner senf::console::ScopedDirectory< Owner >::owner

Definition at line 115 of file ScopedDirectory.hh.

Constructor & Destructor Documentation

◆ ScopedDirectory()

template<class Owner>
senf::console::ScopedDirectory< Owner >::ScopedDirectory ( Owner *  owner)
explicit

Member Function Documentation

◆ add() [1/4]

template<class Owner>
template<class NodeType >
NodeType& senf::console::ScopedDirectory< Owner >::add ( std::string const &  name,
boost::shared_ptr< NodeType >  node 
)

◆ add() [2/4]

template<class Owner>
template<class NodeType >
NodeType& senf::console::ScopedDirectory< Owner >::add ( std::string const &  name,
NodeType &  node,
typename boost::enable_if< boost::is_convertible< NodeType &, GenericNode &> >::type = 0 
)

◆ add() [3/4]

template<class Owner>
template<class Factory >
Factory::result_type senf::console::ScopedDirectory< Owner >::add ( std::string const &  name,
Factory const &  factory,
typename boost::enable_if< boost::is_convertible< Factory *, detail::OwnedNodeFactory *> >::type = 0 
)

◆ add() [4/4]

template<class Owner>
template<class Factory >
Factory::result_type senf::console::ScopedDirectory< Owner >::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 
)

The documentation for this class was generated from the following files: