Beispiel #1
0
void OSSIADevice::removeNode(const State::Address& address)
{
    using namespace OSSIA;
    if(!m_capas.canRemoveNode)
        return;
    if(!connected())
        return;

    OSSIA::Node* node = getNodeFromPath(address.path, m_dev.get());
    auto parent = node->getParent();
    auto& parentChildren = node->getParent()->children();
    auto it = std::find_if(parentChildren.begin(), parentChildren.end(),
                           [&] (auto&& elt) { return elt.get() == node; });
    if(it != parentChildren.end())
    {
        /* If we are listening to this node, we recursively
         * remove listening to all the children. */
        removeListening_impl(*it->get(), address);

        // TODO !! if we remove nodes while recording
        // (or anything involving a registered listening state), there will be crashes.
        // The Device Explorer should be locked for edition during recording / playing.
        parent->erase(it);
    }
}
Beispiel #2
0
void OSSIADevice::removeAddress(const QString &address)
{
    using namespace OSSIA;
    QStringList path = address.split("/");
    path.removeFirst();
    path.removeFirst();

    OSSIA::Node* node = createNodeFromPath(path, m_dev.get());
    auto& children = node->getParent()->children();
    auto it = boost::range::find_if(children, [&] (auto&& elt) { return elt.get() == node; });
    if(it != children.end())
        children.erase(it);
}