// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/** \file
- \brief ObjectDirectory public header */
+ \brief ScopedDirectory public header */
-#ifndef HH_ObjectDirectory_
-#define HH_ObjectDirectory_ 1
+#ifndef HH_ScopedDirectory_
+#define HH_ScopedDirectory_ 1
// Custom includes
#include <boost/utility.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include "Node.hh"
-//#include "ObjectDirectory.mpp"
+//#include "ScopedDirectory.mpp"
///////////////////////////////hh.p////////////////////////////////////////
namespace senf {
namespace console {
- /** \brief Internal: Node creation helper traits (ObjectDirectory proxy)
+ /** \brief Internal: Node creation helper traits (ScopedDirectory proxy)
This class is used like NodeCreateTraits to customize the child node creation. This trait
- class is used however by the ObjectDirectory proxy.
+ class is used however by the ScopedDirectory proxy.
*/
template <class Owner, class Object>
struct OwnerNodeCreateTraits
};
};
- /** \brief Internal: Marker base class for all ObjectDirectory proxies
+ /** \brief Internal: Marker base class for all ScopedDirectory proxies
*/
- struct ObjectDirectoryBase {};
+ class ScopedDirectoryBase
+ {
+ public:
+ DirectoryNode & node() const; ///< Access the proxied DirectoryNode
+
+ ///////////////////////////////////////////////////////////////////////////
+ ///\name Proxied members (see DirectoryNode)
+ ///\{
+
+ GenericNode::ptr remove(std::string const & name);
+ DirectoryNode & operator[](std::string const & name) const;
+ CommandNode & operator()(std::string const & name) const;
+ GenericNode & get(std::string const & name) const;
+ DirectoryNode & mkdir(std::string const & name);
+ DirectoryNode::ChildrenRange children() const;
+ DirectoryNode & doc(std::string const & doc);
+
+ ///\}
+
+ protected:
+ ScopedDirectoryBase();
+ ~ScopedDirectoryBase();
+
+ private:
+ DirectoryNode::ptr node_;
+ };
/** \brief DirectoryNode member proxy
- ObjectDirectory is used whenever a class wants to manage it's own directory. The class
+ 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
class MyClass
{
public:
- ObjectDirectory<MyClass> configDir;
+ ScopedDirectory<MyClass> configDir;
MyClass() : configDir(this)
{
};
\endcode
- The ObjectDirectory proxy implements 'add()' to add new children to the proxied
+ The ScopedDirectory proxy implements 'add()' to add new children to the proxied
DirectoryNode. All add() variants supported by DirectoryNode are supported by
- ObjectDirectory.
+ 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
\ingroup node_tree
*/
- template <class Owner>
- class ObjectDirectory : public ObjectDirectoryBase
+ template <class Owner=void>
+ class ScopedDirectory : public ScopedDirectoryBase
{
public:
///////////////////////////////////////////////////////////////////////////
///\name Structors and default members
///@{
- ObjectDirectory(Owner * owner);
- ~ObjectDirectory();
+ ScopedDirectory(Owner * owner);
///@}
///////////////////////////////////////////////////////////////////////////
implementation just forwards the call to the proxied
directory node. */
- DirectoryNode & node() const; ///< Access the proxied DirectoryNode
-
- ///////////////////////////////////////////////////////////////////////////
- ///\name Proxied members (see DirectoryNode)
- ///\{
-
- GenericNode::ptr remove(std::string const & name);
- DirectoryNode & operator[](std::string const & name) const;
- CommandNode & operator()(std::string const & name) const;
- GenericNode & get(std::string const & name) const;
- DirectoryNode & mkdir(std::string const & name);
- DirectoryNode::ChildrenRange children() const;
- DirectoryNode & doc(std::string const & doc);
-
- ///\}
-
protected:
private:
- DirectoryNode::ptr node_;
Owner * owner_;
};
+ template <>
+ class ScopedDirectory<void> : public ScopedDirectoryBase
+ {
+ public:
+ template <class Object>
+ typename NodeCreateTraits<Object>::NodeType & add(std::string const & name,
+ Object const & ob);
+ };
+
#ifndef DOXYGEN
template <class Owner, class Function>
SimpleCommandNode & senf_console_add_node(
template <class Node>
DirectoryNode & senf_console_add_node(
DirectoryNode & dir, std::string const & name, Node const & node, int,
- typename boost::enable_if< boost::is_convertible<Node*, ObjectDirectoryBase*> >::type * = 0);
+ typename boost::enable_if< boost::is_convertible<Node*, ScopedDirectoryBase*> >::type * = 0);
#endif
}}
///////////////////////////////hh.e////////////////////////////////////////
-//#include "ObjectDirectory.cci"
-//#include "ObjectDirectory.ct"
-#include "ObjectDirectory.cti"
+#include "ScopedDirectory.cci"
+//#include "ScopedDirectory.ct"
+#include "ScopedDirectory.cti"
#endif
\f