Skip to content
Snippets Groups Projects
Commit 4a506a4d authored by g0dil's avatar g0dil
Browse files

Utils/Console: Fix adding DirectoryNode's

parent edc48dd4
No related branches found
No related tags found
No related merge requests found
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
//#include "Setup.ih" //#include "Setup.ih"
// Custom includes // Custom includes
#include "Jack.hh"
#define prefix_ inline #define prefix_ inline
///////////////////////////////cti.p/////////////////////////////////////// ///////////////////////////////cti.p///////////////////////////////////////
...@@ -37,7 +38,7 @@ prefix_ void senf::ppi:: ...@@ -37,7 +38,7 @@ prefix_ void senf::ppi::
connect(T & source, C & target, connect(T & source, C & target,
typename boost::disable_if< boost::is_base_of<connector::Connector, T> >::type *, typename boost::disable_if< boost::is_base_of<connector::Connector, T> >::type *,
typename boost::enable_if< boost::is_base_of<connector::Connector, C> >::type *, typename boost::enable_if< boost::is_base_of<connector::Connector, C> >::type *,
typename boost::disable_if< boost::is_base_of<connector::Jack, T> >:: type *) typename boost::disable_if< boost::is_base_of<connector::Jack, T> >::type *)
{ {
connect(source.output, target); connect(source.output, target);
} }
...@@ -47,7 +48,7 @@ prefix_ void senf::ppi:: ...@@ -47,7 +48,7 @@ prefix_ void senf::ppi::
connect(C & source, T & target, connect(C & source, T & target,
typename boost::enable_if< boost::is_base_of<connector::Connector, C> >::type *, typename boost::enable_if< boost::is_base_of<connector::Connector, C> >::type *,
typename boost::disable_if< boost::is_base_of<connector::Connector,T> >::type *, typename boost::disable_if< boost::is_base_of<connector::Connector,T> >::type *,
typename boost::disable_if< boost::is_base_of<connector::Jack, T> >:: type *) typename boost::disable_if< boost::is_base_of<connector::Jack, T> >::type *)
{ {
connect(source, target.input); connect(source, target.input);
} }
...@@ -57,8 +58,8 @@ prefix_ void senf::ppi:: ...@@ -57,8 +58,8 @@ prefix_ void senf::ppi::
connect(T1 & source, T2 & target, connect(T1 & source, T2 & target,
typename boost::disable_if< boost::is_base_of<connector::Connector, T1> >::type *, typename boost::disable_if< boost::is_base_of<connector::Connector, T1> >::type *,
typename boost::disable_if< boost::is_base_of<connector::Connector, T2> >::type *, typename boost::disable_if< boost::is_base_of<connector::Connector, T2> >::type *,
typename boost::disable_if< boost::is_base_of<connector::Jack, T1> >:: type *, typename boost::disable_if< boost::is_base_of<connector::Jack, T1> >::type *,
typename boost::disable_if< boost::is_base_of<connector::Jack, T2> >:: type *) typename boost::disable_if< boost::is_base_of<connector::Jack, T2> >::type *)
{ {
connect(source.output, target.input); connect(source.output, target.input);
} }
......
...@@ -212,6 +212,12 @@ senf::console::DirectoryNode::mkdir(std::string const & name) ...@@ -212,6 +212,12 @@ senf::console::DirectoryNode::mkdir(std::string const & name)
return add(name, create()); return add(name, create());
} }
prefix_ senf::console::DirectoryNode &
senf::console::DirectoryNode::provideDirectory(std::string const & name)
{
return hasChild(name) ? getDirectory(name) : mkdir(name);
}
prefix_ senf::console::DirectoryNode::ChildrenRange senf::console::DirectoryNode::children() prefix_ senf::console::DirectoryNode::ChildrenRange senf::console::DirectoryNode::children()
const const
{ {
...@@ -348,6 +354,13 @@ senf::console::senf_console_add_node(DirectoryNode & node, std::string const & n ...@@ -348,6 +354,13 @@ senf::console::senf_console_add_node(DirectoryNode & node, std::string const & n
return node.add(name, SimpleCommandNode::create(fn)); return node.add(name, SimpleCommandNode::create(fn));
} }
prefix_ senf::console::DirectoryNode &
senf::console::senf_console_add_node(DirectoryNode & node, std::string const & name,
DirectoryNode & dir, int)
{
return node.add(name, dir.thisptr());
}
#endif #endif
///////////////////////////////cci.e/////////////////////////////////////// ///////////////////////////////cci.e///////////////////////////////////////
......
...@@ -538,6 +538,8 @@ namespace console { ...@@ -538,6 +538,8 @@ namespace console {
DirectoryNode & mkdir(std::string const & name); DirectoryNode & mkdir(std::string const & name);
///< Create sub-directory node ///< Create sub-directory node
DirectoryNode & provideDirectory(std::string const & name);
///< Return subdirectory, possibly creating it
ChildrenRange children() const; ///< Return iterator range over all children. ChildrenRange children() const; ///< Return iterator range over all children.
/**< The returned range is sorted by child name. */ /**< The returned range is sorted by child name. */
...@@ -711,6 +713,9 @@ namespace console { ...@@ -711,6 +713,9 @@ namespace console {
SimpleCommandNode & senf_console_add_node(DirectoryNode & node, std::string const & name, SimpleCommandNode & senf_console_add_node(DirectoryNode & node, std::string const & name,
SimpleCommandNode::Function fn, int); SimpleCommandNode::Function fn, int);
DirectoryNode & senf_console_add_node(DirectoryNode & node, std::string const & name,
DirectoryNode & dir, int);
#endif #endif
}} }}
......
...@@ -88,6 +88,14 @@ senf_console_add_node(DirectoryNode & node, Owner & owner, std::string const & n ...@@ -88,6 +88,14 @@ senf_console_add_node(DirectoryNode & node, Owner & owner, std::string const & n
return node.add(name, boost::bind(fn,boost::ref(owner),_1,_2)); return node.add(name, boost::bind(fn,boost::ref(owner),_1,_2));
} }
template <class Owner>
prefix_ senf::console::DirectoryNode &
senf::console::senf_console_add_node(DirectoryNode & node, Owner & owner,
std::string const & name, DirectoryNode & dir, int)
{
return node.add(name, dir.thisptr());
}
template <class Node> template <class Node>
prefix_ senf::console::DirectoryNode & senf::console:: prefix_ senf::console::DirectoryNode & senf::console::
senf_console_add_node(DirectoryNode & dir, std::string const & name, Node const & node, int, senf_console_add_node(DirectoryNode & dir, std::string const & name, Node const & node, int,
......
...@@ -197,6 +197,10 @@ namespace console { ...@@ -197,6 +197,10 @@ namespace console {
DirectoryNode & node, Owner & owner, std::string const & name, DirectoryNode & node, Owner & owner, std::string const & name,
void (Owner::*fn)(std::ostream &, ParseCommandInfo const &), int); void (Owner::*fn)(std::ostream &, ParseCommandInfo const &), int);
template <class Owner>
DirectoryNode & senf_console_add_node(DirectoryNode & node, Owner & owner,
std::string const & name, DirectoryNode & dir, int);
template <class Node> template <class Node>
DirectoryNode & senf_console_add_node( DirectoryNode & senf_console_add_node(
DirectoryNode & dir, std::string const & name, Node const & node, int, DirectoryNode & dir, std::string const & name, Node const & node, int,
......
...@@ -199,6 +199,7 @@ template <class Variable> ...@@ -199,6 +199,7 @@ template <class Variable>
prefix_ senf::console::VariableAttributor<Variable> senf::console:: prefix_ senf::console::VariableAttributor<Variable> senf::console::
senf_console_add_node(DirectoryNode & node, std::string const & name, Variable & var, int, senf_console_add_node(DirectoryNode & node, std::string const & name, Variable & var, int,
typename boost::disable_if< boost::is_convertible<Variable*, ScopedDirectoryBase*> >::type *, typename boost::disable_if< boost::is_convertible<Variable*, ScopedDirectoryBase*> >::type *,
typename boost::disable_if< boost::is_convertible<Variable*, GenericNode*> >::type *,
typename boost::disable_if_c<detail::ParsedCommandTraits<Variable>::is_callable>::type *) typename boost::disable_if_c<detail::ParsedCommandTraits<Variable>::is_callable>::type *)
{ {
return detail::VariableNodeCreator<Variable>::add(node, name, var); return detail::VariableNodeCreator<Variable>::add(node, name, var);
...@@ -214,9 +215,10 @@ senf::console::senf_console_add_node(DirectoryNode & node, std::string const & n ...@@ -214,9 +215,10 @@ senf::console::senf_console_add_node(DirectoryNode & node, std::string const & n
template <class Variable, class Owner> template <class Variable, class Owner>
prefix_ senf::console::VariableAttributor<Variable> senf::console:: prefix_ senf::console::VariableAttributor<Variable> senf::console::
senf_console_add_node(DirectoryNode & node, Owner &, std::string const & name, senf_console_add_node(DirectoryNode & node, Owner & owner, std::string const & name,
Variable & var, int, Variable & var, int,
typename boost::disable_if< boost::is_convertible<Variable*, ScopedDirectoryBase*> >::type *, typename boost::disable_if< boost::is_convertible<Variable*, ScopedDirectoryBase*> >::type *,
typename boost::disable_if< boost::is_convertible<Variable*, GenericNode*> >::type *,
typename boost::disable_if_c<detail::ParsedCommandTraits<Variable>::is_callable>::type *) typename boost::disable_if_c<detail::ParsedCommandTraits<Variable>::is_callable>::type *)
{ {
return detail::VariableNodeCreator<Variable>::add(node, name, var); return detail::VariableNodeCreator<Variable>::add(node, name, var);
......
...@@ -42,12 +42,15 @@ namespace console { ...@@ -42,12 +42,15 @@ namespace console {
class ScopedDirectoryBase; class ScopedDirectoryBase;
template <class Variable> class VariableAttributor; template <class Variable> class VariableAttributor;
#ifndef DOXYGEN #ifndef DOXYGEN
template <class Variable> template <class Variable>
VariableAttributor<Variable> senf_console_add_node( VariableAttributor<Variable> senf_console_add_node(
DirectoryNode & node, std::string const & name, Variable & var, int, DirectoryNode & node, std::string const & name, Variable & var, int,
typename boost::disable_if< boost::is_convertible<Variable*, ScopedDirectoryBase*> >::type * = 0, typename boost::disable_if< boost::is_convertible<Variable*, ScopedDirectoryBase*> >::type * = 0,
typename boost::disable_if< boost::is_convertible<Variable*, GenericNode*> >::type * = 0,
typename boost::disable_if_c<detail::ParsedCommandTraits<Variable>::is_callable>::type * = 0); typename boost::disable_if_c<detail::ParsedCommandTraits<Variable>::is_callable>::type * = 0);
template <class Variable> template <class Variable>
...@@ -59,6 +62,7 @@ namespace console { ...@@ -59,6 +62,7 @@ namespace console {
VariableAttributor<Variable> senf_console_add_node( VariableAttributor<Variable> senf_console_add_node(
DirectoryNode & node, Owner & owner, std::string const & name, Variable & var, int, DirectoryNode & node, Owner & owner, std::string const & name, Variable & var, int,
typename boost::disable_if< boost::is_convertible<Variable*, ScopedDirectoryBase*> >::type * = 0, typename boost::disable_if< boost::is_convertible<Variable*, ScopedDirectoryBase*> >::type * = 0,
typename boost::disable_if< boost::is_convertible<Variable*, GenericNode*> >::type * = 0,
typename boost::disable_if_c<detail::ParsedCommandTraits<Variable>::is_callable>::type * = 0); typename boost::disable_if_c<detail::ParsedCommandTraits<Variable>::is_callable>::type * = 0);
template <class Variable, class Owner> template <class Variable, class Owner>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment