senf::console::ScopedDirectory< Owner > Class Template Reference
[The node tree]

DirectoryNode member proxy. More...

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

Inheritance diagram for senf::console::ScopedDirectory< Owner >:
Inheritance graph
[legend]

List of all members.


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 118 of file ScopedDirectory.hh.


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)
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 *)

Structors and default members

  ScopedDirectory (Owner *owner)

Member Typedef Documentation

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

Definition at line 124 of file ScopedDirectory.hh.


Constructor & Destructor Documentation

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

Definition at line 37 of file ScopedDirectory.cti.


Member Function Documentation

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 )

Definition at line 100 of file ScopedDirectory.cti.

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 )

Definition at line 72 of file ScopedDirectory.cti.

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 )

Definition at line 63 of file ScopedDirectory.cti.

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

Definition at line 54 of file ScopedDirectory.cti.

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

Definition at line 45 of file ScopedDirectory.cti.


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