28 #include "../Common/PathParseAndRetrieve.h"
41 void operator()(InterfaceTree::node_type &node) {
42 m_tree->m_removeHandler(node);
43 node.visitChildren(*
this);
54 bool ret = ifaces.empty();
58 auto it = std::find(begin(ifaces), end(ifaces), iface);
59 if (it == end(ifaces)) {
60 ifaces.push_back(iface);
68 auto it = std::find(begin(ifaces), end(ifaces), iface);
69 if (it != end(ifaces)) {
72 return ifaces.empty();
75 common::InterfaceList &
77 return m_getNodeForPath(path).value().interfaces;
81 return m_getNodeForPath(path).value().handler;
86 return m_removeHandler(m_getNodeForPath(path));
91 RemoteHandlerPtr
const &handler) {
92 return m_setHandler(m_getNodeForPath(path), handler);
101 InterfaceTree::node_type &
102 InterfaceTree::m_getNodeForPath(std::string
const &path) {
106 RemoteHandlerPtr InterfaceTree::m_removeHandler(node_type &node) {
107 auto ret = node.value().handler;
108 node.value().handler.reset();
109 m_handlers.remove(ret);
114 InterfaceTree::m_setHandler(node_type &node,
115 RemoteHandlerPtr
const &handler) {
116 auto ret = m_removeHandler(node);
117 node.value().handler = handler;
118 m_handlers.add(handler);
shared_ptr< ClientInterface > ClientInterfacePtr
Pointer for holding ClientInterface objects safely.
InterfaceTree()
Constructor.
RemoteHandlerPtr getHandlerForPath(std::string const &path)
Returns the handler for a given path.
RemoteHandlerPtr eraseHandlerForPath(std::string const &path)
Clears and returns the handler for a given path.
bool addInterface(common::ClientInterfacePtr const &iface)
Add an interface to the tree.
RemoteHandlerPtr replaceHandlerForPath(std::string const &path, RemoteHandlerPtr const &handler)
Sets the handler for a given path, returning the old handler if any.
void updateHandlers()
Call the update method on all handlers.
common::InterfaceList & getInterfacesForPath(std::string const &path)
Returns a reference to the list of interfaces registered for a given path.
bool removeInterface(common::ClientInterfacePtr const &iface)
Remove an interface from the tree.
Holds on to lists of interfaces organized into the tree structure, as well as their associated handle...
util::TreeNode< ValueType > & pathParseAndRetrieve(util::TreeNode< ValueType > &root, std::string const &path)
Internal method for parsing a path and getting or creating the nodes along it.
void clearHandlers()
Removes all handlers.