bool CompositeNode::remove( INode* child )
    {
        NodePtr ptr( child ); // scoped reference count

        if ( !child || child->getParent() != this ) { return false; }
        if ( !eraseItem( _children, ptr ) ) { return false; }

        child->setParent( 0 );

        // check for added child attributes
        /*AttributeMap::iterator it;
        AttributeMap::iterator it2;
        for ( it = _attributes.begin(); it != _attributes.end(); )
        {
            it2 = it;
            ++it;

            if ( child->hasAttribute( it2->second ) )
            {
                removeAttributeFromParent( it2->second );
                doRemoveAttribute( it2 );
            }
        }*/

        getEventManager().sendEvent( E_NODE_CHILD_REMOVED_EVENT, *this, *child );

        return true;
    }
示例#2
0
esp_err_t Storage::eraseNamespace(uint8_t nsIndex)
{
    if (mState != StorageState::ACTIVE) {
        return ESP_ERR_NVS_NOT_INITIALIZED;
    }

    for (auto it = std::begin(mPageManager); it != std::end(mPageManager); ++it) {
        while (true) {
            auto err = it->eraseItem(nsIndex, ItemType::ANY, nullptr);
            if (err == ESP_ERR_NVS_NOT_FOUND) {
                break;
            }
            else if (err != ESP_OK) {
                return err;
            }
        }
    }
    return ESP_OK;

}