Changeset 4287


Ignore:
Timestamp:
04/27/12 16:50:08 (2 years ago)
Author:
drobilla
Message:

Disconnect via atom interface.

Location:
trunk/ingen
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ingen/ingen/shared/AtomWriter.hpp

    r4113 r4287  
    7979    void forge_uri(const Raul::URI& uri); 
    8080    void forge_properties(const Resource::Properties& properties); 
     81    void forge_edge(const Raul::URI& tail, const Raul::URI& head); 
    8182 
    8283    void    finish_msg(); 
  • trunk/ingen/src/shared/AtomReader.cpp

    r4285 r4287  
    3636AtomReader::get_uri(const LV2_Atom* in, Raul::Atom& out) 
    3737{ 
    38     if (in->type == _uris.atom_URID) { 
    39         const LV2_Atom_URID* urid = (const LV2_Atom_URID*)in; 
    40         out = _forge.alloc_uri(_map.unmap_uri(urid->body)); 
    41     } else { 
    42         out = _forge.alloc(in->size, in->type, LV2_ATOM_BODY(in)); 
     38    if (in) { 
     39        if (in->type == _uris.atom_URID) { 
     40            const LV2_Atom_URID* urid = (const LV2_Atom_URID*)in; 
     41            out = _forge.alloc_uri(_map.unmap_uri(urid->body)); 
     42        } else { 
     43            out = _forge.alloc(in->size, in->type, LV2_ATOM_BODY(in)); 
     44        } 
    4345    } 
    4446} 
     
    7779        _iface.set_response_id(obj->body.id); 
    7880        _iface.get(subject_uri); 
     81    } else if (obj->body.otype == _uris.patch_Delete) { 
     82        if (subject_uri) { 
     83            _iface.del(subject_uri); 
     84            return; 
     85        } 
     86 
     87        const LV2_Atom_Object* body = NULL; 
     88        lv2_atom_object_get(obj, (LV2_URID)_uris.patch_body, &body, 0); 
     89        if (body && body->body.otype == _uris.ingen_Edge) { 
     90            const LV2_Atom* tail = NULL; 
     91            const LV2_Atom* head = NULL; 
     92            lv2_atom_object_get(body, 
     93                                (LV2_URID)_uris.ingen_tail, &tail, 
     94                                (LV2_URID)_uris.ingen_head, &head, 
     95                                NULL); 
     96 
     97            Raul::Atom tail_atom; 
     98            Raul::Atom head_atom; 
     99            get_uri(tail, tail_atom); 
     100            get_uri(head, head_atom); 
     101            if (tail_atom.is_valid() && head_atom.is_valid()) { 
     102                _iface.disconnect(Raul::Path(tail_atom.get_uri()), 
     103                                  Raul::Path(head_atom.get_uri())); 
     104            } else { 
     105                Raul::warn << "Delete of unknown object." << std::endl; 
     106            } 
     107        } 
    79108    } else if (obj->body.otype == _uris.patch_Put) { 
    80109        const LV2_Atom_Object* body = NULL; 
  • trunk/ingen/src/shared/AtomWriter.cpp

    r4285 r4287  
    106106 
    107107void 
     108AtomWriter::forge_edge(const Raul::URI& tail, const Raul::URI& head) 
     109{ 
     110    LV2_Atom_Forge_Frame edge; 
     111    lv2_atom_forge_blank(&_forge, &edge, 0, _uris.ingen_Edge); 
     112    lv2_atom_forge_property_head(&_forge, _uris.ingen_tail, 0); 
     113    forge_uri(tail); 
     114    lv2_atom_forge_property_head(&_forge, _uris.ingen_head, 0); 
     115    forge_uri(head); 
     116    lv2_atom_forge_pop(&_forge, &edge); 
     117} 
     118 
     119void 
    108120AtomWriter::put(const Raul::URI&            uri, 
    109121                const Resource::Properties& properties, 
     
    181193    forge_uri(Raul::Path::lca(src, dst)); 
    182194    lv2_atom_forge_property_head(&_forge, _uris.patch_body, 0); 
    183  
    184     LV2_Atom_Forge_Frame body; 
    185     lv2_atom_forge_blank(&_forge, &body, 0, _uris.ingen_Edge); 
    186     lv2_atom_forge_property_head(&_forge, _uris.ingen_tail, 0); 
    187     forge_uri(src); 
    188     lv2_atom_forge_property_head(&_forge, _uris.ingen_head, 0); 
    189     forge_uri(dst); 
    190     lv2_atom_forge_pop(&_forge, &body); 
    191  
    192     lv2_atom_forge_pop(&_forge, &msg); 
    193  
     195    forge_edge(src, dst); 
     196    lv2_atom_forge_pop(&_forge, &msg); 
    194197    finish_msg(); 
    195198} 
     
    199202                       const Raul::URI& dst) 
    200203{ 
     204    LV2_Atom_Forge_Frame msg; 
     205    lv2_atom_forge_blank(&_forge, &msg, next_id(), _uris.patch_Delete); 
     206    lv2_atom_forge_property_head(&_forge, _uris.patch_body, 0); 
     207    forge_edge(src, dst); 
     208    lv2_atom_forge_pop(&_forge, &msg); 
     209    finish_msg(); 
    201210} 
    202211 
Note: See TracChangeset for help on using the changeset viewer.