Changeset 2533

Show
Ignore:
Timestamp:
03/06/10 02:23:19 (6 months ago)
Author:
drobilla
Message:

Save Ingen patches as working standard LV2 plugin bundles.

This allows you to create an Ingen patch in Ingen running as a Jack client,
save it, then load that patch as an LV2 plugin in any LV2 compliant host.

Eliminate (hopefully) all static data in the engine (for multiple instantiations in a single process).

More API/ABI stable interface for Ingen::Shared::World.

Location:
trunk
Files:
118 modified

Legend:

Unmodified
Added
Removed
  • trunk/ingen/src/bindings/ingen_bindings.cpp

    r2349 r2533  
    4444script_iteration(Ingen::Shared::World* world) 
    4545{ 
    46         if (world->local_engine) 
    47                 world->local_engine->main_iteration(); 
     46        if (world->local_engine()) 
     47                world->local_engine()->main_iteration(); 
    4848} 
    4949 
  • trunk/ingen/src/client/ClientStore.cpp

    r2514 r2533  
    3838 
    3939 
    40 ClientStore::ClientStore(SharedPtr<EngineInterface> engine, SharedPtr<SigClientInterface> emitter) 
    41         : _engine(engine) 
     40ClientStore::ClientStore(SharedPtr<Shared::LV2URIMap> uris, 
     41                SharedPtr<EngineInterface> engine, SharedPtr<SigClientInterface> emitter) 
     42        : _uris(uris) 
     43        , _engine(engine) 
    4244        , _emitter(emitter) 
    4345        , _plugins(new Plugins()) 
     
    258260        bool is_meta = ResourceImpl::is_meta_uri(uri); 
    259261 
    260         const LV2URIMap& uris = Shared::LV2URIMap::instance(); 
    261  
    262262        if (!(is_path || is_meta)) { 
    263                 const Atom& type = properties.find(uris.rdf_type)->second; 
     263                const Atom& type = properties.find(_uris->rdf_type)->second; 
    264264                if (type.type() == Atom::URI) { 
    265265                        const URI& type_uri = type.get_uri(); 
    266266                        if (Plugin::type_from_uri(type_uri) != Plugin::NIL) { 
    267                                 SharedPtr<PluginModel> p(new PluginModel(uri, type_uri, properties)); 
     267                                SharedPtr<PluginModel> p(new PluginModel(uris(), uri, type_uri, properties)); 
    268268                                add_plugin(p); 
    269269                                return; 
     
    290290        bool is_patch, is_node, is_port, is_output; 
    291291        PortType data_type(PortType::UNKNOWN); 
    292         ResourceImpl::type(properties, is_patch, is_node, is_port, is_output, data_type); 
     292        ResourceImpl::type(uris(), properties, is_patch, is_node, is_port, is_output, data_type); 
    293293 
    294294        if (is_patch) { 
    295                 SharedPtr<PatchModel> model(new PatchModel(path)); 
     295                SharedPtr<PatchModel> model(new PatchModel(uris(), path)); 
    296296                model->set_properties(properties); 
    297297                add_object(model); 
    298298        } else if (is_node) { 
    299                 const Resource::Properties::const_iterator p = properties.find(uris.rdf_instanceOf); 
     299                const Resource::Properties::const_iterator p = properties.find(_uris->rdf_instanceOf); 
    300300                SharedPtr<PluginModel> plug; 
    301301                if (p->second.is_valid() && p->second.type() == Atom::URI) { 
     
    303303                                LOG(warn) << "Unable to find plugin " << p->second.get_uri() << endl; 
    304304                                plug = SharedPtr<PluginModel>( 
    305                                                 new PluginModel(p->second.get_uri(), uris.ingen_nil, Resource::Properties())); 
     305                                                new PluginModel(uris(), p->second.get_uri(), _uris->ingen_nil, Resource::Properties())); 
    306306                                add_plugin(plug); 
    307307                        } 
    308308 
    309                         SharedPtr<NodeModel> n(new NodeModel(plug, path)); 
     309                        SharedPtr<NodeModel> n(new NodeModel(uris(), plug, path)); 
    310310                        n->set_properties(properties); 
    311311                        add_object(n); 
     
    316316                if (data_type != PortType::UNKNOWN) { 
    317317                        PortModel::Direction pdir = is_output ? PortModel::OUTPUT : PortModel::INPUT; 
    318                         const Resource::Properties::const_iterator i = properties.find(uris.lv2_index); 
     318                        const Resource::Properties::const_iterator i = properties.find(_uris->lv2_index); 
    319319                        if (i != properties.end() && i->second.type() == Atom::INT) { 
    320                                 SharedPtr<PortModel> p(new PortModel(path, i->second.get_int32(), data_type, pdir)); 
     320                                SharedPtr<PortModel> p(new PortModel(uris(), path, i->second.get_int32(), data_type, pdir)); 
    321321                                p->set_properties(properties); 
    322322                                add_object(p); 
  • trunk/ingen/src/client/ClientStore.hpp

    r2445 r2533  
    5353class ClientStore : public Shared::Store, public Shared::CommonInterface, public sigc::trackable { 
    5454public: 
    55         ClientStore(SharedPtr<Shared::EngineInterface> engine=SharedPtr<Shared::EngineInterface>(), 
    56                     SharedPtr<SigClientInterface> emitter=SharedPtr<SigClientInterface>()); 
     55        ClientStore(SharedPtr<Shared::LV2URIMap> uris, 
     56                        SharedPtr<Shared::EngineInterface> engine=SharedPtr<Shared::EngineInterface>(), 
     57                        SharedPtr<SigClientInterface> emitter=SharedPtr<SigClientInterface>()); 
    5758 
    5859        SharedPtr<PluginModel>      plugin(const Raul::URI& uri); 
     
    6667        SharedPtr<Plugins>       plugins()                         { return _plugins; } 
    6768        void                     set_plugins(SharedPtr<Plugins> p) { _plugins = p; } 
     69 
     70        Shared::LV2URIMap& uris() { return *_uris.get(); } 
    6871 
    6972        // CommonInterface 
     
    100103        bool attempt_connection(const Raul::Path& src_port_path, const Raul::Path& dst_port_path); 
    101104 
     105        SharedPtr<Shared::LV2URIMap>       _uris; 
    102106        SharedPtr<Shared::EngineInterface> _engine; 
    103107        SharedPtr<SigClientInterface>      _emitter; 
  • trunk/ingen/src/client/DeprecatedLoader.cpp

    r2518 r2533  
    213213        size_t poly = 0; 
    214214 
    215         const LV2URIMap& uris = Shared::LV2URIMap::instance(); 
    216  
    217215        /* Use parameter overridden polyphony, if given */ 
    218         GraphObject::Properties::iterator poly_param = initial_data.find(uris.ingen_polyphony); 
     216        GraphObject::Properties::iterator poly_param = initial_data.find(_uris->ingen_polyphony); 
    219217        if (poly_param != initial_data.end() && poly_param->second.type() == Atom::INT) 
    220218                poly = poly_param->second.get_int32(); 
    221219 
    222         if (initial_data.find(uris.ingen_document) == initial_data.end()) 
    223                 initial_data.insert(make_pair(uris.ingen_document, filename)); 
     220        if (initial_data.find(_uris->ingen_document) == initial_data.end()) 
     221                initial_data.insert(make_pair(_uris->ingen_document, filename)); 
    224222 
    225223        xmlDocPtr doc = xmlParseFile(filename.c_str()); 
     
    285283        if (!existing && !path.is_root()) { 
    286284                Resource::Properties props; 
    287                 props.insert(make_pair(uris.rdf_type,        uris.ingen_Patch)); 
    288                 props.insert(make_pair(uris.ingen_polyphony, Atom((int32_t)poly))); 
     285                props.insert(make_pair(_uris->rdf_type,        _uris->ingen_Patch)); 
     286                props.insert(make_pair(_uris->ingen_polyphony, Atom((int32_t)poly))); 
    289287                _engine->put(path, props); 
    290288                for (GraphObject::Properties::const_iterator i = initial_data.begin(); i != initial_data.end(); ++i) 
     
    331329                                        const float value = i->value(); 
    332330                                        _engine->set_property(translate_load_path(i->port_path().str()), 
    333                                                         uris.ingen_value, Atom(value)); 
     331                                                        _uris->ingen_value, Atom(value)); 
    334332                                } 
    335333                        } else { 
     
    348346 
    349347        if (!existing) 
    350                 _engine->set_property(path, uris.ingen_enabled, (bool)true); 
     348                _engine->set_property(path, _uris->ingen_enabled, (bool)true); 
    351349 
    352350        _load_path_translations.clear(); 
     
    440438        } 
    441439 
    442         const LV2URIMap& uris = Shared::LV2URIMap::instance(); 
    443  
    444440        // Compatibility hacks for old patches that represent patch ports as nodes 
    445441        if (plugin_uri.empty()) { 
     
    451447                        is_port = true; 
    452448                        if (plugin_label == "audio_input") { 
    453                                 props.insert(make_pair(uris.rdf_type, uris.lv2_AudioPort)); 
    454                                 props.insert(make_pair(uris.rdf_type, uris.lv2_InputPort)); 
     449                                props.insert(make_pair(_uris->rdf_type, _uris->lv2_AudioPort)); 
     450                                props.insert(make_pair(_uris->rdf_type, _uris->lv2_InputPort)); 
    455451                        } else if (plugin_label == "audio_output") { 
    456                                 props.insert(make_pair(uris.rdf_type, uris.lv2_AudioPort)); 
    457                                 props.insert(make_pair(uris.rdf_type, uris.lv2_OutputPort)); 
     452                                props.insert(make_pair(_uris->rdf_type, _uris->lv2_AudioPort)); 
     453                                props.insert(make_pair(_uris->rdf_type, _uris->lv2_OutputPort)); 
    458454                        } else if (plugin_label == "control_input") { 
    459                                 props.insert(make_pair(uris.rdf_type, uris.lv2_ControlPort)); 
    460                                 props.insert(make_pair(uris.rdf_type, uris.lv2_InputPort)); 
     455                                props.insert(make_pair(_uris->rdf_type, _uris->lv2_ControlPort)); 
     456                                props.insert(make_pair(_uris->rdf_type, _uris->lv2_InputPort)); 
    461457                        } else if (plugin_label == "control_output" ) { 
    462                                 props.insert(make_pair(uris.rdf_type, uris.lv2_ControlPort)); 
    463                                 props.insert(make_pair(uris.rdf_type, uris.lv2_OutputPort)); 
     458                                props.insert(make_pair(_uris->rdf_type, _uris->lv2_ControlPort)); 
     459                                props.insert(make_pair(_uris->rdf_type, _uris->lv2_OutputPort)); 
    464460                        } else if (plugin_label == "midi_input") { 
    465                                 props.insert(make_pair(uris.rdf_type, uris.lv2ev_EventPort)); 
    466                                 props.insert(make_pair(uris.rdf_type, uris.lv2_InputPort)); 
     461                                props.insert(make_pair(_uris->rdf_type, _uris->lv2ev_EventPort)); 
     462                                props.insert(make_pair(_uris->rdf_type, _uris->lv2_InputPort)); 
    467463                        } else if (plugin_label == "midi_output" ) { 
    468                                 props.insert(make_pair(uris.rdf_type, uris.lv2ev_EventPort)); 
    469                                 props.insert(make_pair(uris.rdf_type, uris.lv2_OutputPort)); 
     464                                props.insert(make_pair(_uris->rdf_type, _uris->lv2ev_EventPort)); 
     465                                props.insert(make_pair(_uris->rdf_type, _uris->lv2_OutputPort)); 
    470466                        } else { 
    471467                                is_port = false; 
     
    524520 
    525521                        Resource::Properties props; 
    526                         props.insert(make_pair(uris.rdf_type,       uris.ingen_Node)); 
    527                         props.insert(make_pair(uris.rdf_instanceOf, Atom(Atom::URI, plugin_uri))); 
     522                        props.insert(make_pair(_uris->rdf_type,       _uris->ingen_Node)); 
     523                        props.insert(make_pair(_uris->rdf_instanceOf, Atom(Atom::URI, plugin_uri))); 
    528524                        _engine->put(path, props); 
    529525 
    530                         _engine->set_property(path, uris.ingen_polyphonic, bool(polyphonic)); 
     526                        _engine->set_property(path, _uris->ingen_polyphonic, bool(polyphonic)); 
    531527 
    532528                        for (GraphObject::Properties::const_iterator i = initial_data.begin(); i != initial_data.end(); ++i) 
     
    539535        } else { 
    540536                Resource::Properties props; 
    541                 props.insert(make_pair(uris.rdf_type,       uris.ingen_Node)); 
    542                 props.insert(make_pair(uris.rdf_instanceOf, Atom(Atom::URI, plugin_uri))); 
     537                props.insert(make_pair(_uris->rdf_type,       _uris->ingen_Node)); 
     538                props.insert(make_pair(_uris->rdf_instanceOf, Atom(Atom::URI, plugin_uri))); 
    543539                _engine->put(path, props); 
    544                 _engine->set_property(path, uris.ingen_polyphonic, bool(polyphonic)); 
     540                _engine->set_property(path, _uris->ingen_polyphonic, bool(polyphonic)); 
    545541                for (GraphObject::Properties::const_iterator i = initial_data.begin(); i != initial_data.end(); ++i) 
    546542                        _engine->set_property(path, i->first, i->second); 
     
    563559 
    564560        GraphObject::Properties initial_data; 
    565         const LV2URIMap& uris = Shared::LV2URIMap::instance(); 
    566  
    567561        while (cur != NULL) { 
    568562                key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 
     
    571565                        name = (const char*)key; 
    572566                } else if ((!xmlStrcmp(cur->name, (const xmlChar*)"polyphony"))) { 
    573                         initial_data.insert(make_pair(uris.ingen_polyphony, (int)poly)); 
     567                        initial_data.insert(make_pair(_uris->ingen_polyphony, (int)poly)); 
    574568                } else if ((!xmlStrcmp(cur->name, (const xmlChar*)"filename"))) { 
    575569                        filename = Glib::build_filename(base_filename, (const char*)key); 
  • trunk/ingen/src/client/DeprecatedLoader.hpp

    r2428 r2533  
    3434 
    3535namespace Ingen { 
     36 
     37namespace Shared { class LV2URIMap; } 
     38 
    3639namespace Client { 
    3740 
     
    4649{ 
    4750public: 
    48         DeprecatedLoader(SharedPtr<Shared::EngineInterface> engine) 
    49                 : _engine(engine) 
     51        DeprecatedLoader( 
     52                        SharedPtr<Shared::LV2URIMap> uris, 
     53                        SharedPtr<Shared::EngineInterface> engine) 
     54                : _uris(uris) 
     55                , _engine(engine) 
    5056        { 
    5157                assert(_engine); 
     
    6571        std::string translate_load_path(const std::string& path); 
    6672 
     73        SharedPtr<Shared::LV2URIMap>       _uris; 
    6774        SharedPtr<Shared::EngineInterface> _engine; 
    6875 
  • trunk/ingen/src/client/HTTPClientReceiver.cpp

    r2484 r2533  
    134134HTTPClientReceiver::update(const std::string& str) 
    135135{ 
    136         LOG(info) << _world->parser->parse_update(_world, _target.get(), str, _url); 
     136        LOG(info) << _world->parser()->parse_update(_world, _target.get(), str, _url); 
    137137} 
    138138 
     
    189189                        Glib::Mutex::Lock lock(me->_mutex); 
    190190                        me->_target->response_ok(0); 
    191                         me->_world->parser->parse_string(me->_world, me->_target.get(), 
     191                        me->_world->parser()->parse_string(me->_world, me->_target.get(), 
    192192                                        Glib::ustring(msg->response_body->data), me->_url); 
    193193                } 
     
    199199                        Glib::Mutex::Lock lock(me->_mutex); 
    200200                        me->_target->response_ok(0); 
    201                         me->_world->parser->parse_string(me->_world, me->_target.get(), 
     201                        me->_world->parser()->parse_string(me->_world, me->_target.get(), 
    202202                                        Glib::ustring(msg->response_body->data), 
    203203                                        Glib::ustring("/patch/")); 
     
    227227HTTPClientReceiver::start(bool dump) 
    228228{ 
    229         Glib::Mutex::Lock lock(_world->rdf_world->mutex()); 
    230  
    231         if (!_world->parser) 
     229        Glib::Mutex::Lock lock(_world->rdf_world()->mutex()); 
     230 
     231        if (!_world->parser()) 
    232232                _world->load("ingen_serialisation"); 
    233233 
  • trunk/ingen/src/client/HTTPEngineSender.cpp

    r2504 r2533  
    3434 
    3535 
    36 HTTPEngineSender::HTTPEngineSender(const World* world, const URI& engine_url) 
    37         : _world(*world->rdf_world) 
     36HTTPEngineSender::HTTPEngineSender(World* world, const URI& engine_url) 
     37        : _world(*world->rdf_world()) 
    3838        , _engine_url(engine_url) 
    3939        , _id(0) 
  • trunk/ingen/src/client/HTTPEngineSender.hpp

    r2504 r2533  
    4444{ 
    4545public: 
    46         HTTPEngineSender(const Shared::World* world, const Raul::URI& engine_url); 
     46        HTTPEngineSender(Shared::World* world, const Raul::URI& engine_url); 
    4747        ~HTTPEngineSender(); 
    4848 
  • trunk/ingen/src/client/NodeModel.cpp

    r2409 r2533  
    3131 
    3232 
    33 NodeModel::NodeModel(SharedPtr<PluginModel> plugin, const Path& path) 
    34         : ObjectModel(path) 
     33NodeModel::NodeModel(Shared::LV2URIMap& uris, SharedPtr<PluginModel> plugin, const Path& path) 
     34        : ObjectModel(uris, path) 
    3535        , _plugin_uri(plugin->uri()) 
    3636        , _plugin(plugin) 
     
    4141} 
    4242 
    43 NodeModel::NodeModel(const URI& plugin_uri, const Path& path) 
    44         : ObjectModel(path) 
     43NodeModel::NodeModel(Shared::LV2URIMap& uris, const URI& plugin_uri, const Path& path) 
     44        : ObjectModel(uris, path) 
    4545        , _plugin_uri(plugin_uri) 
    4646        , _num_values(0) 
     
    207207NodeModel::port_value_range(SharedPtr<PortModel> port, float& min, float& max) const 
    208208{ 
    209         const Shared::LV2URIMap& uris = Shared::LV2URIMap::instance(); 
    210209        assert(port->parent().get() == this); 
    211210 
     
    213212 
    214213        // Possibly overriden 
    215         const Atom& min_atom = port->get_property(uris.lv2_minimum); 
    216         const Atom& max_atom = port->get_property(uris.lv2_maximum); 
     214        const Atom& min_atom = port->get_property(_uris.lv2_minimum); 
     215        const Atom& max_atom = port->get_property(_uris.lv2_maximum); 
    217216        if (min_atom.type() == Atom::FLOAT) 
    218217                min = min_atom.get_float(); 
  • trunk/ingen/src/client/NodeModel.hpp

    r2408 r2533  
    3333 
    3434namespace Ingen { 
     35 
     36namespace Shared { class LV2URIMap; } 
     37 
    3538namespace Client { 
    3639 
     
    7275        friend class ClientStore; 
    7376 
    74         NodeModel(const Raul::URI& plugin_uri, const Raul::Path& path); 
    75         NodeModel(SharedPtr<PluginModel> plugin, const Raul::Path& path); 
     77        NodeModel(Shared::LV2URIMap& uris, const Raul::URI& plugin_uri, const Raul::Path& path); 
     78        NodeModel(Shared::LV2URIMap& uris, SharedPtr<PluginModel> plugin, const Raul::Path& path); 
    7679 
    7780        NodeModel(const Raul::Path& path); 
     
    8790        virtual void clear(); 
    8891 
    89         Ports                  _ports;      ///< Vector of ports (not a Table to preserve order) 
    90         Raul::URI              _plugin_uri; ///< Plugin URI (if PluginModel is unknown) 
    91         SharedPtr<PluginModel> _plugin;     ///< The plugin this node is an instance of 
     92        Ports                        _ports;      ///< Vector of ports (not a Table to preserve order) 
     93        Raul::URI                    _plugin_uri; ///< Plugin URI (if PluginModel is unknown) 
     94        SharedPtr<PluginModel>       _plugin;     ///< The plugin this node is an instance of 
    9295 
    9396private: 
    94         mutable uint32_t       _num_values; ///< Size of _min_values and _max_values 
    95         mutable float*         _min_values; ///< Port min values (cached for LV2) 
    96         mutable float*         _max_values; ///< Port max values (cached for LV2) 
     97        mutable uint32_t _num_values; ///< Size of _min_values and _max_values 
     98        mutable float*   _min_values; ///< Port min values (cached for LV2) 
     99        mutable float*   _max_values; ///< Port max values (cached for LV2) 
    97100}; 
    98101 
  • trunk/ingen/src/client/ObjectModel.cpp

    r2514 r2533  
    2828 
    2929 
    30 ObjectModel::ObjectModel(const Path& path) 
    31         : ResourceImpl(path) 
    32         , _meta(ResourceImpl::meta_uri(path)) 
     30ObjectModel::ObjectModel(Shared::LV2URIMap& uris, const Raul::Path& path) 
     31        : ResourceImpl(uris, path) 
     32        , _meta(uris, ResourceImpl::meta_uri(path)) 
    3333        , _path(path) 
    3434        , _symbol((path == Path::root()) ? "root" : path.symbol()) 
     
    7777ObjectModel::polyphonic() const 
    7878{ 
    79         const Raul::Atom& polyphonic = get_property(Shared::LV2URIMap::instance().ingen_polyphonic); 
     79        const Raul::Atom& polyphonic = get_property(_uris.ingen_polyphonic); 
    8080        return (polyphonic.is_valid() && polyphonic.get_bool()); 
    8181} 
  • trunk/ingen/src/client/ObjectModel.hpp

    r2408 r2533  
    3232 
    3333namespace Ingen { 
     34 
     35namespace Shared { class LV2URIMap; } 
     36 
    3437namespace Client { 
    3538 
     
    8083        friend class ClientStore; 
    8184 
    82         ObjectModel(const Raul::Path& path); 
     85        ObjectModel(Shared::LV2URIMap& uris, const Raul::Path& path); 
    8386 
    8487        virtual void set_path(const Raul::Path& p); 
     
    9093 
    9194        ResourceImpl           _meta; 
    92  
    9395        SharedPtr<ObjectModel> _parent; 
    9496 
    9597private: 
    96         Raul::Path             _path; 
    97         Raul::Symbol           _symbol; 
     98        Raul::Path   _path; 
     99        Raul::Symbol _symbol; 
    98100}; 
    99101 
  • trunk/ingen/src/client/PatchModel.cpp

    r2491 r2533  
    161161PatchModel::enabled() const 
    162162{ 
    163         const Raul::Atom& enabled = get_property(Shared::LV2URIMap::instance().ingen_enabled); 
     163        const Raul::Atom& enabled = get_property(_uris.ingen_enabled); 
    164164        return (enabled.is_valid() && enabled.get_bool()); 
    165165} 
     
    169169PatchModel::internal_poly() const 
    170170{ 
    171         const Raul::Atom& poly = get_property(Shared::LV2URIMap::instance().ingen_polyphony); 
     171        const Raul::Atom& poly = get_property(_uris.ingen_polyphony); 
    172172        return poly.is_valid() ? poly.get_int32() : 1; 
    173173} 
     
    177177PatchModel::polyphonic() const 
    178178{ 
    179         const Raul::Atom& poly = get_property(Shared::LV2URIMap::instance().ingen_polyphonic); 
     179        const Raul::Atom& poly = get_property(_uris.ingen_polyphonic); 
    180180        return poly.is_valid() && poly.get_bool(); 
    181181} 
  • trunk/ingen/src/client/PatchModel.hpp

    r2491 r2533  
    7777        friend class ClientStore; 
    7878 
    79         PatchModel(const Raul::Path& patch_path) 
    80                 : NodeModel("http://drobilla.net/ns/ingen#Patch", patch_path) 
     79        PatchModel(Shared::LV2URIMap& uris, const Raul::Path& patch_path) 
     80                : NodeModel(uris, "http://drobilla.net/ns/ingen#Patch", patch_path) 
    8181                , _connections(new Connections()) 
    8282                , _editable(true) 
  • trunk/ingen/src/client/PluginModel.cpp

    r2420 r2533  
    4141 
    4242 
    43 PluginModel::PluginModel(const URI& uri, const URI& type_uri, const Resource::Properties& properties) 
    44         : ResourceImpl(uri) 
     43PluginModel::PluginModel(Shared::LV2URIMap& uris, 
     44                const URI& uri, const URI& type_uri, const Resource::Properties& properties) 
     45        : ResourceImpl(uris, uri) 
    4546        , _type(type_from_uri(type_uri.str())) 
    4647{ 
     
    7071 
    7172        // No lv2:symbol from data or engine, invent one 
    72         if (key == Shared::LV2URIMap::instance().lv2_symbol) { 
     73        if (key == _uris.lv2_symbol) { 
    7374                const URI& uri = this->uri(); 
    7475                size_t last_slash = uri.find_last_of('/'); 
  • trunk/ingen/src/client/PluginModel.hpp

    r2398 r2533  
    3131 
    3232namespace Ingen { 
     33 
     34namespace Shared { class LV2URIMap; } 
     35 
    3336namespace Client { 
    3437 
     
    4750public: 
    4851        PluginModel( 
     52                        Shared::LV2URIMap&                  uris, 
    4953                        const Raul::URI&                    uri, 
    5054                        const Raul::URI&                    type_uri, 
  • trunk/ingen/src/client/PluginUI.cpp

    r2492 r2533  
    5656        SharedPtr<PortModel> port = ui->node()->ports()[port_index]; 
    5757 
    58         SharedPtr<Shared::LV2URIMap> map = ui->world()->uris; 
     58        const Shared::LV2URIMap& uris = *ui->world()->uris().get(); 
    5959 
    6060        // float (special case, always 0) 
     
    6464                        return; // do nothing (handle stupid plugin UIs that feed back) 
    6565 
    66                 ui->world()->engine->set_property(port->path(), map->ingen_value, Atom(*(float*)buffer)); 
     66                ui->world()->engine()->set_property(port->path(), uris.ingen_value, Atom(*(float*)buffer)); 
    6767 
    68         } else if (format == map->ui_format_events.id) { 
     68        } else if (format == uris.ui_format_events.id) { 
    6969                LV2_Event_Buffer*  buf = (LV2_Event_Buffer*)buffer; 
    7070                LV2_Event_Iterator iter; 
     
    7373                while (lv2_event_is_valid(&iter)) { 
    7474                        LV2_Event* const ev = lv2_event_get(&iter, &data); 
    75                         if (ev->type == map->midi_event.id) { 
     75                        if (ev->type == uris.midi_event.id) { 
    7676                                // FIXME: bundle multiple events by writing an entire buffer here 
    77                                 ui->world()->engine->set_property(port->path(), map->ingen_value, 
     77                                ui->world()->engine()->set_property(port->path(), uris.ingen_value, 
    7878                                        Atom("http://lv2plug.in/ns/ext/midi#MidiEvent", ev->size, data)); 
    7979                        } else { 
     
    8585                } 
    8686 
    87         } else if (format == map->object_transfer.id) { 
     87        } else if (format == uris.object_transfer.id) { 
    8888                LV2_Object* buf = (LV2_Object*)buffer; 
    8989                Raul::Atom val; 
    90                 Shared::LV2Object::to_atom(buf, val); 
    91                 ui->world()->engine->set_property(port->path(), map->ingen_value, val); 
     90                Shared::LV2Object::to_atom(uris, buf, val); 
     91                ui->world()->engine()->set_property(port->path(), uris.ingen_value, val); 
    9292 
    9393        } else { 
     
    123123        SharedPtr<PluginUI> ret; 
    124124 
    125         SLV2Value gtk_gui_uri = slv2_value_new_uri(world->slv2_world, 
     125        SLV2Value gtk_gui_uri = slv2_value_new_uri(world->slv2_world(), 
    126126                "http://lv2plug.in/ns/extensions/ui#GtkUI"); 
    127127 
     
    142142                info << "Found GTK Plugin UI: " << slv2_ui_get_uri(ui) << endl; 
    143143                ret = SharedPtr<PluginUI>(new PluginUI(world, node)); 
    144                 ret->_features = world->lv2_features->lv2_features(node.get()); 
     144                ret->_features = world->lv2_features()->lv2_features(node.get()); 
    145145                SLV2UIInstance inst = slv2_ui_instantiate( 
    146146                                plugin, ui, lv2_ui_write, ret.get(), ret->_features->array()); 
  • trunk/ingen/src/client/PortModel.cpp

    r2492 r2533  
    2929{ 
    3030        Raul::Atom& ret = ObjectModel::set_property(uri, value); 
    31         if (uri == Shared::LV2URIMap::instance().ingen_value) 
     31        if (uri == _uris.ingen_value) 
    3232                this->value(value); 
    3333        return ret; 
     
    3838PortModel::supports(const Raul::URI& value_type) const 
    3939{ 
    40         return has_property(Shared::LV2URIMap::instance().obj_supports, value_type); 
     40        return has_property(_uris.obj_supports, value_type); 
    4141} 
    4242 
     
    4545PortModel::port_property(const std::string& uri) const 
    4646{ 
    47         return has_property(Shared::LV2URIMap::instance().lv2_portProperty, Raul::URI(uri)); 
     47        return has_property(_uris.lv2_portProperty, Raul::URI(uri)); 
    4848} 
    4949 
     
    6666 
    6767 
     68bool 
     69PortModel::has_context(const Raul::URI& uri) 
     70{ 
     71        const Raul::Atom& context = get_property(_uris.ctx_context); 
     72        if (uri == _uris.ctx_AudioContext && !context.is_valid()) 
     73                return true; 
     74        else 
     75                return context == uri; 
     76} 
     77 
     78 
    6879} // namespace Client 
    6980} // namespace Ingen 
  • trunk/ingen/src/client/PortModel.hpp

    r2492 r2533  
    5959        bool is_toggle()      const { return port_property("http://lv2plug.in/ns/lv2core#toggled"); } 
    6060 
     61        bool has_context(const Raul::URI& context); 
     62 
    6163        inline bool operator==(const PortModel& pm) const { return (path() == pm.path()); } 
    6264 
     
    8587        friend class ClientStore; 
    8688 
    87         PortModel(const Raul::Path& path, uint32_t index, Shared::PortType type, Direction dir) 
    88                 : ObjectModel(path) 
     89        PortModel(Shared::LV2URIMap& uris, 
     90                        const Raul::Path& path, uint32_t index, Shared::PortType type, Direction dir) 
     91                : ObjectModel(uris, path) 
    8992                , _index(index) 
    9093                , _direction(dir) 
  • trunk/ingen/src/common/interface/Node.hpp

    r2468 r2533  
    2222#include "GraphObject.hpp" 
    2323 
    24 #include <iostream> 
    2524namespace Ingen { 
    2625namespace Shared { 
  • trunk/ingen/src/engine/BufferFactory.cpp

    r2468 r2533  
    3333using namespace Shared; 
    3434 
    35 BufferFactory::BufferFactory(Engine& engine, SharedPtr<Shared::LV2URIMap> map) 
     35BufferFactory::BufferFactory(Engine& engine, SharedPtr<Shared::LV2URIMap> a_uris) 
    3636        : _engine(engine) 
    37         , _map(map) 
     37        , _uris(a_uris) 
    3838        , _silent_buffer(NULL) 
    3939{ 
     40        assert(_uris); 
     41} 
     42 
     43 
     44BufferFactory::~BufferFactory() 
     45{ 
     46        free_list(_free_audio.get()); 
     47        free_list(_free_control.get()); 
     48        free_list(_free_event.get()); 
     49        free_list(_free_object.get()); 
     50} 
     51 
     52 
     53void 
     54BufferFactory::free_list(Buffer* head) 
     55{ 
     56        Buffer* next = head->_next; 
     57        delete head; 
     58        if (next) 
     59                free_list(next); 
    4060} 
    4161 
     
    88108 
    89109        if (!try_head) { 
    90                 if (ThreadManager::current_thread_id() != THREAD_PROCESS) { 
     110                if (!ThreadManager::thread_is(THREAD_PROCESS)) { 
    91111                        return create(type, size); 
    92112                } else { 
     
    114134        if (type.is_control()) { 
    115135                AudioBuffer* ret = new AudioBuffer(*this, type, size); 
    116                 ret->object()->type = _map->object_class_vector.id; 
    117                 ((LV2_Vector_Body*)ret->object()->body)->elem_type = _map->object_class_float32.id; 
     136                ret->object()->type = _uris->object_class_vector.id; 
     137                ((LV2_Vector_Body*)ret->object()->body)->elem_type = _uris->object_class_float32.id; 
    118138                buffer = ret; 
    119139        } else if (type.is_audio()) { 
    120140                AudioBuffer* ret = new AudioBuffer(*this, type, size); 
    121                 ret->object()->type = _map->object_class_float32.id; 
     141                ret->object()->type = _uris->object_class_float32.id; 
    122142                buffer = ret; 
    123143        } else if (type.is_events()) { 
  • trunk/ingen/src/engine/BufferFactory.hpp

    r2468 r2533  
    3838class BufferFactory { 
    3939public: 
    40         BufferFactory(Engine& engine, SharedPtr<Shared::LV2URIMap> map); 
     40        BufferFactory(Engine& engine, SharedPtr<Shared::LV2URIMap> uris); 
     41        ~BufferFactory(); 
    4142 
    4243        typedef boost::intrusive_ptr<Buffer> Ref; 
     
    5051 
    5152        void set_block_length(SampleCount block_length); 
     53 
     54        Shared::LV2URIMap& uris() { assert(_uris); return *_uris.get(); } 
    5255 
    5356private: 
     
    6871        } 
    6972 
     73        void free_list(Buffer* head); 
     74 
    7075        Raul::AtomicPtr<Buffer> _free_audio; 
    7176        Raul::AtomicPtr<Buffer> _free_control; 
     
    7580        Glib::Mutex                  _mutex; 
    7681        Engine&                      _engine; 
    77         SharedPtr<Shared::LV2URIMap> _map; 
     82        SharedPtr<Shared::LV2URIMap> _uris; 
    7883 
    7984        Ref _silent_buffer; 
  • trunk/ingen/src/engine/ClientBroadcaster.hpp

    r2445 r2533  
    2727#include "NodeFactory.hpp" 
    2828 
    29 #include <iostream> 
    3029using namespace std; 
    3130 
  • trunk/ingen/src/engine/ConnectionImpl.cpp

    r2495 r2533  
    128128ConnectionImpl::can_connect(const OutputPort* src, const InputPort* dst) 
    129129{ 
    130         const LV2URIMap& uris = Shared::LV2URIMap::instance(); 
     130        const LV2URIMap& uris = src->bufs().uris(); 
    131131        return ( 
    132132                        (   (src->is_a(PortType::CONTROL) || src->is_a(PortType::AUDIO)) 
  • trunk/ingen/src/engine/Context.hpp

    r2487 r2533  
    2121#include "EventSink.hpp" 
    2222#include "tuning.hpp" 
     23#include "types.hpp" 
    2324 
    2425namespace Ingen { 
  • trunk/ingen/src/engine/ControlBindings.cpp

    r2485 r2533  
    1919#include "raul/log.hpp" 
    2020#include "raul/midi_events.h" 
     21#include "shared/LV2URIMap.hpp" 
     22#include "module/World.hpp" 
    2123#include "events/SendPortValue.hpp" 
    2224#include "events/SendBinding.hpp" 
     
    3739 
    3840 
    39 ControlBindings::ControlBindings(Engine& engine, SharedPtr<Shared::LV2URIMap> map) 
     41ControlBindings::ControlBindings(Engine& engine) 
    4042        : _engine(engine) 
    41         , _map(map) 
    4243        , _learn_port(NULL) 
    4344        , _bindings(new Bindings()) 
     
    5657ControlBindings::port_binding(PortImpl* port) 
    5758{ 
    58         const Shared::LV2URIMap& uris    = Shared::LV2URIMap::instance(); 
    59         const Raul::Atom&        binding = port->get_property(uris.ingen_controlBinding); 
     59        const Shared::LV2URIMap& uris = *_engine.world()->uris().get(); 
     60        const Raul::Atom& binding = port->get_property(uris.ingen_controlBinding); 
    6061        Key key; 
    6162        if (binding.type() == Atom::DICT) { 
     
    115116ControlBindings::port_value_changed(ProcessContext& context, PortImpl* port) 
    116117{ 
     118        const Shared::LV2URIMap& uris = *_engine.world()->uris().get(); 
    117119        Key key = port_binding(port); 
    118120        if (key) { 
     
    151153                } 
    152154                if (size > 0) 
    153                         _feedback->append(0, 0, _map->midi_event.id, size, buf); 
     155                        _feedback->append(0, 0, uris.midi_event.id, size, buf); 
    154156        } 
    155157} 
     
    167169ControlBindings::control_to_port_value(PortImpl* port, Type type, int16_t value) 
    168170{ 
    169         const Shared::LV2URIMap& uris = Shared::LV2URIMap::instance(); 
     171        const Shared::LV2URIMap& uris = *_engine.world()->uris().get(); 
    170172 
    171173        // TODO: cache these to avoid the lookup 
     
    204206                return 0; 
    205207 
    206         const Shared::LV2URIMap& uris = Shared::LV2URIMap::instance(); 
     208        const Shared::LV2URIMap& uris = *_engine.world()->uris().get(); 
    207209 
    208210        // TODO: cache these to avoid the lookup 
     
    260262ControlBindings::bind(ProcessContext& context, Key key) 
    261263{ 
    262         const Shared::LV2URIMap& uris = Shared::LV2URIMap::instance(); 
     264        const Shared::LV2URIMap& uris = *context.engine().world()->uris().get(); 
    263265        assert(_learn_port); 
    264266        if (key.type == MIDI_NOTE) { 
     
    337339        _feedback->clear(); 
    338340 
     341        const Shared::LV2URIMap& uris = *context.engine().world()->uris().get(); 
     342 
    339343        // Learn from input if necessary 
    340344        if (_learn_port) { 
     
    342346                                buffer->get_event(&frames, &subframes, &type, &size, &buf); 
    343347                                buffer->increment()) { 
    344                         if (type != _map->midi_event.id) 
     348                        if (type != uris.midi_event.id) 
    345349                                continue; 
    346350 
     
    359363                        buffer->get_event(&frames, &subframes, &type, &size, &buf); 
    360364                        buffer->increment()) { 
    361                 if (type != _map->midi_event.id) 
     365                if (type != uris.midi_event.id) 
    362366                        continue; 
    363367 
  • trunk/ingen/src/engine/ControlBindings.hpp

    r2442 r2533  
    5757        typedef std::map<Key, PortImpl*> Bindings; 
    5858 
    59         ControlBindings(Engine& engine, SharedPtr<Shared::LV2URIMap> map); 
     59        ControlBindings(Engine& engine); 
    6060        ~ControlBindings(); 
    6161 
     
    8989        int16_t    port_value_to_control(PortImpl* port, Type type); 
    9090 
    91         Engine&                      _engine; 
    92         SharedPtr<Shared::LV2URIMap> _map; 
    93         PortImpl*                    _learn_port; 
     91        Engine&   _engine; 
     92        PortImpl* _learn_port; 
    9493 
    9594        SharedPtr<Bindings> _bindings; 
  • trunk/ingen/src/engine/Driver.hpp

    r2468 r2533  
    7878 
    7979        /** Activate driver (begin processing graph and events). */ 
    80         virtual void activate()   = 0; 
     80        virtual void activate() {} 
    8181 
    8282        /** Deactivate driver (stop processing graph and events). */ 
    83         virtual void deactivate() = 0; 
     83        virtual void deactivate() {} 
    8484 
    8585        /** Return true iff driver is activated (processing graph and events). */ 
    86         virtual bool is_activated() const = 0; 
     86        virtual bool is_activated() const { return true; } 
    8787 
    8888        /** Create a port ready to be inserted with add_input (non realtime). 
     
    9898 
    9999        /** Remove a system visible port. */ 
    100         virtual Raul::List<DriverPort*>::Node* remove_port(const Raul::Path& path) = 0; 
     100        virtual Raul::Deletable* remove_port(const Raul::Path& path, Ingen::DriverPort** port=NULL) = 0; 
    101101 
    102102        /** Return true iff this driver supports the given type of I/O */ 
  • trunk/ingen/src/engine/DuplexPort.cpp

    r2494 r2533  
    5151{ 
    5252        assert(PortImpl::_parent == parent); 
    53         set_property(Shared::LV2URIMap::instance().ingen_polyphonic, polyphonic); 
     53        set_property(bufs.uris().ingen_polyphonic, polyphonic); 
    5454} 
    5555 
  • trunk/ingen/src/engine/Engine.cpp

    r2496 r2533  
    5959bool ThreadManager::single_threaded = true; 
    6060 
    61 Engine::Engine(Ingen::Shared::World* world) 
    62         : _world(world) 
     61Engine::Engine(Ingen::Shared::World* a_world) 
     62        : _world(a_world) 
    6363        , _maid(new Raul::Maid(maid_queue_size)) 
    6464        , _post_processor(new PostProcessor(*this, post_processor_queue_size)) 
    6565        , _broadcaster(new ClientBroadcaster()) 
    66         , _node_factory(new NodeFactory(world)) 
     66        , _node_factory(new NodeFactory(a_world)) 
    6767        , _message_context(new MessageContext(*this)) 
    68         , _buffer_factory(new BufferFactory(*this, world->uris)) 
    69         , _control_bindings(new ControlBindings(*this, world->uris)) 
     68        , _buffer_factory(new BufferFactory(*this, a_world->uris())) 
     69        //, _buffer_factory(NULL) 
     70        , _control_bindings(new ControlBindings(*this)) 
    7071        , _quit_flag(false) 
    7172        , _activated(false) 
    7273{ 
    73         if (world->store) { 
    74                 assert(PtrCast<EngineStore>(world->store)); 
     74        if (a_world->store()) { 
     75                assert(PtrCast<EngineStore>(a_world->store())); 
    7576        } else { 
    76                 world->store = SharedPtr<Shared::Store>(new EngineStore()); 
     77                a_world->set_store(SharedPtr<Shared::Store>(new EngineStore())); 
    7778        } 
    7879} 
     
    102103Engine::engine_store() const 
    103104{ 
    104          return PtrCast<EngineStore>(_world->store); 
     105         return PtrCast<EngineStore>(_world->store()); 
    105106} 
    106107 
     
    138139 
    139140 
    140 Ingen::QueuedEngineInterface* 
    141 Engine::new_local_interface() 
    142 { 
    143         return new Ingen::QueuedEngineInterface(*this, Ingen::event_queue_size); 
    144 } 
    145  
    146  
    147141void 
    148142Engine::add_event_source(SharedPtr<EventSource> source) 
     
    165159Engine::activate() 
    166160{ 
     161        if (_activated) 
     162                return true; 
     163 
    167164        assert(_driver); 
     165        //assert(ThreadManager::single_threaded == true); 
     166        ThreadManager::single_threaded = true; 
    168167 
    169168        _buffer_factory->set_block_length(_driver->block_length()); 
     
    171170        _message_context->Thread::start(); 
    172171 
    173         uint32_t parallelism = _world->conf->option("parallelism").get_int32(); 
     172        uint32_t parallelism = _world->conf()->option("parallelism").get_int32(); 
    174173 
    175174        for (EventSources::iterator i = _event_sources.begin(); i != _event_sources.end(); ++i) 
    176175                (*i)->activate_source(); 
    177176 
    178         const LV2URIMap& uris = *world()->uris; 
     177        const LV2URIMap& uris = *world()->uris().get(); 
    179178 
    180179        // Create root patch 
     
    186185                root_patch->set_property(uris.rdf_type, uris.ingen_Node); 
    187186                root_patch->activate(*_buffer_factory); 
    188                 _world->store->add(root_patch); 
     187                _world->store()->add(root_patch); 
    189188                root_patch->compiled_patch(root_patch->compile()); 
    190189                _driver->set_root_patch(root_patch); 
  • trunk/ingen/src/engine/Engine.hpp

    r2409 r2533  
    6262 * \ingroup engine 
    6363 */ 
    64 class Engine : boost::noncopyable 
     64class Engine : public boost::noncopyable 
    6565{ 
    6666public: 
     
    7979        virtual void deactivate(); 
    8080 
    81         void process_events(ProcessContext& context); 
     81        virtual void process_events(ProcessContext& context); 
    8282 
    8383        virtual bool activated() { return _activated; } 
    8484 
    85         BufferFactory*     buffer_factory()   const { return _buffer_factory; } 
    86         ClientBroadcaster* broadcaster()      const { return _broadcaster; } 
    87         ControlBindings*   control_bindings() const { return _control_bindings; } 
    88         Driver*            driver()           const { return _driver.get(); } 
    89         MessageContext*    message_context()  const { return _message_context; } 
    90         NodeFactory*       node_factory()     const { return _node_factory; } 
    91         PostProcessor*     post_processor()   const { return _post_processor; } 
    92         Raul::Maid*        maid()             const { return _maid; } 
     85        virtual BufferFactory*     buffer_factory()   const { return _buffer_factory; } 
     86        virtual ClientBroadcaster* broadcaster()      const { return _broadcaster; } 
     87        virtual ControlBindings*   control_bindings() const { return _control_bindings; } 
     88        virtual Driver*            driver()           const { return _driver.get(); } 
     89        virtual MessageContext*    message_context()  const { return _message_context; } 
     90        virtual NodeFactory*       node_factory()     const { return _node_factory; } 
     91        virtual PostProcessor*     post_processor()   const { return _post_processor; } 
     92        virtual Raul::Maid*        maid()             const { return _maid; } 
    9393 
    94         SharedPtr<EngineStore> engine_store() const; 
     94        virtual SharedPtr<EngineStore> engine_store() const; 
    9595 
    9696        virtual void set_driver(SharedPtr<Driver> driver) { _driver = driver; } 
     
    9898        virtual void add_event_source(SharedPtr<EventSource> source); 
    9999 
    100         Ingen::QueuedEngineInterface* new_local_interface(); 
    101  
    102         Ingen::Shared::World* world() { return _world; } 
     100        virtual Ingen::Shared::World* world() { return _world; } 
    103101 
    104102        typedef std::vector<ProcessSlave*> ProcessSlaves; 
    105         inline const ProcessSlaves& process_slaves() const { return _process_slaves; } 
    106         inline ProcessSlaves& process_slaves() { return _process_slaves; } 
     103        virtual const ProcessSlaves& process_slaves() const { return _process_slaves; } 
     104        virtual ProcessSlaves& process_slaves() { return _process_slaves; } 
    107105 
    108106private: 
  • trunk/ingen/src/engine/EventSource.cpp

    r2391 r2533  
    3232{ 
    3333        Thread::set_context(THREAD_PRE_PROCESS); 
    34         assert(context() == THREAD_PRE_PROCESS); 
    3534        set_name("EventSource"); 
    3635} 
  • trunk/ingen/src/engine/events/CreateNode.cpp

    r2509 r2533  
    8282        } 
    8383 
    84         const LV2URIMap& uris = Shared::LV2URIMap::instance(); 
    85         const Resource::Properties::const_iterator p = properties.find(uris.ingen_polyphonic); 
     84        const Resource::Properties::const_iterator p = properties.find( 
     85                        engine.world()->uris()->ingen_polyphonic); 
    8686        if (p != properties.end() && p->second.type() == Raul::Atom::BOOL 
    8787                        && p->second.get_bool()) 
  • trunk/ingen/src/engine/events/CreatePatch.cpp

    r2479 r2533  
    8484                poly = _poly; 
    8585 
    86         const LV2URIMap& uris = *_engine.world()->uris.get(); 
     86        const LV2URIMap& uris = *_engine.world()->uris().get(); 
    8787 
    8888        _patch = new PatchImpl(_engine, path.symbol(), poly, _parent, 
  • trunk/ingen/src/engine/events/CreatePort.cpp

    r2510 r2533  
    8585        _patch = _engine.engine_store()->find_patch(_path.parent()); 
    8686 
    87         const LV2URIMap& uris = *_engine.world()->uris.get(); 
     87        const LV2URIMap& uris = *_engine.world()->uris().get(); 
    8888 
    8989        if (_patch != NULL) { 
  • trunk/ingen/src/engine/events/Delete.cpp

    r2486 r2533  
    4343        , _path(path) 
    4444        , _store_iterator(engine.engine_store()->end()) 
     45        , _garbage(NULL) 
    4546        , _driver_port(NULL) 
    4647        , _patch_node_listnode(NULL) 
     
    154155                _port->parent_patch()->external_ports(_ports_array); 
    155156 
    156                 if ( ! _port->parent_patch()->parent()) { 
    157                         _driver_port = _engine.driver()->remove_port(_port->path()); 
    158                 } 
     157                if ( ! _port->parent_patch()->parent()) 
     158                        _garbage = _engine.driver()->remove_port(_port->path(), &_driver_port); 
    159159        } 
    160160 
     
    202202        } 
    203203 
    204         if (_driver_port) { 
    205                 _driver_port->elem()->destroy(); 
    206                 _engine.maid()->push(_driver_port); 
    207         } 
     204        if (_driver_port) 
     205                _driver_port->destroy(); 
     206 
     207        _engine.maid()->push(_garbage); 
    208208} 
    209209 
  • trunk/ingen/src/engine/events/Delete.hpp

    r2417 r2533  
    7676        SharedPtr<NodeImpl>            _node;                ///< Non-NULL iff a node 
    7777        SharedPtr<PortImpl>            _port;                ///< Non-NULL iff a port 
    78         Raul::List<DriverPort*>::Node* _driver_port; 
     78        Raul::Deletable*               _garbage; 
     79        DriverPort*                    _driver_port; 
    7980        PatchImpl::Nodes::Node*        _patch_node_listnode; 
    8081        Raul::List<PortImpl*>::Node*   _patch_port_listnode; 
  • trunk/ingen/src/engine/events/RequestMetadata.cpp

    r2514 r2533  
    7575        GraphObjectImpl* obj = dynamic_cast<GraphObjectImpl*>(_resource); 
    7676        if (obj) { 
    77                 if (_key == _engine.world()->uris->ingen_value) 
     77                if (_key == _engine.world()->uris()->ingen_value) 
    7878                        _special_type = PORT_VALUE; 
    7979                else if (_is_meta) 
     
    102102                                IntrusivePtr<ObjectBuffer> obuf = PtrCast<ObjectBuffer>(port->buffer(0)); 
    103103                                if (obuf) { 
    104                                         LV2Object::to_atom(obuf->object(), _value); 
     104                                        LV2Object::to_atom(*_engine.world()->uris().get(), obuf->object(), _value); 
    105105                                } 
    106106                        } 
     
    120120                                _request->respond_ok(); 
    121121                                _request->client()->set_property(_uri.str(), 
    122                                                 _engine.world()->uris->ingen_value, _value); 
     122                                                _engine.world()->uris()->ingen_value, _value); 
    123123                        } else { 
    124124                                const string msg = "Get value for non-port " + _uri.str(); 
  • trunk/ingen/src/engine/events/SendBinding.cpp

    r2412 r2533  
    3232SendBinding::post_process() 
    3333{ 
    34         const LV2URIMap& uris = *_engine.world()->uris.get(); 
     34        const LV2URIMap& uris = *_engine.world()->uris().get(); 
    3535        Raul::Atom::DictValue dict; 
    3636        if (_type == ControlBindings::MIDI_CC) { 
  • trunk/ingen/src/engine/events/SendPortValue.cpp

    r2445 r2533  
    3434        _engine.broadcaster()->set_property( 
    3535                        _port->path(), 
    36                         _engine.world()->uris->ingen_value, _value); 
     36                        _engine.world()->uris()->ingen_value, _value); 
    3737} 
    3838 
  • trunk/ingen/src/engine/events/SetMetadata.cpp

    r2514 r2533  
    112112        } 
    113113 
    114         const LV2URIMap& uris = *_engine.world()->uris.get(); 
     114        const LV2URIMap& uris = *_engine.world()->uris().get(); 
    115115 
    116116        if (is_graph_object && !_object) { 
     
    118118                bool is_patch = false, is_node = false, is_port = false, is_output = false; 
    119119                PortType data_type(PortType::UNKNOWN); 
    120                 ResourceImpl::type(_properties, is_patch, is_node, is_port, is_output, data_type); 
     120                ResourceImpl::type(uris, _properties, is_patch, is_node, is_port, is_output, data_type); 
    121121 
    122122                // Create a separate request without a source so EventSource isn't unblocked twice 
  • trunk/ingen/src/engine/events/SetPortValue.cpp

    r2492 r2533  
    103103        if (_port) { 
    104104                _port->set_value(_value); 
    105                 _port->set_property(_engine.world()->uris->ingen_value, _value); 
     105                _port->set_property(_engine.world()->uris()->ingen_value, _value); 
    106106        } 
    107107 
     
    152152                } 
    153153 
    154                 SharedPtr<LV2URIMap> uris = _engine.world()->uris; 
     154                LV2URIMap& uris = *_engine.world()->uris().get(); 
    155155 
    156156                EventBuffer* const ebuf = dynamic_cast<EventBuffer*>(buf); 
     
    160160                        // Size 0 event, pass it along to the plugin as a typed but empty event 
    161161                        if (_value.data_size() == 0) { 
    162                                 const uint32_t type_id = uris->uri_to_id(NULL, _value.get_blob_type()); 
     162                                const uint32_t type_id = uris.uri_to_id(NULL, _value.get_blob_type()); 
    163163                                ebuf->append(frames, 0, type_id, 0, NULL); 
    164164                                _port->raise_set_by_user_flag(); 
     
    167167                        } else if (!strcmp(_value.get_blob_type(), "http://lv2plug.in/ns/ext/midi#MidiEvent")) { 
    168168                                ebuf->prepare_write(context); 
    169                                 ebuf->append(frames, 0, uris->midi_event.id, _value.data_size(), 
     169                                ebuf->append(frames, 0, uris.midi_event.id, _value.data_size(), 
    170170                                                (const uint8_t*)_value.get_blob()); 
    171171                                _port->raise_set_by_user_flag(); 
     
    177177                if (obuf) { 
    178178                        obuf->object()->size = obuf->size() - sizeof(LV2_Object); 
    179                         if (LV2Object::from_atom(_value, obuf->object())) { 
     179                        if (LV2Object::from_atom(uris, _value, obuf->object())) { 
    180180                                debug << "Converted atom " << _value << " :: " << obuf->object()->type 
    181181                                        << " * " << obuf->object()->size << " @ " << obuf->object() << endl; 
     
    201201                _request->respond_ok(); 
    202202                _engine.broadcaster()->set_property(_port_path, 
    203                                 _engine.world()->uris->ingen_value, _value); 
     203                                _engine.world()->uris()->ingen_value, _value); 
    204204                break; 
    205205        case TYPE_MISMATCH: 
  • trunk/ingen/src/engine/GraphObjectImpl.cpp

    r2514 r2533  
    2929 
    3030 
    31 GraphObjectImpl::GraphObjectImpl(GraphObjectImpl* parent, const Symbol& symbol) 
    32         : ResourceImpl(parent ? parent->path().child(symbol) : Raul::Path::root()) 
     31GraphObjectImpl::GraphObjectImpl(Shared::LV2URIMap& uris, 
     32                GraphObjectImpl* parent, const Symbol& symbol) 
     33        : ResourceImpl(uris, parent ? parent->path().child(symbol) : Raul::Path::root()) 
    3334        , _parent(parent) 
    3435        , _path(parent ? parent->path().child(symbol) : "/") 
    3536        , _symbol(symbol) 
    36         , _meta(ResourceImpl::meta_uri(uri())) 
     37        , _meta(uris, ResourceImpl::meta_uri(uri())) 
    3738{ 
    3839} 
  • trunk/ingen/src/engine/GraphObjectImpl.hpp

    r2468 r2533  
    3232 
    3333namespace Ingen { 
     34 
     35namespace Shared { class LV2URIMap; } 
    3436 
    3537class PatchImpl; 
     
    99101 
    100102protected: 
    101         GraphObjectImpl(GraphObjectImpl* parent, const Raul::Symbol& symbol); 
     103        GraphObjectImpl(Shared::LV2URIMap& uris, 
     104                        GraphObjectImpl* parent, const Raul::Symbol& symbol); 
    102105 
    103106        GraphObjectImpl* _parent; 
  • trunk/ingen/src/engine/HTTPClientSender.cpp

    r2445 r2533  
    6060        const string full_uri = _url + "/" + path; 
    6161 
    62         Redland::Model model(*_engine.world()->rdf_world); 
     62        Redland::Model model(*_engine.world()->rdf_world()); 
    6363        for (Resource::Properties::const_iterator i = properties.begin(); i != properties.end(); ++i) 
    6464                model.add_statement( 
    65                                 Redland::Resource(*_engine.world()->rdf_world, path), 
     65                                Redland::Resource(*_engine.world()->rdf_world(), path), 
    6666                                i->first.str(), 
    6767                                AtomRDF::atom_to_node(model, i->second)); 
     
    112112{ 
    113113#if 0 
    114         Redland::Node node = AtomRDF::atom_to_node(*_engine.world()->rdf_world, value); 
     114        Redland::Node node = AtomRDF::atom_to_node(*_engine.world()->rdf_world(), value); 
    115115        const string msg = string( 
    116116                        "@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .\n" 
  • trunk/ingen/src/engine/HTTPEngineReceiver.cpp

    r2514 r2533  
    5656        LOG(info) << "Started HTTP server on port " << soup_server_get_port(_server) << endl; 
    5757 
    58         if (!engine.world()->parser || !engine.world()->serialiser) 
     58        if (!engine.world()->parser() || !engine.world()->serialiser()) 
    5959                engine.world()->load("ingen_serialisation"); 
    6060 
     
    100100        HTTPEngineReceiver* me = (HTTPEngineReceiver*)data; 
    101101 
    102         SharedPtr<Store> store = me->_engine.world()->store; 
     102        SharedPtr<Store> store = me->_engine.world()->store(); 
    103103        if (!store) { 
    104104                soup_message_set_status (msg, SOUP_STATUS_INTERNAL_SERVER_ERROR); 
     
    111111        } 
    112112 
    113         SharedPtr<Serialiser> serialiser = me->_engine.world()->serialiser; 
     113        SharedPtr<Serialiser> serialiser = me->_engine.world()->serialiser(); 
    114114 
    115115        const string base_uri = "path:/"; 
     
    181181 
    182182                // Get serialiser 
    183                 SharedPtr<Serialiser> serialiser = me->_engine.world()->serialiser; 
     183                SharedPtr<Serialiser> serialiser = me->_engine.world()->serialiser(); 
    184184                if (!serialiser) { 
    185185                        soup_message_set_status(msg, SOUP_STATUS_INTERNAL_SERVER_ERROR); 
     
    201201 
    202202                // Get parser 
    203                 SharedPtr<Parser> parser = me->_engine.world()->parser; 
     203                SharedPtr<Parser> parser = me->_engine.world()->parser(); 
    204204                if (!parser) { 
    205205                        soup_message_set_status(msg, SOUP_STATUS_INTERNAL_SERVER_ERROR); 
  • trunk/ingen/src/engine/InputPort.cpp

    r2495 r2533  
    5050        , _num_connections(0) 
    5151{ 
    52         const LV2URIMap& uris = Shared::LV2URIMap::instance(); 
     52        const LV2URIMap& uris = bufs.uris(); 
    5353 
    5454        if (!dynamic_cast<Patch*>(parent)) 
     
    8282InputPort::get_buffers(BufferFactory& bufs, Raul::Array<BufferFactory::Ref>* buffers, uint32_t poly) 
    8383{ 
    84         size_t num_connections = (ThreadManager::current_thread_id() == THREAD_PROCESS) 
     84        size_t num_connections = (ThreadManager::thread_is(THREAD_PROCESS)) 
    8585                        ? _connections.size() : _num_connections; 
    8686 
     
    9292 
    9393        } else if (num_connections == 1) { 
    94                 if (ThreadManager::current_thread_id() == THREAD_PROCESS) { 
     94                if (ThreadManager::thread_is(THREAD_PROCESS)) { 
    9595                        if (!_connections.front()->must_mix() && !_connections.front()->must_queue()) { 
    9696                                // Single non-mixing conneciton, use buffers directly 
  • trunk/ingen/src/engine/InternalPlugin.cpp

    r2485 r2533  
    3333using namespace Internals; 
    3434 
    35 InternalPlugin::InternalPlugin(const std::string& uri, const std::string& symbol) 
    36         : PluginImpl(Plugin::Internal, uri) 
     35InternalPlugin::InternalPlugin(Shared::LV2URIMap& uris, 
     36                const std::string& uri, const std::string& symbol) 
     37        : PluginImpl(uris, Plugin::Internal, uri) 
    3738        , _symbol(symbol) 
    3839{ 
    39         const LV2URIMap& uris = Shared::LV2URIMap::instance(); 
    4040        set_property(uris.rdf_type, uris.ingen_Internal); 
    4141} 
     
    5454 
    5555        const string uri_str = uri().str(); 
     56 
    5657        if (uri_str == NS_INTERNALS "Controller") { 
    57                 return new ControllerNode(bufs, name, polyphonic, parent, srate); 
     58                return new ControllerNode(this, bufs, name, polyphonic, parent, srate); 
    5859        } else if (uri_str == NS_INTERNALS "Delay") { 
    59                 return new DelayNode(bufs, name, polyphonic, parent, srate); 
     60                return new DelayNode(this, bufs, name, polyphonic, parent, srate); 
    6061        } else if (uri_str == NS_INTERNALS "Note") { 
    61                 return new NoteNode(bufs, name, polyphonic, parent, srate); 
     62                return new NoteNode(this, bufs, name, polyphonic, parent, srate); 
    6263        } else if (uri_str == NS_INTERNALS "Trigger") { 
    63                 return new TriggerNode(bufs, name, polyphonic, parent, srate); 
     64                return new TriggerNode(this, bufs, name, polyphonic, parent, srate); 
    6465        } else { 
    6566                return NULL; 
  • trunk/ingen/src/engine/InternalPlugin.hpp

    r2398 r2533  
    2121#include "ingen-config.h" 
    2222 
    23 #ifndef HAVE_SLV2 
    24 #error "This file requires SLV2, but HAVE_SLV2 is not defined.  Please report." 
    25 #endif 
    26  
    2723#include <cstdlib> 
    2824#include <glibmm/module.h> 
     
    4541{ 
    4642public: 
    47         InternalPlugin(const std::string& uri, const std::string& symbol); 
     43        InternalPlugin(Shared::LV2URIMap& uris, 
     44                        const std::string& uri, const std::string& symbol); 
    4845 
    4946        NodeImpl* instantiate(BufferFactory&     bufs, 
  • trunk/ingen/src/engine/ingen_engine.cpp

    r2409 r2533  
    2626 
    2727struct IngenEngineModule : public Ingen::Shared::Module { 
    28         void load(Ingen::Shared::World* world) { 
     28        virtual void load(Ingen::Shared::World* world) { 
    2929                set_denormal_flags(); 
    30                 world->local_engine = SharedPtr<Engine>(new Engine(world)); 
     30                SharedPtr<Engine> engine(new Ingen::Engine(world)); 
     31                world->set_local_engine(engine); 
    3132                SharedPtr<QueuedEngineInterface> interface( 
    32                                 new Ingen::QueuedEngineInterface(*world->local_engine, event_queue_size)); 
    33                 world->engine = interface; 
    34                 world->local_engine->add_event_source(interface); 
     33                                new Ingen::QueuedEngineInterface(*engine.get(), event_queue_size)); 
     34                world->set_engine(interface); 
     35                engine->add_event_source(interface); 
     36                assert(world->local_engine() == engine); 
    3537        } 
    3638}; 
  • trunk/ingen/src/engine/ingen_http.cpp

    r2349 r2533  
    2828        void load(Ingen::Shared::World* world) { 
    2929                SharedPtr<HTTPEngineReceiver> interface( 
    30                                 new Ingen::HTTPEngineReceiver(*world->local_engine.get(), 
    31                                                 world->conf->option("engine-port").get_int32())); 
    32                 world->local_engine->add_event_source(interface); 
     30                                new Ingen::HTTPEngineReceiver(*world->local_engine().get(), 
     31                                                world->conf()->option("engine-port").get_int32())); 
     32                world->local_engine()->add_event_source(interface); 
    3333        } 
    3434}; 
  • trunk/ingen/src/engine/ingen_jack.cpp

    r2349 r2533  
    2626struct IngenJackModule : public Ingen::Shared::Module { 
    2727        void load(Ingen::Shared::World* world) { 
    28                 Ingen::JackDriver* driver = new Ingen::JackDriver(*world->local_engine.get()); 
    29                 driver->attach(world->conf->option("jack-server").get_string(), 
    30                                 world->conf->option("jack-client").get_string(), NULL); 
    31                 world->local_engine->set_driver(SharedPtr<Driver>(driver)); 
     28                Ingen::JackDriver* driver = new Ingen::JackDriver(*world->local_engine().get()); 
     29                driver->attach(world->conf()->option("jack-server").get_string(), 
     30                                world->conf()->option("jack-client").get_string(), NULL); 
     31                world->local_engine()->set_driver(SharedPtr<Driver>(driver)); 
    3232        } 
    3333}; 
  • trunk/ingen/src/engine/ingen_lv2.cpp

    r2527 r2533  
    1717 */ 
    1818 
    19 #ifndef PLUGIN_URI 
    20 #error "This file requires PLUGIN_URI to be defined" 
    21 #endif 
    22  
    2319#include <stdlib.h> 
     20#include <glibmm/miscutils.h> 
     21#include <glibmm/convert.h> 
     22#include <glib.h> 
    2423#include "lv2.h" 
     24#include "ingen-config.h" 
     25#include "raul/log.hpp" 
     26#include "raul/Thread.hpp" 
     27#include "raul/SharedPtr.hpp" 
     28#include "engine/AudioBuffer.hpp" 
    2529#include "engine/Engine.hpp" 
     30#include "engine/ThreadManager.hpp" 
    2631#include "engine/Driver.hpp" 
    2732#include "engine/ProcessContext.hpp" 
    2833#include "engine/PatchImpl.hpp" 
     34#include "engine/QueuedEngineInterface.hpp" 
    2935#include "module/World.hpp" 
    30  
    31 extern "C" { 
     36#include "module/ingen_module.hpp" 
     37#include "shared/runtime_paths.hpp" 
     38#include "shared/Configuration.hpp" 
     39#include "serialisation/Parser.hpp" 
     40#include "interface/EngineInterface.hpp" 
    3241 
    3342using namespace Ingen; 
    3443 
    35 /* Plugin */ 
    36  
    37 struct IngenLV2Driver : public Ingen::Driver { 
    38         IngenLV2Driver(Engine& engine, SampleCount buffer_size, SampleCount sample_rate) 
     44namespace Ingen { 
     45namespace LV2 { 
     46 
     47/** Record of a patch found in this LV2 bundle */ 
     48struct LV2Patch { 
     49        LV2Patch(const std::string& u, const std::string& f); 
     50 
     51        const std::string uri; 
     52        const std::string filename; 
     53        LV2_Descriptor    descriptor; 
     54}; 
     55 
     56 
     57/* Static library data */ 
     58typedef std::vector< SharedPtr<const LV2Patch> > LV2Patches; 
     59static bool           initialised = false; 
     60static LV2Patches     patches; 
     61static Configuration  conf; 
     62static int            argc = 0; 
     63static char**         argv = NULL; 
     64static Shared::World* world = NULL; 
     65 
     66 
     67struct LV2Driver; 
     68 
     69class LV2Port : public DriverPort 
     70{ 
     71public: 
     72        LV2Port(LV2Driver* driver, DuplexPort* patch_port) 
     73                : DriverPort(patch_port) 
     74                , _driver(driver) 
     75                , _buffer(NULL) 
     76        {} 
     77 
     78        // TODO: LV2 dynamic ports 
     79        void create() {} 
     80        void destroy() {} 
     81        void move(const Raul::Path& path) {} 
     82 
     83        void pre_process(ProcessContext& context) { 
     84                if (!is_input() || !_buffer) 
     85                        return; 
     86 
     87                if (_patch_port->buffer_type() == PortType::AUDIO) { 
     88                        AudioBuffer* patch_buf = (AudioBuffer*)_patch_port->buffer(0).get(); 
     89                        patch_buf->copy((Sample*)_buffer, 0, context.nframes() - 1); 
     90                } else if (_patch_port->buffer_type() == PortType::EVENTS) { 
     91                        //Raul::warn << "TODO: LV2 event I/O" << std::endl; 
     92                } 
     93        } 
     94 
     95        void post_process(ProcessContext& context) { 
     96                if (is_input() || !_buffer) 
     97                        return; 
     98 
     99                if (_patch_port->buffer_type() == PortType::AUDIO) { 
     100                        AudioBuffer* patch_buf = (AudioBuffer*)_patch_port->buffer(0).get(); 
     101                        memcpy((Sample*)_buffer, patch_buf->data(), context.nframes() * sizeof(Sample)); 
     102                } else if (_patch_port->buffer_type() == PortType::EVENTS) { 
     103                        //Raul::warn << "TODO: LV2 event I/O" << std::endl; 
     104                } 
     105        } 
     106 
     107        void* buffer() const        { return _buffer; } 
     108        void  set_buffer(void* buf) { _buffer = buf; } 
     109 
     110private: 
     111        LV2Driver* _driver; 
     112        void*      _buffer; 
     113}; 
     114 
     115 
     116struct LV2Driver : public Driver { 
     117private: 
     118        typedef std::vector<LV2Port*> Ports; 
     119 
     120public: 
     121        LV2Driver(Engine& engine, SampleCount buffer_size, SampleCount sample_rate) 
    39122                : _context(engine) 
     123                , _root_patch(NULL) 
    40124                , _buffer_size(buffer_size) 
    41125                , _sample_rate(sample_rate) 
    42126                , _frame_time(0) 
    43                 , _root_patch(NULL) 
    44127        {} 
    45  
    46         void activate() {} 
    47         void deactivate() {} 
    48         bool is_activated() const { return true; } 
    49128 
    50129        void run(uint32_t nframes) { 
    51130                _context.locate(_frame_time, nframes, 0); 
     131 
     132                for (Ports::iterator i = _ports.begin(); i != _ports.end(); ++i) 
     133                        (*i)->pre_process(_context); 
     134 
    52135                if (_root_patch) 
    53136                        _root_patch->process(_context); 
     137 
     138                for (Ports::iterator i = _ports.begin(); i != _ports.end(); ++i) 
     139                        (*i)->post_process(_context); 
     140 
    54141                _frame_time += nframes; 
    55142        } 
    56143 
    57         virtual void       set_root_patch(PatchImpl* patch) {} 
    58         virtual PatchImpl* root_patch()                     { return NULL; } 
    59  
    60         virtual void        add_port(DriverPort* port)          {} 
    61         virtual DriverPort* remove_port(const Raul::Path& path) { return NULL; } 
    62  
    63         virtual DriverPort* create_port(DuplexPort* patch_port) { return NULL; } 
    64  
    65         virtual DriverPort* driver_port(const Raul::Path& path) { return NULL; } 
    66  
    67         virtual SampleCount buffer_size()  const { return _buffer_size; } 
     144        virtual void       set_root_patch(PatchImpl* patch) { _root_patch = patch; } 
     145        virtual PatchImpl* root_patch()                     { return _root_patch; } 
     146 
     147        virtual void add_port(DriverPort* port) { 
     148                // Note this doesn't have to be realtime safe since there's no dynamic LV2 ports 
     149                ThreadManager::assert_thread(THREAD_PROCESS); 
     150                assert(dynamic_cast<LV2Port*>(port)); 
     151                assert(port->patch_port()->index() == _ports.size()); 
     152                _ports.push_back((LV2Port*)port); 
     153        } 
     154 
     155        virtual Raul::Deletable* remove_port(const Raul::Path& path, Ingen::DriverPort** port=NULL) { 
     156                // Note this doesn't have to be realtime safe since there's no dynamic LV2 ports 
     157                ThreadManager::assert_thread(THREAD_PROCESS); 
     158 
     159                for (Ports::iterator i = _ports.begin(); i != _ports.end(); ++i) { 
     160                        if ((*i)->patch_port()->path() == path) { 
     161                                _ports.erase(i); 
     162                                return NULL; 
     163                        } 
     164                } 
     165 
     166                Raul::warn << "Unable to find port " << path << std::endl; 
     167                return NULL; 
     168        } 
     169 
     170 
     171        virtual bool supports(Shared::PortType port_type, Shared::EventType event_type) { 
     172                return true; 
     173        } 
     174 
     175        virtual DriverPort* create_port(DuplexPort* patch_port) { 
     176                return new LV2Port(this, patch_port); 
     177        } 
     178 
     179        virtual DriverPort* driver_port(const Raul::Path& path) { 
     180                ThreadManager::assert_thread(THREAD_PROCESS); 
     181 
     182                for (Ports::iterator i = _ports.begin(); i != _ports.end(); ++i) 
     183                        if ((*i)->patch_port()->path() == path) 
     184                                return (*i); 
     185 
     186                return NULL; 
     187        } 
     188 
     189        virtual SampleCount block_length() const { return _buffer_size; } 
    68190        virtual SampleCount sample_rate()  const { return _sample_rate; } 
    69191        virtual SampleCount frame_time()   const { return _frame_time;} 
     
    78200        SampleCount    _sample_rate; 
    79201        SampleCount    _frame_time; 
     202        Ports          _ports; 
    80203}; 
    81204 
     205} // namespace LV2 
     206} // namespace Ingen 
     207 
     208 
     209/* LV2 Plugin Interface */ 
     210 
     211extern "C" { 
     212 
    82213 
    83214struct IngenPlugin { 
    84         Ingen::Shared::World*    world; 
    85         SharedPtr<Ingen::Engine> engine; 
     215        Ingen::Shared::World* world; 
    86216}; 
    87  
    88  
    89 static void 
    90 ingen_activate(LV2_Handle instance) 
    91 { 
    92         IngenPlugin* plugin = (IngenPlugin*)instance; 
    93         plugin->engine->activate(1); 
    94 } 
    95  
    96  
    97 static void 
    98 ingen_cleanup(LV2_Handle instance) 
    99 { 
    100         IngenPlugin* plugin = (IngenPlugin*)instance; 
    101         plugin->engine.reset(); 
    102         ingen_destroy_world(); 
    103         free(instance); 
    104 } 
    105  
    106  
    107 static void 
    108 ingen_connect_port(LV2_Handle instance, uint32_t port, void* data) 
    109 { 
    110 } 
    111217 
    112218 
     
    117223                  const LV2_Feature*const* features) 
    118224{ 
     225        Shared::set_bundle_path(bundle_path); 
     226 
     227        using namespace LV2; 
     228 
     229        const LV2Patch* patch = NULL; 
     230        for (LV2Patches::iterator i = patches.begin(); i != patches.end(); ++i) { 
     231                if (&(*i)->descriptor == descriptor) { 
     232                        patch = (*i).get(); 
     233                        break; 
     234                } 
     235        } 
     236 
     237        if (!patch) { 
     238                Raul::error << "Could not find patch " << descriptor->URI << std::endl; 
     239                return NULL; 
     240        } 
     241 
    119242        IngenPlugin* plugin = (IngenPlugin*)malloc(sizeof(IngenPlugin)); 
    120  
    121         Shared::bundle_path = bundle_path; 
    122  
    123         plugin->world = ingen_get_world(); 
    124         plugin->engine = SharedPtr<Engine>(new Engine(plugin->world)); 
    125         plugin->world->local_engine = plugin->engine; 
    126  
    127         // FIXME: fixed buffer size 
    128         plugin->engine->set_driver(PortType::AUDIO, 
    129                         SharedPtr<Driver>(new IngenLV2Driver(*plugin->engine, rate, 4096))); 
     243        //plugin->world = ingen_world_new(&conf, argc, argv); 
     244        plugin->world = LV2::world; 
     245 
     246        SharedPtr<Engine> engine(new Engine(plugin->world)); 
     247        plugin->world->set_local_engine(engine); 
     248 
     249        SharedPtr<QueuedEngineInterface> interface( 
     250                        new Ingen::QueuedEngineInterface(*plugin->world->local_engine(), event_queue_size)); 
     251        plugin->world->set_engine(interface); 
     252        plugin->world->local_engine()->add_event_source(interface); 
     253 
     254        Raul::Thread::get().set_context(THREAD_PRE_PROCESS); 
     255        ThreadManager::single_threaded = true; 
     256 
     257        ProcessContext context(*engine.get()); 
     258 
     259        // FIXME: fixed (or at least maximum) buffer size 
     260        engine->set_driver(SharedPtr<Driver>(new LV2Driver(*engine.get(), rate, 4096))); 
     261 
     262        engine->activate(); 
     263        ThreadManager::single_threaded = true; 
     264 
     265        // FIXME: don't load all plugins, only necessary ones 
     266        plugin->world->engine()->load_plugins(); 
     267        engine->process_events(context); 
     268 
     269        plugin->world->parser()->parse_document(plugin->world, 
     270                        plugin->world->engine().get(), patch->filename); 
     271        engine->process_events(context); 
     272 
     273        engine->deactivate(); 
     274 
     275        // Activate and deactivate to create root patch, allocate buffers, etc 
     276        //engine->activate(); 
     277        //engine->deactivate(); 
    130278 
    131279        return (LV2_Handle)plugin; 
     
    134282 
    135283static void 
     284ingen_connect_port(LV2_Handle instance, uint32_t port, void* data) 
     285{ 
     286} 
     287 
     288 
     289static void 
     290ingen_activate(LV2_Handle instance) 
     291{ 
     292        IngenPlugin* me = (IngenPlugin*)instance; 
     293        me->world->local_engine()->activate(); 
     294} 
     295 
     296 
     297static void 
    136298ingen_run(LV2_Handle instance, uint32_t sample_count) 
    137299{ 
    138         IngenPlugin* plugin = (IngenPlugin*)instance; 
    139         ((IngenLV2Driver*)plugin->engine->driver())->run(sample_count); 
     300        IngenPlugin* me = (IngenPlugin*)instance; 
     301        // FIXME: don't do this every call 
     302        Raul::Thread::get().set_context(THREAD_PROCESS); 
     303        ((LV2::LV2Driver*)me->world->local_engine()->driver())->run(sample_count); 
     304} 
     305 
     306 
     307static void 
     308ingen_deactivate(LV2_Handle instance) 
     309{ 
     310        IngenPlugin* me = (IngenPlugin*)instance; 
     311        me->world->local_engine()->deactivate(); 
     312} 
     313 
     314 
     315static void 
     316ingen_cleanup(LV2_Handle instance) 
     317{ 
     318        IngenPlugin* me = (IngenPlugin*)instance; 
     319        me->world->set_local_engine(SharedPtr<Engine>()); 
     320        me->world->set_engine(SharedPtr<EngineInterface>()); 
     321        //ingen_world_free(me->world); 
     322        free(instance); 
    140323} 
    141324 
     
    148331 
    149332 
    150 static void 
    151 ingen_deactivate(LV2_Handle instance) 
    152 { 
    153         IngenPlugin* plugin = (IngenPlugin*)instance; 
    154         plugin->engine->deactivate(); 
    155 } 
    156  
    157  
    158 /* Library */ 
    159  
    160 static LV2_Descriptor *ingen_descriptor = NULL; 
    161  
    162 static void 
    163 init_descriptor() 
    164 { 
    165         ingen_descriptor = (LV2_Descriptor*)malloc(sizeof(LV2_Descriptor)); 
    166  
    167         ingen_descriptor->URI = PLUGIN_URI; 
    168         ingen_descriptor->instantiate = ingen_instantiate; 
    169         ingen_descriptor->connect_port = ingen_connect_port; 
    170         ingen_descriptor->activate = ingen_activate; 
    171         ingen_descriptor->run = ingen_run; 
    172         ingen_descriptor->deactivate = ingen_deactivate; 
    173         ingen_descriptor->cleanup = ingen_cleanup; 
    174         ingen_descriptor->extension_data = ingen_extension_data; 
    175 } 
    176  
     333/* Library Code */ 
     334 
     335namespace Ingen { 
     336namespace LV2 { 
     337 
     338LV2Patch::LV2Patch(const std::string& u, const std::string& f) 
     339        : uri(u), filename(f) 
     340{ 
     341        descriptor.URI            = uri.c_str(); 
     342        descriptor.instantiate    = ingen_instantiate; 
     343        descriptor.connect_port   = ingen_connect_port; 
     344        descriptor.activate       = ingen_activate; 
     345        descriptor.run            = ingen_run; 
     346        descriptor.deactivate     = ingen_deactivate; 
     347        descriptor.cleanup        = ingen_cleanup; 
     348        descriptor.extension_data = ingen_extension_data; 
     349} 
     350 
     351} // namespace LV2 
     352} // namespace Ingen 
     353 
     354 
     355static void 
     356init() 
     357{ 
     358        Shared::set_bundle_path_from_code((void*)&init); 
     359 
     360        using namespace LV2; 
     361 
     362        //Shared::World* world = ingen_world_new(&conf, argc, argv); 
     363 
     364        world = ingen_world_new(&conf, argc, argv); 
     365        if (!world->load("ingen_serialisation")) { 
     366                Raul::error << "Unable to load serialisation module" << std::endl; 
     367                //ingen_world_free(world); 
     368                return; 
     369        } 
     370 
     371 
     372        Serialisation::Parser::PatchRecords records( 
     373                        world->parser()->find_patches(world, 
     374                                Glib::filename_to_uri(Shared::bundle_file_path("manifest.ttl")))); 
     375 
     376        for (Serialisation::Parser::PatchRecords::iterator i = records.begin(); 
     377                        i != records.end(); ++i) { 
     378                patches.push_back(SharedPtr<const LV2Patch>( 
     379                                new LV2Patch(i->uri.str(), i->filename))); 
     380        } 
     381 
     382 
     383        //ingen_world_free(world); 
     384 
     385        initialised = true; 
     386} 
     387 
     388 
     389/* LV2 Library Interface */ 
     390 
     391extern "C" { 
    177392 
    178393LV2_SYMBOL_EXPORT 
     
    180395lv2_descriptor(uint32_t index) 
    181396{ 
    182         if (!ingen_descriptor) 
    183                 init_descriptor(); 
    184  
    185         switch (index) { 
    186         case 0: 
    187                 return ingen_descriptor; 
    188         default: 
     397        if (!LV2::initialised) 
     398                init(); 
     399 
     400        if (index >= LV2::patches.size()) 
    189401                return NULL; 
    190         } 
     402        else 
     403                return &LV2::patches[index]->descriptor; 
     404} 
     405 
    191406} 
    192407 
  • trunk/ingen/src/engine/ingen_osc.cpp

    r2349 r2533  
    2828        void load(Ingen::Shared::World* world) { 
    2929                SharedPtr<OSCEngineReceiver> interface( 
    30                                 new Ingen::OSCEngineReceiver(*world->local_engine.get(), 
     30                                new Ingen::OSCEngineReceiver(*world->local_engine().get(), 
    3131                                        event_queue_size, 
    32                                         world->conf->option("engine-port").get_int32())); 
    33                 world->local_engine->add_event_source(interface); 
     32                                        world->conf()->option("engine-port").get_int32())); 
     33                world->local_engine()->add_event_source(interface); 
    3434        } 
    3535}; 
  • trunk/ingen/src/engine/internals/Controller.cpp

    r2486 r2533  
    3737using namespace Shared; 
    3838 
    39 static InternalPlugin controller_plugin(NS_INTERNALS "Controller", "controller"); 
     39InternalPlugin* ControllerNode::internal_plugin(Shared::LV2URIMap& uris) { 
     40        return new InternalPlugin(uris, NS_INTERNALS "Controller", "controller"); 
     41} 
    4042 
    41 InternalPlugin& ControllerNode::internal_plugin() { return controller_plugin; } 
    42  
    43 ControllerNode::ControllerNode(BufferFactory& bufs, 
    44                                const string&  path, 
    45                                bool           polyphonic, 
    46                                PatchImpl*     parent, 
    47                                SampleRate     srate) 
    48         : NodeImpl(&controller_plugin, path, false, parent, srate) 
     43ControllerNode::ControllerNode(InternalPlugin* plugin, 
     44                               BufferFactory&  bufs, 
     45                               const string&   path, 
     46                               bool            polyphonic, 
     47                               PatchImpl*      parent, 
     48                               SampleRate      srate) 
     49        : NodeImpl(plugin, path, false, parent, srate) 
    4950        , _learning(false) 
    5051{ 
    51         const LV2URIMap& uris = Shared::LV2URIMap::instance(); 
     52        const LV2URIMap& uris = bufs.uris(); 
    5253        _ports = new Raul::Array<PortImpl*>(6); 
    5354 
  • trunk/ingen/src/engine/internals/Controller.hpp

    r2486 r2533  
    4141{ 
    4242public: 
    43         ControllerNode(BufferFactory& bufs, const std::string& path, bool polyphonic, PatchImpl* parent, SampleRate srate); 
     43        ControllerNode( 
     44                        InternalPlugin*    plugin, 
     45                        BufferFactory&     bufs, 
     46                        const std::string& path, 
     47                        bool               polyphonic, 
     48                        PatchImpl*         parent, 
     49                        SampleRate         srate); 
    4450 
    4551        void process(ProcessContext& context); 
     
    4955        void learn() { _learning = true; } 
    5056 
    51         static InternalPlugin& internal_plugin(); 
     57        static InternalPlugin* internal_plugin(Shared::LV2URIMap& uris); 
    5258 
    5359private: 
  • trunk/ingen/src/engine/internals/Delay.cpp

    r2486 r2533  
    5050static const float MAX_DELAY_SECONDS = 8.0f; 
    5151 
    52 static InternalPlugin note_plugin(NS_INTERNALS "Delay", "delay"); 
    53  
    54 InternalPlugin& DelayNode::internal_plugin() { return note_plugin; } 
    55  
    56 DelayNode::DelayNode(BufferFactory& bufs, const string& path, bool polyphonic, PatchImpl* parent, SampleRate srate) 
    57         : NodeImpl(&note_plugin, path, polyphonic, parent, srate) 
     52InternalPlugin* DelayNode::internal_plugin(Shared::LV2URIMap& uris) { 
     53        return new InternalPlugin(uris, NS_INTERNALS "Delay", "delay"); 
     54} 
     55 
     56DelayNode::DelayNode( 
     57                InternalPlugin*    plugin, 
     58                BufferFactory&     bufs, 
     59                const std::string& path, 
     60                bool               polyphonic, 
     61                PatchImpl*         parent, 
     62                SampleRate         srate) 
     63        : NodeImpl(plugin, path, polyphonic, parent, srate) 
    5864        , _buffer(0) 
    5965        , _buffer_length(0) 
     
    6167        , _write_phase(0) 
    6268{ 
    63         const LV2URIMap& uris = Shared::LV2URIMap::instance(); 
     69        const LV2URIMap& uris = bufs.uris(); 
    6470        _ports = new Raul::Array<PortImpl*>(3); 
    6571 
  • trunk/ingen/src/engine/internals/Delay.hpp

    r2486 r2533  
    4545{ 
    4646public: 
    47         DelayNode(BufferFactory& bufs, const std::string& path, bool polyphonic, PatchImpl* parent, SampleRate srate); 
     47        DelayNode( 
     48                        InternalPlugin*    plugin, 
     49                        BufferFactory&     bufs, 
     50                        const std::string& path, 
     51                        bool               polyphonic, 
     52                        PatchImpl*         parent, 
     53                        SampleRate         srate); 
     54 
    4855        ~DelayNode(); 
    4956 
     
    5259        void process(ProcessContext& context); 
    5360 
    54         static InternalPlugin& internal_plugin(); 
     61        static InternalPlugin* internal_plugin(Shared::LV2URIMap& uris); 
    5562 
    5663        float delay_samples() const { return _delay_samples; } 
  • trunk/ingen/src/engine/internals/Note.cpp

    r2486 r2533  
    4444using namespace Shared; 
    4545 
    46 static InternalPlugin note_plugin(NS_INTERNALS "Note", "note"); 
    47  
    48 InternalPlugin& NoteNode::internal_plugin() { return note_plugin; } 
    49  
    50 NoteNode::NoteNode(BufferFactory& bufs, const string& path, bool polyphonic, PatchImpl* parent, SampleRate srate) 
    51         : NodeImpl(&note_plugin, path, polyphonic, parent, srate) 
     46InternalPlugin* NoteNode::internal_plugin(Shared::LV2URIMap& uris) { 
     47        return new InternalPlugin(uris, NS_INTERNALS "Note", "note"); 
     48} 
     49 
     50NoteNode::NoteNode( 
     51                InternalPlugin*    plugin, 
     52                BufferFactory&     bufs, 
     53                const std::string& path, 
     54                bool               polyphonic, 
     55                PatchImpl*         parent, 
     56                SampleRate         srate) 
     57        : NodeImpl(plugin, path, polyphonic, parent, srate) 
    5258        , _voices(new Raul::Array<Voice>(_polyphony)) 
    5359        , _prepared_voices(NULL) 
    5460        , _sustain(false) 
    5561{ 
    56         const LV2URIMap& uris = Shared::LV2URIMap::instance(); 
     62        const LV2URIMap& uris = bufs.uris(); 
    5763        _ports = new Raul::Array<PortImpl*>(5); 
     64 
     65 
     66        std::cout << "NEW NOTE NODE" << std::endl; 
    5867 
    5968        _midi_in_port = new InputPort(bufs, this, "input", 0, 1, PortType::EVENTS, Raul::Atom()); 
  • trunk/ingen/src/engine/internals/Note.hpp

    r2486 r2533  
    4141{ 
    4242public: 
    43         NoteNode(BufferFactory& bufs, const std::string& path, bool polyphonic, PatchImpl* parent, SampleRate srate); 
     43        NoteNode( 
     44                        InternalPlugin*    plugin, 
     45                        BufferFactory&     bufs, 
     46                        const std::string& path, 
     47                        bool               polyphonic, 
     48                        PatchImpl*         parent, 
     49                        SampleRate         srate); 
     50 
    4451        ~NoteNode(); 
    4552 
     
    5663        void sustain_off(ProcessContext& context, FrameTime time); 
    5764 
    58         static InternalPlugin& internal_plugin(); 
     65        static InternalPlugin* internal_plugin(Shared::LV2URIMap& uris); 
    5966 
    6067private: 
  • trunk/ingen/src/engine/internals/Trigger.cpp

    r2486 r2533  
    4040using namespace Shared; 
    4141 
    42 static InternalPlugin trigger_plugin(NS_INTERNALS "Trigger", "trigger"); 
     42InternalPlugin* TriggerNode::internal_plugin(Shared::LV2URIMap& uris) { 
     43        return new InternalPlugin(uris, NS_INTERNALS "Trigger", "trigger"); 
     44} 
    4345 
    44 InternalPlugin& TriggerNode::internal_plugin() { return trigger_plugin; } 
    45  
    46 TriggerNode::TriggerNode(BufferFactory& bufs, const string& path, bool polyphonic, PatchImpl* parent, SampleRate srate) 
    47         : NodeImpl(&trigger_plugin, path, false, parent, srate) 
     46TriggerNode::TriggerNode( 
     47                InternalPlugin*    plugin, 
     48                BufferFactory&     bufs, 
     49                const std::string& path, 
     50                bool               polyphonic, 
     51                PatchImpl*         parent, 
     52                SampleRate         srate) 
     53        : NodeImpl(plugin, path, false, parent, srate) 
    4854        , _learning(false) 
    4955{ 
    50         const LV2URIMap& uris = LV2URIMap::instance(); 
     56        const LV2URIMap& uris = bufs.uris(); 
    5157        _ports = new Raul::Array<PortImpl*>(5); 
    5258 
  • trunk/ingen/src/engine/internals/Trigger.hpp

    r2486 r2533  
    4444{ 
    4545public: 
    46         TriggerNode(BufferFactory& bufs, const std::string& path, bool polyphonic, PatchImpl* parent, SampleRate srate); 
     46        TriggerNode( 
     47                        InternalPlugin*    plugin, 
     48                        BufferFactory&     bufs, 
     49                        const std::string& path, 
     50                        bool               polyphonic, 
     51                        PatchImpl*         parent, 
     52                        SampleRate         srate); 
    4753 
    4854        void process(ProcessContext& context); 
     
    5359        void learn() { _learning = true; } 
    5460 
    55         static InternalPlugin& internal_plugin(); 
     61        static InternalPlugin* internal_plugin(Shared::LV2URIMap& uris); 
    5662 
    5763private: 
  • trunk/ingen/src/engine/JackDriver.cpp

    r2492 r2533  
    193193        , _root_patch(NULL) 
    194194{ 
    195         _midi_event_type = _engine.world()->uris->uri_to_id( 
     195        _midi_event_type = _engine.world()->uris()->uri_to_id( 
    196196                        NULL, "http://lv2plug.in/ns/ext/midi#MidiEvent"); 
    197197} 
     
    275275 
    276276        if (!_client) 
    277                 attach(_engine.world()->conf->option("jack-server").get_string(), 
    278                                 _engine.world()->conf->option("jack-client").get_string(), NULL); 
     277                attach(_engine.world()->conf()->option("jack-server").get_string(), 
     278                                _engine.world()->conf()->option("jack-client").get_string(), NULL); 
    279279 
    280280        jack_set_process_callback(_client, process_cb, this); 
     
    339339 * It is the callers responsibility to delete the returned port. 
    340340 */ 
    341 Raul::List<DriverPort*>::Node* 
    342 JackDriver::remove_port(const Path& path) 
     341Raul::Deletable* 
     342JackDriver::remove_port(const Path& path, DriverPort** port) 
    343343{ 
    344344        ThreadManager::assert_thread(THREAD_PROCESS); 
    345345 
    346         for (Raul::List<JackPort*>::iterator i = _ports.begin(); i != _ports.end(); ++i) 
    347                 if ((*i)->patch_port()->path() == path) 
    348                         return (Raul::List<DriverPort*>::Node*)(_ports.erase(i)); 
     346        for (Raul::List<JackPort*>::iterator i = _ports.begin(); i != _ports.end(); ++i) { 
     347                if ((*i)->patch_port()->path() == path) { 
     348                        Raul::List<Ingen::JackPort*>::Node* node = _ports.erase(i); 
     349                        if (port) 
     350                                *port = node->elem(); 
     351                        return node; 
     352                } 
     353        } 
    349354 
    350355        LOG(warn) << "Unable to find port " << path << endl; 
  • trunk/ingen/src/engine/JackDriver.hpp

    r2468 r2533  
    9898        DriverPort* driver_port(const Raul::Path& path); 
    9999 
    100         Raul::List<DriverPort*>::Node* remove_port(const Raul::Path& path); 
     100        Raul::Deletable* remove_port(const Raul::Path& path, DriverPort** port=NULL); 
    101101 
    102102        PatchImpl* root_patch()                     { return _root_patch; } 
  • trunk/ingen/src/engine/LADSPANode.cpp

    r2492 r2533  
    134134LADSPANode::instantiate(BufferFactory& bufs) 
    135135{ 
    136         const LV2URIMap& uris = Shared::LV2URIMap::instance(); 
     136        const LV2URIMap& uris = bufs.uris(); 
    137137        if (!_ports) 
    138138                _ports = new Raul::Array<PortImpl*>(_descriptor->PortCount); 
  • trunk/ingen/src/engine/LADSPAPlugin.cpp

    r2468 r2533  
    3232 
    3333LADSPAPlugin::LADSPAPlugin( 
     34                Shared::LV2URIMap& uris, 
    3435                const std::string& library_path, 
    3536                const std::string& uri, 
     
    3738                const std::string& label, 
    3839                const std::string& name) 
    39         : PluginImpl(Plugin::LADSPA, uri, library_path) 
     40        : PluginImpl(uris, Plugin::LADSPA, uri, library_path) 
    4041        , _id(id) 
    4142        , _label(label) 
    4243        , _name(name) 
    4344{ 
    44         const LV2URIMap& uris = Shared::LV2URIMap::instance(); 
    4545        set_property(uris.rdf_type,   uris.ingen_LADSPAPlugin); 
    4646        set_property(uris.lv2_symbol, Symbol::symbolify(label)); 
     
    5252LADSPAPlugin::get_property(const Raul::URI& uri) const 
    5353{ 
    54         if (uri == Shared::LV2URIMap::instance().doap_name) 
     54        if (uri == _uris.doap_name) 
    5555                return _name; 
    5656        else 
  • trunk/ingen/src/engine/LADSPAPlugin.hpp

    r2398 r2533  
    3838{ 
    3939public: 
    40         LADSPAPlugin(const std::string& library_path, 
    41                      const std::string& uri, 
    42                      unsigned long      id, 
    43                      const std::string& label, 
    44                      const std::string& name); 
     40        LADSPAPlugin( 
     41                        Shared::LV2URIMap& uris, 
     42                        const std::string& library_path, 
     43                const std::string& uri, 
     44                unsigned long      id, 
     45                const std::string& label, 
     46                const std::string& name); 
    4547 
    4648        NodeImpl* instantiate(BufferFactory& bufs, 
  • trunk/ingen/src/engine/LV2Info.cpp

    r2349 r2533  
    3232 
    3333LV2Info::LV2Info(Ingen::Shared::World* world) 
    34         : input_class(slv2_value_new_uri(world->slv2_world, SLV2_PORT_CLASS_INPUT)) 
    35         , output_class(slv2_value_new_uri(world->slv2_world, SLV2_PORT_CLASS_OUTPUT)) 
    36         , control_class(slv2_value_new_uri(world->slv2_world, SLV2_PORT_CLASS_CONTROL)) 
    37         , audio_class(slv2_value_new_uri(world->slv2_world, SLV2_PORT_CLASS_AUDIO)) 
    38         , event_class(slv2_value_new_uri(world->slv2_world, SLV2_PORT_CLASS_EVENT)) 
    39         , value_port_class(slv2_value_new_uri(world->slv2_world, LV2_OBJECT_URI "#ValuePort")) 
    40         , message_port_class(slv2_value_new_uri(world->slv2_world, LV2_OBJECT_URI "#MessagePort")) 
     34        : input_class(slv2_value_new_uri(world->slv2_world(), SLV2_PORT_CLASS_INPUT)) 
     35        , output_class(slv2_value_new_uri(world->slv2_world(), SLV2_PORT_CLASS_OUTPUT)) 
     36        , control_class(slv2_value_new_uri(world->slv2_world(), SLV2_PORT_CLASS_CONTROL)) 
     37        , audio_class(slv2_value_new_uri(world->slv2_world(), SLV2_PORT_CLASS_AUDIO)) 
     38        , event_class(slv2_value_new_uri(world->slv2_world(), SLV2_PORT_CLASS_EVENT)) 
     39        , value_port_class(slv2_value_new_uri(world->slv2_world(), LV2_OBJECT_URI "#ValuePort")) 
     40        , message_port_class(slv2_value_new_uri(world->slv2_world(), LV2_OBJECT_URI "#MessagePort")) 
    4141        , _world(world) 
    4242{ 
    4343        assert(world); 
    4444 
    45         world->lv2_features->add_feature(LV2_EVENT_URI, 
     45        world->lv2_features()->add_feature(LV2_EVENT_URI, 
    4646                        SharedPtr<Shared::LV2Features::Feature>(new EventFeature())); 
    47         world->lv2_features->add_feature(LV2_BLOB_SUPPORT_URI, 
     47        world->lv2_features()->add_feature(LV2_BLOB_SUPPORT_URI, 
    4848                        SharedPtr<Shared::LV2Features::Feature>(new BlobFeature())); 
    49         world->lv2_features->add_feature(LV2_RESIZE_PORT_URI, 
     49        world->lv2_features()->add_feature(LV2_RESIZE_PORT_URI, 
    5050                        SharedPtr<Shared::LV2Features::Feature>(new ResizeFeature())); 
    5151} 
  • trunk/ingen/src/engine/LV2Info.hpp

    r2398 r2533  
    5555 
    5656        Ingen::Shared::World& world()     { return *_world; } 
    57         SLV2World             lv2_world() { return _world->slv2_world; } 
     57        SLV2World             lv2_world() { return _world->slv2_world(); } 
    5858 
    5959private: 
  • trunk/ingen/src/engine/LV2Node.cpp

    r2518 r2533  
    139139LV2Node::instantiate(BufferFactory& bufs) 
    140140{ 
    141         const LV2URIMap&   uris = Shared::LV2URIMap::instance(); 
     141        const LV2URIMap&   uris = bufs.uris(); 
    142142        SharedPtr<LV2Info> info = _lv2_plugin->lv2_info(); 
    143143        SLV2Plugin         plug = _lv2_plugin->slv2_plugin(); 
     
    149149        _instances = new Instances(_polyphony, SharedPtr<void>()); 
    150150 
    151         _features = info->world().lv2_features->lv2_features(this); 
     151        _features = info->world().lv2_features()->lv2_features(this); 
    152152 
    153153        uint32_t port_buffer_size = 0; 
     
    310310                for (uint32_t i = 0; i < slv2_values_size(types); ++i) { 
    311311                        SLV2Value type = slv2_values_get_at(types, i); 
    312                         std::cout << path() << " port " << id << " supports " << 
    313                                 slv2_value_as_uri(type) << std::endl; 
     312                        Raul::info << path() << " port " << id << " supports " << 
     313                                        slv2_value_as_uri(type) << std::endl; 
    314314                        if (slv2_value_is_uri(type)) { 
    315315                                port->add_property(uris.obj_supports, Raul::URI(slv2_value_as_uri(type))); 
  • trunk/ingen/src/engine/LV2Plugin.cpp

    r2468 r2533  
    3333 
    3434LV2Plugin::LV2Plugin(SharedPtr<LV2Info> lv2_info, const std::string& uri) 
    35         : PluginImpl(Plugin::LV2, uri) 
     35        : PluginImpl(*lv2_info->world().uris().get(), Plugin::LV2, uri) 
    3636        , _slv2_plugin(NULL) 
    3737        , _lv2_info(lv2_info) 
    3838{ 
    39         const LV2URIMap& uris = Shared::LV2URIMap::instance(); 
    40         set_property(uris.rdf_type, uris.lv2_Plugin); 
     39        set_property(_uris.rdf_type, _uris.lv2_Plugin); 
    4140} 
    4241 
     
    7473        load(); // FIXME: unload at some point 
    7574 
    76         Glib::Mutex::Lock lock(engine.world()->rdf_world->mutex()); 
     75        Glib::Mutex::Lock lock(engine.world()->rdf_world()->mutex()); 
    7776        LV2Node* n = new LV2Node(this, name, polyphonic, parent, srate); 
    7877 
  • trunk/ingen/src/engine/MessageContext.cpp

    r2491 r2533  
    3838MessageContext::run(PortImpl* port, FrameTime time) 
    3939{ 
    40         if (ThreadManager::current_thread_id() == THREAD_PRE_PROCESS) { 
     40        if (ThreadManager::thread_is(THREAD_PRE_PROCESS)) { 
    4141                assert(port); 
    4242                Glib::Mutex::Lock lock(_mutex); 
     
    4444                _sem.post(); 
    4545                _cond.wait(_mutex); 
    46         } else if (ThreadManager::current_thread_id() == THREAD_PROCESS) { 
     46        } else if (ThreadManager::thread_is(THREAD_PROCESS)) { 
    4747                Request r(time, port); 
    4848                _requests.write(sizeof(Request), &r); 
    4949                // signal() will be called at the end of this process cycle 
    50         } else if (ThreadManager::current_thread_id() == THREAD_MESSAGE) { 
     50        } else if (ThreadManager::thread_is(THREAD_MESSAGE)) { 
    5151                warn << "Message context recursion at " << port->path() << endl; 
    5252        } else { 
  • trunk/ingen/src/engine/NodeFactory.cpp

    r2518 r2533  
    6767{ 
    6868        for (Plugins::iterator i = _plugins.begin(); i != _plugins.end(); ++i) 
    69                 if (i->second->type() != Shared::Plugin::Internal) 
    70                         delete i->second; 
     69                delete i->second; 
    7170 
    7271        _plugins.clear(); 
     
    112111        ThreadManager::assert_thread(THREAD_PRE_PROCESS); 
    113112 
    114         _world->rdf_world->mutex().lock(); 
     113        _world->rdf_world()->mutex().lock(); 
    115114 
    116115        // Only load if we havn't already, so every client connecting doesn't cause 
     
    133132        } 
    134133 
    135         _world->rdf_world->mutex().unlock(); 
     134        _world->rdf_world()->mutex().unlock(); 
    136135} 
    137136 
     
    140139NodeFactory::load_internal_plugins() 
    141140{ 
    142         InternalPlugin& controller_plug = ControllerNode::internal_plugin(); 
    143         _plugins.insert(make_pair(controller_plug.uri(), &controller_plug)); 
    144  
    145         InternalPlugin& delay_plug = DelayNode::internal_plugin(); 
    146         _plugins.insert(make_pair(delay_plug.uri(), &delay_plug)); 
    147  
    148         InternalPlugin& note_plug = NoteNode::internal_plugin(); 
    149         _plugins.insert(make_pair(note_plug.uri(), &note_plug)); 
    150  
    151         InternalPlugin& trigger_plug = TriggerNode::internal_plugin(); 
    152         _plugins.insert(make_pair(trigger_plug.uri(), &trigger_plug)); 
     141        Shared::LV2URIMap& uris = *_world->uris().get(); 
     142        InternalPlugin* controller_plug = ControllerNode::internal_plugin(uris); 
     143        _plugins.insert(make_pair(controller_plug->uri(), controller_plug)); 
     144 
     145        InternalPlugin* delay_plug = DelayNode::internal_plugin(uris); 
     146        _plugins.insert(make_pair(delay_plug->uri(), delay_plug)); 
     147 
     148        InternalPlugin* note_plug = NoteNode::internal_plugin(uris); 
     149        _plugins.insert(make_pair(note_plug->uri(), note_plug)); 
     150 
     151        InternalPlugin* trigger_plug = TriggerNode::internal_plugin(uris); 
     152        _plugins.insert(make_pair(trigger_plug->uri(), trigger_plug)); 
    153153} 
    154154 
     
    160160NodeFactory::load_lv2_plugins() 
    161161{ 
    162         SLV2Plugins plugins = slv2_world_get_all_plugins(_world->slv2_world); 
     162        SLV2Plugins plugins = slv2_world_get_all_plugins(_world->slv2_world()); 
    163163 
    164164        for (unsigned i=0; i < slv2_plugins_size(plugins); ++i) { 
     
    178178        } 
    179179 
    180         slv2_plugins_free(_world->slv2_world, plugins); 
     180        slv2_plugins_free(_world->slv2_world(), plugins); 
    181181} 
    182182#endif // HAVE_SLV2 
     
    255255 
    256256                                if (i == _plugins.end()) { 
    257                                         LADSPAPlugin* plugin = new LADSPAPlugin(lib_path, uri, 
    258                                                 descriptor->UniqueID, 
    259                                                 descriptor->Label, 
    260                                                 descriptor->Name); 
     257                                        LADSPAPlugin* plugin = new LADSPAPlugin(*_world->uris().get(), 
     258                                                        lib_path, uri, 
     259                                                        descriptor->UniqueID, 
     260                                                        descriptor->Label, 
     261                                                        descriptor->Name); 
    261262 
    262263                                        _plugins.insert(make_pair(uri, plugin)); 
  • trunk/ingen/src/engine/NodeImpl.cpp

    r2501 r2533  
    3737 
    3838NodeImpl::NodeImpl(PluginImpl* plugin, const Raul::Symbol& symbol, bool polyphonic, PatchImpl* parent, SampleRate srate) 
    39         : GraphObjectImpl(parent, symbol) 
     39        : GraphObjectImpl(plugin->uris(), parent, symbol) 
    4040        , _plugin(plugin) 
    4141        , _polyphonic(polyphonic) 
  • trunk/ingen/src/engine/ObjectSender.cpp

    r2492 r2533  
    137137                client->put(port->meta_uri(), port->meta().properties()); 
    138138 
    139         const Shared::LV2URIMap& map = Shared::LV2URIMap::instance(); 
    140  
    141139        client->put(port->path(), port->properties()); 
    142140 
    143141        // Send control value 
    144142        if (port->is_a(PortType::CONTROL)) 
    145                 client->set_property(port->path(), map.ingen_value, port->value()); 
     143                client->set_property(port->path(), port->bufs().uris().ingen_value, port->value()); 
    146144 
    147145        if (bundle) 
  • trunk/ingen/src/engine/OutputPort.cpp

    r2494 r2533  
    4040        : PortImpl(bufs, parent, symbol, index, poly, type, value, buffer_size) 
    4141{ 
    42         const LV2URIMap& uris = Shared::LV2URIMap::instance(); 
    43  
    4442        if (!dynamic_cast<Patch*>(parent)) 
    45                 add_property(uris.rdf_type, uris.lv2_OutputPort); 
     43                add_property(bufs.uris().rdf_type, bufs.uris().lv2_OutputPort); 
    4644 
    4745        if (type == PortType::CONTROL) 
  • trunk/ingen/src/engine/PatchImpl.cpp

    r2499 r2533  
    1919#include <cmath> 
    2020#include "raul/log.hpp" 
     21#include "module/World.hpp" 
     22#include "shared/LV2URIMap.hpp" 
    2123#include "ThreadManager.hpp" 
    2224#include "NodeImpl.hpp" 
     
    4042 
    4143PatchImpl::PatchImpl(Engine& engine, const Raul::Symbol& symbol, uint32_t poly, PatchImpl* parent, SampleRate srate, uint32_t internal_poly) 
    42         : NodeImpl(new PatchPlugin("http://example.org/FIXME", "patch", "Ingen Patch"), 
     44        : NodeImpl(new PatchPlugin(*engine.world()->uris().get(), 
     45                                engine.world()->uris()->ingen_Patch.c_str(), "patch", "Ingen Patch"), 
    4346                symbol, poly, parent, srate) 
    4447        , _engine(engine) 
     
    339342PatchImpl::num_ports() const 
    340343{ 
    341         ThreadID context = ThreadManager::current_thread_id(); 
    342  
    343         if (context == THREAD_PROCESS) 
     344        if (ThreadManager::thread_is(THREAD_PROCESS)) 
    344345                return NodeImpl::num_ports(); 
    345346        else 
  • trunk/ingen/src/engine/PatchPlugin.hpp

    r2398 r2533  
    3636{ 
    3737public: 
    38         PatchPlugin(const std::string& uri, 
    39                     const std::string& symbol, 
    40                     const std::string& name) 
    41                 : PluginImpl(Plugin::Patch, uri) 
     38        PatchPlugin( 
     39                        Shared::LV2URIMap& uris, 
     40                        const std::string& uri, 
     41                        const std::string& symbol, 
     42                        const std::string& name) 
     43                : PluginImpl(uris, Plugin::Patch, uri) 
    4244        {} 
    4345 
  • trunk/ingen/src/engine/PluginImpl.hpp

    r2398 r2533  
    2929namespace Ingen { 
    3030 
     31namespace Shared { class LV2URIMap; } 
     32 
    3133class PatchImpl; 
    3234class NodeImpl; 
     
    4446{ 
    4547public: 
    46         PluginImpl(Type type, const std::string& uri, const std::string library_path="") 
    47                 : ResourceImpl(uri) 
     48        PluginImpl(Shared::LV2URIMap& uris, 
     49                        Type type, const std::string& uri, const std::string library_path="") 
     50                : ResourceImpl(uris, uri) 
    4851                , _type(type) 
    4952                , _library_path(library_path) 
  • trunk/ingen/src/engine/PortImpl.cpp

    r2494 r2533  
    4949                   const Atom&         value, 
    5050                   size_t              buffer_size) 
    51         : GraphObjectImpl(node, name) 
     51        : GraphObjectImpl(bufs.uris(), node, name) 
    5252        , _bufs(bufs) 
    5353        , _index(index) 
     
    7070                _buffer_size = bufs.default_buffer_size(type); 
    7171 
    72         const LV2URIMap& uris = Shared::LV2URIMap::instance(); 
     72        const LV2URIMap& uris = bufs.uris(); 
    7373        add_property(uris.rdf_type,  type.uri()); 
    7474        set_property(uris.lv2_index, Atom((int32_t)index)); 
     
    8989PortImpl::supports(const Raul::URI& value_type) const 
    9090{ 
    91         return has_property(Shared::LV2URIMap::instance().obj_supports, value_type); 
     91        return has_property(_bufs.uris().obj_supports, value_type); 
    9292} 
    9393 
     
    228228        case PortType::VALUE: 
    229229        case PortType::MESSAGE: 
    230                 LV2Object::to_atom(((ObjectBuffer*)buffer(0).get())->object(), val); 
     230                LV2Object::to_atom(_bufs.uris(), ((ObjectBuffer*)buffer(0).get())->object(), val); 
    231231                break; 
    232232        } 
     
    243243PortImpl::set_context(Context::ID c) 
    244244{ 
    245         const LV2URIMap& uris = Shared::LV2URIMap::instance(); 
     245        const LV2URIMap& uris = _bufs.uris(); 
    246246        _context = c; 
    247247        switch (c) { 
    248248        case Context::AUDIO: 
    249                 set_property(uris.ctx_context, uris.ctx_AudioContext); 
     249                remove_property(uris.ctx_context, uris.wildcard); 
    250250                break; 
    251251        case Context::MESSAGE: 
  • trunk/ingen/src/engine/PortImpl.hpp

    r2494 r2533  
    137137        void        set_context(Context::ID c); 
    138138 
     139        BufferFactory& bufs() const { return _bufs; } 
     140 
    139141protected: 
    140142        PortImpl(BufferFactory&      bufs, 
  • trunk/ingen/src/engine/QueuedEngineInterface.cpp

    r2504 r2533  
    226226        Path path = meta ? (string("/") + path.chop_start("/")) : uri.str(); 
    227227        Resource::Properties remove; 
    228         remove.insert(make_pair(predicate, Shared::LV2URIMap::instance().wildcard)); 
     228        remove.insert(make_pair(predicate, _engine.world()->uris()->wildcard)); 
    229229        Resource::Properties add; 
    230230        add.insert(make_pair(predicate, value)); 
  • trunk/ingen/src/engine/ThreadManager.hpp

    r2398 r2533  
    3535class ThreadManager { 
    3636public: 
    37         inline static ThreadID current_thread_id() { 
    38                 return (ThreadID)Raul::Thread::get().context(); 
     37        inline static bool thread_is(ThreadID id) { 
     38                return Raul::Thread::get().is_context(id); 
    3939        } 
    4040 
    4141        inline static void assert_thread(ThreadID id) { 
    42                 assert(single_threaded || current_thread_id() == id); 
     42                assert(single_threaded || Raul::Thread::get().is_context(id)); 
    4343        } 
    4444 
    4545        inline static void assert_not_thread(ThreadID id) { 
    46                 assert(single_threaded || current_thread_id() != id); 
     46                assert(single_threaded || !Raul::Thread::get().is_context(id)); 
    4747        } 
    4848 
  • trunk/ingen/src/engine/wscript

    r2506 r2533  
    5959                internals/Trigger.cpp 
    6060        ''' 
    61  
     61         
     62        if bld.env['HAVE_LADSPA_H'] == 1: 
     63                core_source += ' LADSPAPlugin.cpp LADSPANode.cpp ' 
     64        if bld.env['HAVE_SLV2'] == 1: 
     65                core_source += ' LV2Info.cpp LV2Plugin.cpp LV2Node.cpp ' 
     66         
    6267        obj = bld.new_task_gen('cxx', 'shlib') 
    6368        obj.source = core_source 
    64         if bld.env['HAVE_LADSPA_H'] == 1: 
    65                 obj.source += ' LADSPAPlugin.cpp LADSPANode.cpp ' 
    66         if bld.env['HAVE_SLV2'] == 1: 
    67                 obj.source += ' LV2Info.cpp LV2Plugin.cpp LV2Node.cpp ' 
    6869        obj.export_incdirs = ['.'] 
    6970        obj.includes     = ['.', '..', '../..', '../common'] 
     
    116117                autowaf.use_lib(bld, obj, core_libs + ' JACK') 
    117118 
    118         # Lightweight ingen/lv2 wrapper 
    119         #obj = bld.new_task_gen('cxx', 'shlib') 
    120         #obj.source = core_source 
    121         #if bld.env['HAVE_LADSPA_H'] == 1: 
    122         #       obj.source += ' LADSPAPlugin.cpp LADSPANode.cpp ' 
    123         #if bld.env['HAVE_SLV2'] == 1: 
    124         #       obj.source += ' LV2Plugin.cpp LV2Node.cpp ' 
    125         #obj.export_incdirs = ['.'] 
    126         #obj.includes     = ['.', '..', '../common', './events'] 
    127         #obj.name         = 'ingen_lv2' 
    128         #obj.target       = 'ingen.lv2/ingen_lv2' 
    129         #obj.install_path = '' 
    130         #core_libs = 'GLIBMM GTHREAD LV2CORE SLV2 RAUL REDLANDMM' 
    131         #autowaf.use_lib(bld, obj, core_libs) 
    132  
    133  
     119        # Ingen LV2 wrapper 
     120        obj = bld.new_task_gen('cxx', 'shlib') 
     121        obj.source = ' ingen_lv2.cpp ' 
     122        obj.export_incdirs = ['.'] 
     123        obj.includes     = ['.', '..', '../..', '../common'] 
     124        obj.name         = 'libingen_lv2' 
     125        obj.target       = 'ingen_lv2' 
     126        obj.install_path = '${LIBDIR}/ingen' 
     127        obj.uselib_local = 'libingen_shared libingen_module' 
     128        obj.add_objects  = 'libingen_engine' 
     129        autowaf.use_lib(bld, obj, core_libs) 
  • trunk/ingen/src/gui/App.cpp

    r2515 r2533  
    9191        _about_dialog->property_logo_icon_name() = "ingen"; 
    9292 
    93         PluginModel::set_rdf_world(*world->rdf_world); 
     93        PluginModel::set_rdf_world(*world->rdf_world()); 
    9494 
    9595#ifdef HAVE_SLV2 
    96         PluginModel::set_slv2_world(world->slv2_world); 
     96        PluginModel::set_slv2_world(world->slv2_world()); 
    9797#endif 
    9898} 
     
    110110{ 
    111111        Gnome::Canvas::init(); 
    112         _main = new Gtk::Main(world->argc, world->argv); 
     112        _main = new Gtk::Main(&world->argc(), &world->argv()); 
    113113 
    114114        if (!_instance) 
     
    170170        assert( ! _loader); 
    171171 
    172         _world->engine->register_client(client.get()); 
     172        _world->engine()->register_client(client.get()); 
    173173 
    174174        _client = client; 
    175175        _handle = handle; 
    176         _store  = SharedPtr<ClientStore>(new ClientStore(_world->engine, client)); 
    177         _loader = SharedPtr<ThreadedLoader>(new ThreadedLoader(_world->engine)); 
     176        _store  = SharedPtr<ClientStore>(new ClientStore(_world->uris(), _world->engine(), client)); 
     177        _loader = SharedPtr<ThreadedLoader>(new ThreadedLoader(_world->uris(), _world->engine())); 
    178178 
    179179        _patch_tree_window->init(*_store); 
     
    187187App::detach() 
    188188{ 
    189         if (_world->engine) { 
     189        if (_world->engine()) { 
    190190                _window_factory->clear(); 
    191191                _store->clear(); 
     
    195195                _client.reset(); 
    196196                _handle.reset(); 
    197                 _world->engine.reset(); 
    198         } 
    199 } 
    200  
    201  
    202 const SharedPtr<Serialiser>& 
     197                _world->set_engine(SharedPtr<EngineInterface>()); 
     198        } 
     199} 
     200 
     201 
     202SharedPtr<Serialiser> 
    203203App::serialiser() 
    204204{ 
    205         if (!_world->serialiser) 
     205        if (!_world->serialiser()) 
    206206                _world->load("ingen_serialisation"); 
    207207 
    208         return _world->serialiser; 
     208        return _world->serialiser(); 
    209209} 
    210210 
     
    300300                return false; 
    301301 
    302         if (_world->local_engine) { 
    303                 _world->local_engine->main_iteration(); 
     302        if (_world->local_engine()) { 
     303                _world->local_engine()->main_iteration(); 
    304304        } else { 
    305305                _enable_signal = false; 
     
    327327{ 
    328328        bool quit = true; 
    329         if (App::instance().world()->local_engine) { 
     329        if (App::instance().world()->local_engine()) { 
    330330                Gtk::MessageDialog d(dialog_parent, 
    331331                        "The engine is running in this process.  Quitting will terminate Ingen." 
  • trunk/ingen/src/gui/App.hpp

    r2492 r2533  
    106106        Glib::RefPtr<Gdk::Pixbuf> icon_from_path(const std::string& path, int size); 
    107107 
    108         const SharedPtr<Shared::EngineInterface>&    engine() const { return _world->engine; } 
    109         const SharedPtr<Client::SigClientInterface>& client() const { return _client; } 
    110         const SharedPtr<Client::ClientStore>&        store()  const { return _store; } 
    111         const SharedPtr<ThreadedLoader>&             loader() const { return _loader; } 
     108        SharedPtr<Shared::EngineInterface>    engine() const { return _world->engine(); } 
     109        SharedPtr<Client::SigClientInterface> client() const { return _client; } 
     110        SharedPtr<Client::ClientStore>        store()  const { return _store; } 
     111        SharedPtr<ThreadedLoader>             loader() const { return _loader; } 
    112112 
    113         const SharedPtr<Serialisation::Serialiser>& serialiser(); 
     113        SharedPtr<Serialisation::Serialiser> serialiser(); 
    114114 
    115115        static inline App& instance() { assert(_instance); return *_instance; } 
     
    119119 
    120120        inline Ingen::Shared::World*     world() const { return _world; } 
    121         inline Ingen::Shared::LV2URIMap& uris()  const { return *_world->uris; } 
     121        inline Ingen::Shared::LV2URIMap& uris()  const { return *_world->uris(); } 
    122122 
    123123protected: 
  • trunk/ingen/src/gui/ConnectWindow.cpp

    r2504 r2533  
    7575ConnectWindow::start(Ingen::Shared::World* world) 
    7676{ 
    77         if (world->local_engine) { 
     77        if (world->local_engine()) { 
    7878                _mode = INTERNAL; 
    7979                if (_widgets_loaded) 
     
    8181        } 
    8282 
    83         set_connected_to(world->engine); 
     83        set_connected_to(world->engine()); 
    8484 
    8585        connect(true); 
     
    9090ConnectWindow::set_connected_to(SharedPtr<Shared::EngineInterface> engine) 
    9191{ 
    92         App::instance().world()->engine = engine; 
     92        App::instance().world()->set_engine(engine); 
    9393 
    9494        if (!_widgets_loaded) 
     
    112112                _disconnect_button->set_sensitive(false); 
    113113 
    114                 if (App::instance().world()->local_engine) 
     114                if (App::instance().world()->local_engine()) 
    115115                        _internal_radio->set_sensitive(true); 
    116116                else 
     
    179179 
    180180                if (existing) 
    181                         uri = world->engine->uri().str(); 
     181                        uri = world->engine()->uri().str(); 
    182182 
    183183                // Create client-side listener 
     
    199199#ifdef HAVE_LIBLO 
    200200                        if (scheme == "osc.udp" || scheme == "osc.tcp") 
    201                                 world->engine = SharedPtr<EngineInterface>(new OSCEngineSender(uri)); 
     201                                world->set_engine(SharedPtr<EngineInterface>(new OSCEngineSender(uri))); 
    202202#endif 
    203203#ifdef HAVE_SOUP 
    204204                        if (scheme == "http") 
    205                                 world->engine = SharedPtr<EngineInterface>(new HTTPEngineSender(world, uri)); 
     205                                world->set_engine(SharedPtr<EngineInterface>(new HTTPEngineSender(world, uri))); 
    206206#endif 
    207207                } else { 
    208                         uri = world->engine->uri().str(); 
     208                        uri = world->engine()->uri().str(); 
    209209                        scheme = uri.substr(0, uri.find(":")); 
    210210                } 
     
    224224 
    225225                if (Raul::Process::launch(cmd)) { 
    226                         world->engine = SharedPtr<EngineInterface>( 
    227                                         new OSCEngineSender(string("osc.udp://localhost:").append(port_str))); 
     226                        world->set_engine(SharedPtr<EngineInterface>( 
     227                                        new OSCEngineSender(string("osc.udp://localhost:").append(port_str)))); 
    228228 
    229229                        // FIXME: static args 
     
    247247#endif // defined(HAVE_LIBLO) || defined(HAVE_SOUP) 
    248248        if (_mode == INTERNAL) { 
    249                 if (!world->local_engine) 
     249                if (!world->local_engine()) 
    250250                        world->load("ingen_engine"); 
    251251 
    252252                SharedPtr<SigClientInterface> client(new SigClientInterface()); 
    253253 
    254                 if (!world->local_engine->driver()) 
     254                if (!world->local_engine()->driver()) 
    255255                        world->load("ingen_jack"); 
    256256 
    257                 world->local_engine->activate(); 
     257                world->local_engine()->activate(); 
    258258 
    259259                App::instance().attach(client); 
  • trunk/ingen/src/gui/LoadRemotePatchWindow.cpp

    r2332 r2533  
    6767        _initial_data = data; 
    6868 
    69         Redland::Model model(*App::instance().world()->rdf_world, 
     69        Redland::Model model(*App::instance().world()->rdf_world(), 
    7070                        "http://rdf.drobilla.net/ingen_patches/index.ttl", 
    7171                        "http://rdf.drobilla.net/ingen_patches/"); 
    7272 
    73         Redland::Query query(*App::instance().world()->rdf_world, Glib::ustring( 
     73        Redland::Query query(*App::instance().world()->rdf_world(), Glib::ustring( 
    7474                "SELECT DISTINCT ?name ?uri WHERE {" 
    7575                "  ?uri a            ingen:Patch ;" 
     
    7777                "}")); 
    7878 
    79         Redland::Query::Results results = query.run(*App::instance().world()->rdf_world, model); 
     79        Redland::Query::Results results = query.run(*App::instance().world()->rdf_world(), model); 
    8080 
    8181        for (Redland::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { 
  • trunk/ingen/src/gui/NodeModule.cpp

    r2492 r2533  
    121121 
    122122        if (b && node()->plugin()) { 
    123                 Glib::Mutex::Lock lock(App::instance().world()->rdf_world->mutex()); 
     123                Glib::Mutex::Lock lock(App::instance().world()->rdf_world()->mutex()); 
    124124                const Raul::Atom& name_property = node()->get_property(uris.lv2_name); 
    125125                if (name_property.type() == Atom::STRING) 
  • trunk/ingen/src/gui/PatchCanvas.cpp

    r2523 r2533  
    662662        ++_paste_count; 
    663663 
    664         Builder builder(*App::instance().engine()); 
    665         ClientStore clipboard; 
     664        const LV2URIMap& uris = App::instance().uris(); 
     665 
     666        Builder builder(App::instance().world()->uris(), *App::instance().engine()); 
     667        ClientStore clipboard(App::instance().world()->uris()); 
    666668        clipboard.set_plugins(App::instance().store()->plugins()); 
    667669 
    668         const LV2URIMap& uris = App::instance().uris(); 
    669670 
    670671        // mkdir -p 
  • trunk/ingen/src/gui/Port.cpp

    r2492 r2533  
    193193                Ingen::Shared::World* const world = app.world(); 
    194194                app.engine()->set_property(model()->path(), 
    195                                 world->uris->ingen_value, Atom(value)); 
     195                                world->uris()->ingen_value, Atom(value)); 
    196196                PatchWindow* pw = app.window_factory()->patch_window( 
    197197                                PtrCast<PatchModel>(model()->parent())); 
     
    242242                return NULL; 
    243243 
    244         const Raul::Atom& context = pm->get_property(uris.ctx_context); 
    245         if (!context.is_valid() || context.type() != Atom::URI || context == uris.ctx_AudioContext) 
     244        if (pm->has_context(uris.ctx_AudioContext)) 
    246245                return NULL; 
    247246 
  • trunk/ingen/src/gui/PropertiesWindow.cpp

    r2469 r2533  
    1919#include <string> 
    2020#include "raul/log.hpp" 
    21 #include "module/ingen_module.hpp" 
    2221#include "module/World.hpp" 
    2322#include "client/NodeModel.hpp" 
     
    9089        set_title(model->path().chop_scheme() + " Properties - Ingen"); 
    9190 
    92         Shared::World* world = ingen_get_world(); 
     91        Shared::World* world = App::instance().world(); 
    9392 
    9493        ostringstream ss; 
     
    101100 
    102101                // Column 0: Property 
    103                 Gtk::Label* lab = manage(new Gtk::Label(world->rdf_world->qualify(i->first.str()), 0.0, 0.5)); 
     102                Gtk::Label* lab = manage(new Gtk::Label(world->rdf_world()->qualify(i->first.str()), 0.0, 0.5)); 
    104103                _table->attach(*lab, 0, 1, n_rows, n_rows + 1, Gtk::FILL|Gtk::SHRINK, Gtk::SHRINK); 
    105104 
  • trunk/ingen/src/gui/ThreadedLoader.cpp

    r2525 r2533  
    3232 
    3333 
    34 ThreadedLoader::ThreadedLoader(SharedPtr<EngineInterface> engine) 
     34ThreadedLoader::ThreadedLoader(SharedPtr<Shared::LV2URIMap> uris, SharedPtr<EngineInterface> engine) 
    3535        : _engine(engine) 
    36         , _deprecated_loader(engine) 
     36        , _deprecated_loader(uris, engine) 
    3737{ 
    3838        set_name("Loader"); 
     
    4848ThreadedLoader::parser() 
    4949{ 
    50         Ingen::Shared::World* world = ingen_get_world(); 
     50        Ingen::Shared::World* world = App::instance().world(); 
    5151 
    52         if (!world->parser) 
     52        if (!world->parser()) 
    5353                world->load("ingen_serialisation"); 
    5454 
    55         return world->parser; 
     55        return world->parser(); 
    5656} 
    5757 
     
    8080        _mutex.lock(); 
    8181 
    82         Ingen::Shared::World* world = ingen_get_world(); 
     82        Ingen::Shared::World* world = App::instance().world(); 
    8383 
    8484        Glib::ustring engine_base = ""; 
     
    102102        } else { 
    103103                _events.push_back(sigc::hide_return(sigc::bind( 
    104                                 sigc::mem_fun(world->parser.get(), &Ingen::Serialisation::Parser::parse_document), 
     104                                sigc::mem_fun(world->parser().get(), &Ingen::Serialisation::Parser::parse_document), 
    105105                                App::instance().world(), 
    106                                 App::instance().world()->engine.get(), 
     106                                App::instance().world()->engine().get(), 
    107107                                document_uri, 
    108108                                data_path, 
  • trunk/ingen/src/gui/ThreadedLoader.hpp

    r2398 r2533  
    5656{ 
    5757public: 
    58         ThreadedLoader(SharedPtr<EngineInterface> engine); 
     58        ThreadedLoader(SharedPtr<Shared::LV2URIMap> uris, SharedPtr<EngineInterface> engine); 
    5959 
    6060        void load_patch(bool                              merge, 
  • trunk/ingen/src/ingen/main.cpp

    r2525 r2533  
    3131#include "redlandmm/World.hpp" 
    3232#include "interface/EngineInterface.hpp" 
     33#include "shared/Configuration.hpp" 
    3334#include "shared/runtime_paths.hpp" 
    3435#include "module/ingen_module.hpp" 
     
    4546using namespace Ingen; 
    4647 
    47 SharedPtr<Ingen::Engine> engine; 
     48Ingen::Shared::World* world = NULL; 
    4849 
    4950void 
     
    5152{ 
    5253        cout << "ingen: Interrupted" << endl; 
    53         engine->quit(); 
     54        if (world->local_engine()) 
     55                world->local_engine()->quit(); 
     56        ingen_world_free(world); 
     57        exit(1); 
    5458} 
    5559 
     
    5862{ 
    5963        cerr << "ingen: Error: " << msg << endl; 
    60         ingen_destroy_world(); 
     64        ingen_world_free(world); 
    6165        exit(1); 
    6266} 
     
    6569main(int argc, char** argv) 
    6670{ 
    67         Raul::Configuration conf("A realtime modular audio processor.", 
    68         "Ingen is a flexible modular system that be used in various ways.\n" 
    69         "The engine can run as a stand-alone server controlled via a network protocol\n" 
    70         "(e.g. OSC), or internal to another process (e.g. the GUI).  The GUI, or other\n" 
    71         "clients, can communicate with the engine via any supported protocol, or host the\n" 
    72         "engine in the same process.  Many clients can connect to an engine at once.\n\n" 
    73         "Examples:\n" 
    74         "  ingen -e                     # Run an engine, listen for OSC\n" 
    75         "  ingen -g                     # Run a GUI, connect via OSC\n" 
    76         "  ingen -eg                    # Run an engine and a GUI in one process\n" 
    77         "  ingen -egl patch.ing.ttl     # Run an engine and a GUI and load a patch file\n" 
    78         "  ingen -egl patch.ing.lv2     # Run an engine and a GUI and load a patch bundle"); 
    79  
    80         conf.add("client-port", 'C', "Client OSC port", Atom::INT, Atom()) 
    81                 .add("connect",     'c', "Connect to engine URI", Atom::STRING, "osc.udp://localhost:16180") 
    82                 .add("engine",      'e', "Run (JACK) engine", Atom::BOOL, false) 
    83                 .add("engine-port", 'E', "Engine listen port", Atom::INT,  16180) 
    84                 .add("gui",         'g', "Launch the GTK graphical interface", Atom::BOOL, false) 
    85                 .add("help",        'h', "Print this help message", Atom::BOOL, false) 
    86                 .add("jack-client", 'n', "JACK client name", Atom::STRING, "ingen") 
    87                 .add("jack-server", 's', "JACK server name", Atom::STRING, "default") 
    88                 .add("load",        'l', "Load patch", Atom::STRING, Atom()) 
    89                 .add("parallelism", 'p', "Number of concurrent process threads", Atom::INT, 1) 
    90                 .add("path",        'L', "Target path for loaded patch", Atom::STRING, Atom()) 
    91                 .add("run",         'r', "Run script", Atom::STRING, Atom()); 
     71        Shared::Configuration conf; 
    9272 
    9373        // Parse command line options 
     
    10888        } 
    10989 
     90#ifdef BUNDLE 
    11091        // Set bundle path from executable location so resources/modules can be found 
    11192        Shared::set_bundle_path_from_code((void*)&main); 
     93#endif 
    11294 
    11395        SharedPtr<Shared::EngineInterface> engine_interface; 
     
    118100#endif 
    119101 
    120         Ingen::Shared::World* world = ingen_get_world(); 
    121  
    122         world->argc = argc; 
    123         world->argv = argv; 
    124         world->conf = &conf; 
    125  
    126         // Set up RDF namespaces 
    127         world->rdf_world->add_prefix("dc",      "http://purl.org/dc/elements/1.1/"); 
    128         world->rdf_world->add_prefix("doap",    "http://usefulinc.com/ns/doap#"); 
    129         world->rdf_world->add_prefix("ingen",   "http://drobilla.net/ns/ingen#"); 
    130         world->rdf_world->add_prefix("ingenui", "http://drobilla.net/ns/ingenuity#"); 
    131         world->rdf_world->add_prefix("lv2",     "http://lv2plug.in/ns/lv2core#"); 
    132         world->rdf_world->add_prefix("lv2ev",   "http://lv2plug.in/ns/ext/event#"); 
    133         world->rdf_world->add_prefix("ctx",     "http://lv2plug.in/ns/dev/contexts#"); 
    134         world->rdf_world->add_prefix("lv2midi", "http://lv2plug.in/ns/ext/midi#"); 
    135         world->rdf_world->add_prefix("midi",    "http://drobilla.net/ns/dev/midi#"); 
    136         world->rdf_world->add_prefix("owl",     "http://www.w3.org/2002/07/owl#"); 
    137         world->rdf_world->add_prefix("rdfs",    "http://www.w3.org/2000/01/rdf-schema#"); 
    138         world->rdf_world->add_prefix("sp",      "http://lv2plug.in/ns/dev/string-port#"); 
    139         world->rdf_world->add_prefix("xsd",     "http://www.w3.org/2001/XMLSchema#"); 
     102        Ingen::Shared::World* world = ingen_world_new(&conf, argc, argv); 
     103 
     104        assert(!world->local_engine()); 
    140105 
    141106        // Run engine 
     
    144109                        ingen_abort("Unable to load engine module"); 
    145110 
    146                 if (!world->local_engine) 
     111                if (!world->local_engine()) 
    147112                        ingen_abort("Unable to create engine"); 
    148113 
    149                 engine = world->local_engine; 
    150                 engine_interface = world->engine; 
     114                engine_interface = world->engine(); 
    151115 
    152116                // Not loading a GUI, load network engine interfaces 
     
    176140 
    177141        // Activate the engine, if we have one 
    178         if (engine) { 
     142        if (world->local_engine()) { 
    179143                if (!world->load("ingen_jack")) 
    180144                        ingen_abort("Unable to load jack module"); 
    181145 
    182                 engine->activate(); 
    183         } 
    184  
    185         world->engine = engine_interface; 
     146                world->local_engine()->activate(); 
     147        } 
     148 
     149        world->set_engine(engine_interface); 
    186150 
    187151        // Load a patch 
     
    207171                        ingen_abort("Unable to load serialisation module"); 
    208172 
    209                 if (world->parser) { 
     173                if (world->parser()) { 
    210174                        // Assumption:  Containing ':' means URI, otherwise filename 
    211175                        string uri = conf.option("load").get_string(); 
     
    221185                        if (conf.option("gui").get_bool()) 
    222186                                engine_interface->get("ingen:plugins"); 
    223                         world->parser->parse_document( 
     187                        world->parser()->parse_document( 
    224188                                        world, engine_interface.get(), uri, data_path, parent, symbol); 
    225189 
     
    246210 
    247211        // Listen to OSC and run main loop 
    248         } else if (engine && !conf.option("gui").get_bool()) { 
     212        } else if (world->local_engine() && !conf.option("gui").get_bool()) { 
    249213                signal(SIGINT, ingen_interrupt); 
    250214                signal(SIGTERM, ingen_interrupt); 
    251                 engine->main(); // Block here 
     215                world->local_engine()->main(); // Block here 
    252216        } 
    253217 
    254218        // Shut down 
    255         if (engine) { 
    256                 engine->deactivate(); 
    257                 engine.reset(); 
    258         } 
    259  
    260         ingen_destroy_world(); 
     219        if (world->local_engine()) 
     220                world->local_engine()->deactivate(); 
     221 
     222        ingen_world_free(world); 
    261223 
    262224        return 0; 
  • trunk/ingen/src/module/ingen_module.cpp

    r2408 r2533  
    2929extern "C" { 
    3030 
    31 static Ingen::Shared::World* world = NULL; 
    32  
    3331Ingen::Shared::World* 
    34 ingen_get_world() 
     32ingen_world_new(Raul::Configuration* conf, int& argc, char**& argv) 
    3533{ 
    36     static Ingen::Shared::World* world = NULL; 
    37  
    38         if (!world) { 
    39                 world = new Ingen::Shared::World(); 
    40         world->rdf_world = new Redland::World(); 
    41 #ifdef HAVE_SLV2 
    42                 world->slv2_world = slv2_world_new_using_rdf_world(world->rdf_world->world()); 
    43                 world->lv2_features = new Ingen::Shared::LV2Features(); 
    44                 world->uris = PtrCast<Ingen::Shared::LV2URIMap>( 
    45                                 world->lv2_features->feature(LV2_URI_MAP_URI)); 
    46                 slv2_world_load_all(world->slv2_world); 
    47 #else 
    48                 world->uris = SharedPtr<Ingen::Shared::LV2URIMap>( 
    49                                 new Ingen::Shared::LV2URIMap()); 
    50 #endif 
    51                 world->engine.reset(); 
    52                 world->local_engine.reset(); 
    53         } 
    54  
    55         return world; 
     34        return new Ingen::Shared::World(conf, argc, argv); 
    5635} 
    5736 
    5837void 
    59 ingen_destroy_world() 
     38ingen_world_free(Ingen::Shared::World* world) 
    6039{ 
    61         if (world) { 
    62                 world->unload_all(); 
    63 #ifdef HAVE_SLV2 
    64                 slv2_world_free(world->slv2_world); 
    65                 delete world->lv2_features; 
    66 #endif 
    67         delete world->rdf_world; 
    68                 delete world; 
    69                 world = NULL; 
    70         } 
     40        delete world; 
    7141} 
    7242 
  • trunk/ingen/src/module/ingen_module.hpp

    r2398 r2533  
    1919#define INGEN_MODULE_HPP 
    2020 
     21namespace Raul { class Configuration; } 
     22 
    2123namespace Ingen { namespace Shared { class World; } } 
    2224 
    2325extern "C" { 
    2426 
    25 Ingen::Shared::World* ingen_get_world(); 
    26 void                  ingen_destroy_world(); 
     27Ingen::Shared::World* ingen_world_new(Raul::Configuration* conf, int& argc, char**& argv); 
     28void                  ingen_world_free(Ingen::Shared::World* world); 
    2729 
    2830} // extern "C" 
  • trunk/ingen/src/module/World.cpp

    r2414 r2533  
    1616 */ 
    1717 
     18#include "ingen-config.h" 
     19#include <boost/utility.hpp> 
    1820#include <glibmm/module.h> 
    1921#include <glibmm/miscutils.h> 
    2022#include <glibmm/fileutils.h> 
     23#ifdef HAVE_SLV2 
     24#include "slv2/slv2.h" 
     25#endif 
    2126#include "raul/log.hpp" 
    22 #include "ingen-config.h" 
     27#include "redlandmm/World.hpp" 
    2328#include "shared/runtime_paths.hpp" 
     29#include "shared/LV2Features.hpp" 
     30#include "shared/LV2URIMap.hpp" 
    2431#include "World.hpp" 
    2532 
     
    8693} 
    8794 
     95 
     96struct WorldImpl : public boost::noncopyable { 
     97        WorldImpl(Raul::Configuration* conf, int& a_argc, char**& a_argv) 
     98                : argc(a_argc) 
     99                , argv(a_argv) 
     100                , conf(conf) 
     101                , lv2_features(NULL) 
     102                , rdf_world(new Redland::World()) 
     103                , uris(new Shared::LV2URIMap()) 
     104#ifdef HAVE_SLV2 
     105                , slv2_world(slv2_world_new_using_rdf_world(rdf_world->c_obj())) 
     106#endif 
     107        { 
     108#ifdef HAVE_SLV2 
     109                lv2_features = new Ingen::Shared::LV2Features(); 
     110                lv2_features->add_feature(LV2_URI_MAP_URI, uris); 
     111                slv2_world_load_all(slv2_world); 
     112#endif 
     113 
     114                // Set up RDF namespaces 
     115                rdf_world->add_prefix("dc",      "http://purl.org/dc/elements/1.1/"); 
     116                rdf_world->add_prefix("doap",    "http://usefulinc.com/ns/doap#"); 
     117                rdf_world->add_prefix("ingen",   "http://drobilla.net/ns/ingen#"); 
     118                rdf_world->add_prefix("ingenui", "http://drobilla.net/ns/ingenuity#"); 
     119                rdf_world->add_prefix("lv2",     "http://lv2plug.in/ns/lv2core#"); 
     120                rdf_world->add_prefix("lv2ev",   "http://lv2plug.in/ns/ext/event#"); 
     121                rdf_world->add_prefix("ctx",     "http://lv2plug.in/ns/dev/contexts#"); 
     122                rdf_world->add_prefix("lv2midi", "http://lv2plug.in/ns/ext/midi#"); 
     123                rdf_world->add_prefix("midi",    "http://drobilla.net/ns/dev/midi#"); 
     124                rdf_world->add_prefix("owl",     "http://www.w3.org/2002/07/owl#"); 
     125                rdf_world->add_prefix("rdfs",    "http://www.w3.org/2000/01/rdf-schema#"); 
     126                rdf_world->add_prefix("sp",      "http://lv2plug.in/ns/dev/string-port#"); 
     127                rdf_world->add_prefix("xsd",     "http://www.w3.org/2001/XMLSchema#"); 
     128        } 
     129 
     130        virtual ~WorldImpl() 
     131        { 
     132                modules.clear(); 
     133                interface_factories.clear(); 
     134                script_runners.clear(); 
     135 
     136        #ifdef HAVE_SLV2 
     137                slv2_world_free(slv2_world); 
     138                slv2_world = NULL; 
     139        #endif 
     140 
     141                delete rdf_world; 
     142                rdf_world = NULL; 
     143 
     144                delete lv2_features; 
     145                lv2_features = NULL; 
     146 
     147                uris.reset(); 
     148        } 
     149 
     150        typedef std::map< const std::string, SharedPtr<Module> > Modules; 
     151        Modules modules; 
     152 
     153        typedef std::map<const std::string, World::InterfaceFactory> InterfaceFactories; 
     154        InterfaceFactories interface_factories; 
     155 
     156        typedef bool (*ScriptRunner)(World* world, const char* filename); 
     157        typedef std::map<const std::string, ScriptRunner> ScriptRunners; 
     158        ScriptRunners script_runners; 
     159 
     160        int&                                 argc; 
     161        char**&                              argv; 
     162        Raul::Configuration*                 conf; 
     163        LV2Features*                         lv2_features; 
     164        Redland::World*                      rdf_world; 
     165        SharedPtr<LV2URIMap>                 uris; 
     166    SharedPtr<EngineInterface>           engine; 
     167        SharedPtr<Engine>                    local_engine; 
     168    SharedPtr<Serialisation::Serialiser> serialiser; 
     169    SharedPtr<Serialisation::Parser>     parser; 
     170    SharedPtr<Store>                     store; 
     171#ifdef HAVE_SLV2 
     172    SLV2World                            slv2_world; 
     173#endif 
     174}; 
     175 
     176 
     177World::World(Raul::Configuration* conf, int& argc, char**& argv) 
     178        : _impl(new WorldImpl(conf, argc, argv)) 
     179{ 
     180} 
     181 
     182 
     183World::~World() 
     184{ 
     185        unload_all(); 
     186        delete _impl; 
     187} 
     188 
     189void World::set_local_engine(SharedPtr<Engine> e)                  { _impl->local_engine = e; } 
     190void World::set_engine(SharedPtr<EngineInterface> e)               { _impl->engine = e; } 
     191void World::set_serialiser(SharedPtr<Serialisation::Serialiser> s) { _impl->serialiser = s; } 
     192void World::set_parser(SharedPtr<Serialisation::Parser> p)         { _impl->parser = p; } 
     193void World::set_store(SharedPtr<Store> s)                          { _impl->store = s; } 
     194void World::set_conf(Raul::Configuration* c)                       { _impl->conf = c; } 
     195 
     196int&                                 World::argc()         { return _impl->argc; } 
     197char**&                              World::argv()         { return _impl->argv; } 
     198SharedPtr<Engine>                    World::local_engine() { return _impl->local_engine; } 
     199SharedPtr<EngineInterface>           World::engine()       { return _impl->engine; } 
     200SharedPtr<Serialisation::Serialiser> World::serialiser()   { return _impl->serialiser; } 
     201SharedPtr<Serialisation::Parser>     World::parser()       { return _impl->parser; } 
     202SharedPtr<Store>                     World::store()        { return _impl->store; } 
     203Raul::Configuration*                 World::conf()         { return _impl->conf; } 
     204LV2Features*                         World::lv2_features() { return _impl->lv2_features; } 
     205 
     206#ifdef HAVE_SLV2 
     207SLV2World            World::slv2_world() { return _impl->slv2_world; } 
     208#endif 
     209Redland::World*      World::rdf_world() { return _impl->rdf_world; } 
     210SharedPtr<LV2URIMap> World::uris()      { return _impl->uris; } 
     211 
     212 
    88213/** Load an Ingen module. 
    89214 * @return true on success, false on failure 
     
    98223                module->library = lib; 
    99224                module->load(this); 
    100                 modules.insert(make_pair(string(name), module)); 
     225                _impl->modules.insert(make_pair(string(name), module)); 
    101226                return true; 
    102227        } else { 
     
    112237World::unload_all() 
    113238{ 
    114         modules.clear(); 
     239        _impl->modules.clear(); 
    115240} 
    116241 
     
    122247{ 
    123248        const string scheme = url.substr(0, url.find(":")); 
    124         const InterfaceFactories::const_iterator i = interface_factories.find(scheme); 
    125         if (i == interface_factories.end()) { 
     249        const WorldImpl::InterfaceFactories::const_iterator i = _impl->interface_factories.find(scheme); 
     250        if (i == _impl->interface_factories.end()) { 
    126251                warn << "Unknown URI scheme `" << scheme << "'" << endl; 
    127252                return SharedPtr<Ingen::Shared::EngineInterface>(); 
     
    136261World::run(const std::string& mime_type, const std::string& filename) 
    137262{ 
    138         const ScriptRunners::const_iterator i = script_runners.find(mime_type); 
    139         if (i == script_runners.end()) { 
     263        const WorldImpl::ScriptRunners::const_iterator i = _impl->script_runners.find(mime_type); 
     264        if (i == _impl->script_runners.end()) { 
    140265                warn << "Unknown script MIME type `" << mime_type << "'" << endl; 
    141266                return false; 
     
    148273World::add_interface_factory(const std::string& scheme, InterfaceFactory factory) 
    149274{ 
    150         interface_factories.insert(make_pair(scheme, factory)); 
     275        _impl->interface_factories.insert(make_pair(scheme, factory)); 
    151276} 
    152277 
  • trunk/ingen/src/module/World.hpp

    r2484 r2533  
    2222#include <string> 
    2323#include <boost/shared_ptr.hpp> 
     24#include <boost/utility.hpp> 
    2425#include <glibmm/module.h> 
     26#include "ingen-config.h" 
    2527#include "raul/Configuration.hpp" 
     28#include "raul/SharedPtr.hpp" 
    2629#include "Module.hpp" 
     30#include "module/ingen_module.hpp" 
    2731 
     32#ifdef HAVE_SLV2 
    2833typedef struct _SLV2World* SLV2World; 
     34#endif 
    2935 
    3036namespace Redland { class World; } 
     
    4248class LV2Features; 
    4349class LV2URIMap; 
     50struct WorldImpl; 
    4451 
    4552 
     
    5360 * set World::serialiser and World::parser to valid objects. 
    5461 */ 
    55 struct World { 
    56         World() : argc(0), argv(0), conf(0), rdf_world(0), slv2_world(0), lv2_features(0) {} 
     62class World : public boost::noncopyable { 
     63        friend Ingen::Shared::World* ::ingen_world_new(Raul::Configuration*, int&, char**&); 
     64        World(Raul::Configuration* conf, int& argc, char**& argv); 
    5765 
    58         bool load(const char* name); 
    59         void unload_all(); 
     66        friend void ::ingen_world_free(Ingen::Shared::World* world); 
     67        virtual ~World(); 
     68 
     69        WorldImpl* _impl; 
     70 
     71public: 
     72        virtual bool load(const char* name); 
     73        virtual void unload_all(); 
    6074 
    6175        typedef SharedPtr<Ingen::Shared::EngineInterface> (*InterfaceFactory)( 
    6276                        World* world, const std::string& engine_url); 
    6377 
    64         void add_interface_factory(const std::string& scheme, InterfaceFactory factory); 
    65         SharedPtr<Ingen::Shared::EngineInterface> interface(const std::string& engine_url); 
     78        virtual void add_interface_factory(const std::string& scheme, InterfaceFactory factory); 
     79        virtual SharedPtr<Ingen::Shared::EngineInterface> interface(const std::string& engine_url); 
    6680 
    67         bool run(const std::string& mime_type, const std::string& filename); 
     81        virtual bool run(const std::string& mime_type, const std::string& filename); 
    6882 
    69         int                  argc; 
    70         char**               argv; 
    71         Raul::Configuration* conf; 
     83        virtual void set_local_engine(SharedPtr<Engine> e); 
     84        virtual void set_engine(SharedPtr<EngineInterface> e); 
     85        virtual void set_serialiser(SharedPtr<Serialisation::Serialiser> s); 
     86        virtual void set_parser(SharedPtr<Serialisation::Parser> p); 
     87        virtual void set_store(SharedPtr<Store> s); 
    7288 
    73         Redland::World*      rdf_world; 
    74     SLV2World            slv2_world; 
    75         LV2Features*         lv2_features; 
     89        virtual SharedPtr<Engine>                    local_engine(); 
     90        virtual SharedPtr<EngineInterface>           engine(); 
     91        virtual SharedPtr<Serialisation::Serialiser> serialiser(); 
     92        virtual SharedPtr<Serialisation::Parser>     parser(); 
     93        virtual SharedPtr<Store>                     store(); 
    7694 
    77         boost::shared_ptr<LV2URIMap> uris; 
     95        virtual Redland::World*      rdf_world(); 
     96        virtual SharedPtr<LV2URIMap> uris(); 
    7897 
    79     boost::shared_ptr<EngineInterface>           engine; 
    80     boost::shared_ptr<Engine>                    local_engine; 
    81     boost::shared_ptr<Serialisation::Serialiser> serialiser; 
    82     boost::shared_ptr<Serialisation::Parser>     parser; 
    83     boost::shared_ptr<Store>                     store; 
     98        virtual int&    argc(); 
     99        virtual char**& argv(); 
    84100 
    85 private: 
    86         typedef std::map< const std::string, boost::shared_ptr<Module> > Modules; 
    87         Modules modules; 
     101        virtual Raul::Configuration* conf(); 
     102        virtual void set_conf(Raul::Configuration* c); 
    88103 
    89         typedef std::map<const std::string, InterfaceFactory> InterfaceFactories; 
    90         InterfaceFactories interface_factories; 
     104        virtual LV2Features* lv2_features(); 
    91105 
    92         typedef bool (*ScriptRunner)(World* world, const char* filename); 
    93         typedef std::map<const std::string, ScriptRunner> ScriptRunners; 
    94         ScriptRunners script_runners; 
     106#ifdef HAVE_SLV2 
     107        virtual SLV2World slv2_world(); 
     108#endif 
    95109}; 
    96110 
  • trunk/ingen/src/serialisation/Parser.cpp

    r2525 r2533  
    7272 
    7373 
     74Parser::PatchRecords 
     75Parser::find_patches( 
     76        Ingen::Shared::World* world, 
     77        const Glib::ustring&  manifest_uri) 
     78{ 
     79        Redland::Model model(*world->rdf_world(), manifest_uri, manifest_uri); 
     80        Redland::Query query(*world->rdf_world(), 
     81                "SELECT DISTINCT ?patch ?file WHERE {\n" 
     82                "?patch a            ingen:Patch ;\n" 
     83                "       rdfs:seeAlso ?file .\n" 
     84                "}"); 
     85 
     86        std::list<PatchRecord> records; 
     87 
     88        Redland::Query::Results results(query.run(*world->rdf_world(), model, manifest_uri)); 
     89        for (Redland::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { 
     90                const Redland::Node& patch((*i)["patch"]); 
     91                const Redland::Node& file((*i)["file"]); 
     92                records.push_back(PatchRecord(patch.to_c_string(), file.to_c_string())); 
     93        } 
     94 
     95        return records; 
     96} 
     97 
     98 
    7499/** Parse a patch from RDF into a CommonInterface (engine or client). 
    75100 * @return whether or not load was successful. 
     
    97122        } 
    98123 
    99         Redland::Model model(*world->rdf_world, document_uri, document_uri); 
     124        Redland::Model model(*world->rdf_world(), document_uri, document_uri); 
    100125 
    101126        LOG(info) << "Parsing " << document_uri << endl; 
     
    132157                boost::optional<GraphObject::Properties> data) 
    133158{ 
    134         Redland::Model model(*world->rdf_world, str.c_str(), str.length(), base_uri); 
     159        Redland::Model model(*world->rdf_world(), str.c_str(), str.length(), base_uri); 
    135160 
    136161        LOG(info) << "Parsing " << (data_path ? data_path->str() : "*") << " from string"; 
     
    140165 
    141166        bool ret = parse(world, target, model, base_uri, data_path, parent, symbol, data); 
    142         Redland::Resource subject(*world->rdf_world, base_uri); 
     167        Redland::Resource subject(*world->rdf_world(), base_uri); 
    143168        parse_connections(world, target, model, subject, parent ? *parent : "/"); 
    144169 
     
    158183                boost::optional<GraphObject::Properties> data) 
    159184{ 
    160         Redland::Model model(*world->rdf_world, str.c_str(), str.length(), base_uri); 
    161  
    162         std::cout << "PARSE UPDATE " << str << endl; 
     185        Redland::Model model(*world->rdf_world(), str.c_str(), str.length(), base_uri); 
    163186 
    164187        // Delete anything explicitly declared to not exist 
    165188        Glib::ustring query_str = Glib::ustring("SELECT DISTINCT ?o WHERE { ?o a owl:Nothing }"); 
    166         Redland::Query query(*world->rdf_world, query_str); 
    167         Redland::Query::Results results = query.run(*world->rdf_world, model, base_uri); 
     189        Redland::Query query(*world->rdf_world(), query_str); 
     190        Redland::Query::Results results = query.run(*world->rdf_world(), model, base_uri); 
    168191 
    169192        for (Redland::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { 
     
    173196 
    174197        // Properties 
    175         query = Redland::Query(*world->rdf_world, 
     198        query = Redland::Query(*world->rdf_world(), 
    176199                "SELECT DISTINCT ?s ?p ?o WHERE {\n" 
    177200                "?s ?p ?o .\n" 
    178201                "}"); 
    179202 
    180         results = Redland::Query::Results(query.run(*world->rdf_world, model, base_uri)); 
     203        results = Redland::Query::Results(query.run(*world->rdf_world(), model, base_uri)); 
    181204 
    182205        for (Redland::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { 
    183                 Glib::Mutex::Lock lock(world->rdf_world->mutex()); 
     206                Glib::Mutex::Lock lock(world->rdf_world()->mutex()); 
    184207                string               obj_uri((*i)["s"].to_string()); 
    185208                const string         key((*i)["p"].to_string()); 
     
    195218 
    196219        // Connections 
    197         Redland::Resource subject(*world->rdf_world, base_uri); 
     220        Redland::Resource subject(*world->rdf_world(), base_uri); 
    198221        parse_connections(world, target, model, subject, "/"); 
    199222 
    200223        // Port values 
    201         query = Redland::Query(*world->rdf_world, 
     224        query = Redland::Query(*world->rdf_world(), 
    202225                "SELECT DISTINCT ?path ?value WHERE {\n" 
    203226                "?path ingen:value ?value .\n" 
    204227                "}"); 
    205228 
    206         results = Redland::Query::Results(query.run(*world->rdf_world, model, base_uri)); 
     229        results = Redland::Query::Results(query.run(*world->rdf_world(), model, base_uri)); 
    207230 
    208231        for (Redland::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { 
    209                 Glib::Mutex::Lock lock(world->rdf_world->mutex()); 
     232                Glib::Mutex::Lock lock(world->rdf_world()->mutex()); 
    210233                const string obj_path = (*i)["path"].to_string(); 
    211234                const Redland::Node& val_node = (*i)["value"]; 
    212235                const Atom a(AtomRDF::node_to_atom(model, val_node)); 
    213                 target->set_property(obj_path, world->uris->ingen_value, a); 
     236                target->set_property(obj_path, world->uris()->ingen_value, a); 
    214237        } 
    215238 
     
    235258                : Glib::ustring("SELECT DISTINCT ?s ?t WHERE { ?s a ?t . }"); 
    236259 
    237         Redland::Query query(*world->rdf_world, query_str); 
    238         Redland::Query::Results results(query.run(*world->rdf_world, model, document_uri)); 
     260        Redland::Query query(*world->rdf_world(), query_str); 
     261        Redland::Query::Results results(query.run(*world->rdf_world(), model, document_uri)); 
    239262 
    240263#define NS_INGEN "http://drobilla.net/ns/ingen#" 
    241264#define NS_LV2   "http://lv2plug.in/ns/lv2core#" 
    242265 
    243         const Redland::Node patch_class    (*world->rdf_world, res, NS_INGEN "Patch"); 
    244         const Redland::Node node_class     (*world->rdf_world, res, NS_INGEN "Node"); 
    245         const Redland::Node internal_class (*world->rdf_world, res, NS_INGEN "Internal"); 
    246         const Redland::Node ladspa_class   (*world->rdf_world, res, NS_INGEN "LADSPAPlugin"); 
    247         const Redland::Node in_port_class  (*world->rdf_world, res, NS_LV2 "InputPort"); 
    248         const Redland::Node out_port_class (*world->rdf_world, res, NS_LV2 "OutputPort"); 
    249         const Redland::Node lv2_class      (*world->rdf_world, res, NS_LV2 "Plugin"); 
     266        const Redland::Node patch_class    (*world->rdf_world(), res, NS_INGEN "Patch"); 
     267        const Redland::Node node_class     (*world->rdf_world(), res, NS_INGEN "Node"); 
     268        const Redland::Node internal_class (*world->rdf_world(), res, NS_INGEN "Internal"); 
     269        const Redland::Node ladspa_class   (*world->rdf_world(), res, NS_INGEN "LADSPAPlugin"); 
     270        const Redland::Node in_port_class  (*world->rdf_world(), res, NS_LV2 "InputPort"); 
     271        const Redland::Node out_port_class (*world->rdf_world(), res, NS_LV2 "OutputPort"); 
     272        const Redland::Node lv2_class      (*world->rdf_world(), res, NS_LV2 "Plugin"); 
    250273 
    251274        const Redland::Node subject_node = (data_path && !data_path->is_root()) 
    252                 ? Redland::Node(*world->rdf_world, res, data_path->chop_start("/")) 
     275                ? Redland::Node(*world->rdf_world(), res, data_path->chop_start("/")) 
    253276                : model.base_uri(); 
    254277 
     
    299322                        } else if (rdf_class == in_port_class || rdf_class == out_port_class) { 
    300323                                parse_properties(world, target, model, subject, path, data); 
     324                                ret = path; 
    301325                        } 
    302326 
     
    334358                boost::optional<GraphObject::Properties> data) 
    335359{ 
    336         const LV2URIMap& uris = *world->uris.get(); 
     360        const LV2URIMap& uris = *world->uris().get(); 
    337361        uint32_t patch_poly = 0; 
    338362 
     
    350374        /* Load polyphony from file if necessary */ 
    351375        if (patch_poly == 0) { 
    352                 Redland::Query query(*world->rdf_world, Glib::ustring( 
     376                Redland::Query query(*world->rdf_world(), Glib::ustring( 
    353377                        "SELECT DISTINCT ?poly WHERE { ") + subject + " ingen:polyphony ?poly }"); 
    354378 
    355                 Results results = query.run(*world->rdf_world, model); 
     379                Results results = query.run(*world->rdf_world(), model); 
    356380                if (results.size() > 0) { 
    357381                        const Redland::Node& poly_node = (*results.begin())["poly"]; 
     
    396420 
    397421        /* Find patches in document */ 
    398         Redland::Query query(*world->rdf_world, Glib::ustring( 
     422        Redland::Query query(*world->rdf_world(), Glib::ustring( 
    399423                "SELECT DISTINCT ?patch WHERE {\n") + 
    400424                        "?patch a ingen:Patch .\n" 
    401425                "}"); 
    402426        set<string> patches; 
    403         Results results = query.run(*world->rdf_world, model, base_uri); 
     427        Results results = query.run(*world->rdf_world(), model, base_uri); 
    404428        for (Results::iterator i = results.begin(); i != results.end(); ++i) { 
    405                 Glib::Mutex::Lock lock(world->rdf_world->mutex()); 
     429                Glib::Mutex::Lock lock(world->rdf_world()->mutex()); 
    406430                patches.insert((*i)["patch"].to_string()); 
    407431        } 
     
    414438 
    415439        /* Find nodes on this patch */ 
    416         query = Redland::Query(*world->rdf_world, Glib::ustring( 
     440        query = Redland::Query(*world->rdf_world(), Glib::ustring( 
    417441                "SELECT DISTINCT ?node ?type WHERE {\n") + 
    418442                        subject + " ingen:node     ?node .\n" 
     
    423447        Resources resources; 
    424448        Types     types; 
    425         results = query.run(*world->rdf_world, model, base_uri); 
     449        results = query.run(*world->rdf_world(), model, base_uri); 
    426450        for (Results::iterator i = results.begin(); i != results.end(); ++i) { 
    427                 Glib::Mutex::Lock lock(world->rdf_world->mutex()); 
     451                Glib::Mutex::Lock lock(world->rdf_world()->mutex()); 
    428452                Redland::Node& node = (*i)["node"]; 
    429453                Redland::Node& type = (*i)["type"]; 
     
    441465 
    442466        /* Load nodes on this patch */ 
    443         query = Redland::Query(*world->rdf_world, Glib::ustring( 
     467        query = Redland::Query(*world->rdf_world(), Glib::ustring( 
    444468                "SELECT DISTINCT ?node ?predicate ?object WHERE {\n") + 
    445469                        subject + " ingen:node ?node .\n" 
    446470                        "?node      ?predicate ?object .\n" 
    447471                "}"); 
    448         results = query.run(*world->rdf_world, model, base_uri); 
     472        results = query.run(*world->rdf_world(), model, base_uri); 
    449473        for (Results::iterator i = results.begin(); i != results.end(); ++i) { 
    450                 Glib::Mutex::Lock lock(world->rdf_world->mutex()); 
     474                Glib::Mutex::Lock lock(world->rdf_world()->mutex()); 
    451475                Redland::Node&    node      = (*i)["node"]; 
    452476                Redland::Node&    predicate = (*i)["predicate"]; 
     
    479503                        continue; 
    480504                parse_patch(world, target, model, res_i->second, patch_path, Symbol(node_path.symbol())); 
    481                 Glib::Mutex::Lock lock(world->rdf_world->mutex()); 
     505                Glib::Mutex::Lock lock(world->rdf_world()->mutex()); 
    482506                target->put(node_path, i->second); 
    483507        } 
     
    498522 
    499523        /* Load node ports */ 
    500         query = Redland::Query(*world->rdf_world, Glib::ustring( 
     524        query = Redland::Query(*world->rdf_world(), Glib::ustring( 
    501525                "SELECT DISTINCT ?node ?port ?key ?val WHERE {\n") + 
    502526                        subject + " ingen:node ?node .\n" 
     
    505529                "}"); 
    506530        Objects node_ports; 
    507         results = query.run(*world->rdf_world, model, base_uri); 
     531        results = query.run(*world->rdf_world(), model, base_uri); 
    508532        for (Results::iterator i = results.begin(); i != results.end(); ++i) { 
    509                 Glib::Mutex::Lock lock(world->rdf_world->mutex()); 
     533                Glib::Mutex::Lock lock(world->rdf_world()->mutex()); 
    510534                const string node_uri = (*i)["node"].to_string(); 
    511535                const string port_uri = (*i)["port"].to_string(); 
     
    532556 
    533557        /* Find ports on this patch */ 
    534         query = Redland::Query(*world->rdf_world, Glib::ustring( 
     558        query = Redland::Query(*world->rdf_world(), Glib::ustring( 
    535559                "SELECT DISTINCT ?port ?type WHERE {\n") + 
    536560                        subject + " lv2:port       ?port .\n" 
     
    538562                "}"); 
    539563        Objects patch_ports; 
    540         results = query.run(*world->rdf_world, model, base_uri); 
     564        results = query.run(*world->rdf_world(), model, base_uri); 
    541565        for (Results::iterator i = results.begin(); i != results.end(); ++i) { 
    542                 Glib::Mutex::Lock lock(world->rdf_world->mutex()); 
     566                Glib::Mutex::Lock lock(world->rdf_world()->mutex()); 
    543567                Redland::Node& port = (*i)["port"]; 
    544568                Redland::Node& type = (*i)["type"]; 
     
    551575 
    552576        /* Load patch ports */ 
    553         query = Redland::Query(*world->rdf_world, Glib::ustring( 
     577        query = Redland::Query(*world->rdf_world(), Glib::ustring( 
    554578                "SELECT DISTINCT ?port ?key ?val WHERE {\n") + 
    555579                        subject + " lv2:port ?port .\n" 
    556580                        "?port      ?key     ?val .\n" 
    557581                "}"); 
    558         results = query.run(*world->rdf_world, model, base_uri); 
     582        results = query.run(*world->rdf_world(), model, base_uri); 
    559583        for (Results::iterator i = results.begin(); i != results.end(); ++i) { 
    560                 Glib::Mutex::Lock lock(world->rdf_world->mutex()); 
     584                Glib::Mutex::Lock lock(world->rdf_world()->mutex()); 
    561585                const string port_uri  = (*i)["port"].to_string(); 
    562586                const Path   port_path = patch_path.child(relative_uri(base_uri, port_uri, false)); 
     
    604628        for (uint32_t index = 0; index < patch_ports.size(); ++index) { 
    605629                Objects::iterator i = ports_by_index[index]; 
    606                 Glib::Mutex::Lock lock(world->rdf_world->mutex()); 
     630                Glib::Mutex::Lock lock(world->rdf_world()->mutex()); 
    607631                const Path port_path = patch_path.child(relative_uri(base_uri, i->first, false)); 
    608632                std::pair<Properties::iterator,Properties::iterator> types_range 
     
    642666 
    643667        /* Enable */ 
    644         query = Redland::Query(*world->rdf_world, Glib::ustring( 
     668        query = Redland::Query(*world->rdf_world(), Glib::ustring( 
    645669                "SELECT DISTINCT ?enabled WHERE {\n") 
    646670                        + subject + " ingen:enabled ?enabled .\n" 
    647671                "}"); 
    648672 
    649         results = query.run(*world->rdf_world, model, base_uri); 
     673        results = query.run(*world->rdf_world(), model, base_uri); 
    650674        for (Results::iterator i = results.begin(); i != results.end(); ++i) { 
    651                 Glib::Mutex::Lock lock(world->rdf_world->mutex()); 
     675                Glib::Mutex::Lock lock(world->rdf_world()->mutex()); 
    652676                const Redland::Node& enabled_node = (*i)["enabled"]; 
    653677                if (enabled_node.is_bool() && enabled_node) { 
     
    672696                boost::optional<GraphObject::Properties> data) 
    673697{ 
    674         const LV2URIMap& uris = *world->uris.get(); 
     698        const LV2URIMap& uris = *world->uris().get(); 
    675699 
    676700        /* Get plugin */ 
    677         Redland::Query query(*world->rdf_world, Glib::ustring( 
     701        Redland::Query query(*world->rdf_world(), Glib::ustring( 
    678702                "SELECT DISTINCT ?plug WHERE {\n") 
    679703                        + subject.to_turtle_token() + " rdf:instanceOf ?plug .\n" 
    680704                "}"); 
    681705 
    682         Redland::Query::Results results = query.run(*world->rdf_world, model); 
     706        Redland::Query::Results results = query.run(*world->rdf_world(), model); 
    683707 
    684708        if (results.size() == 0) { 
     
    693717        } 
    694718 
    695         const string plugin_uri = world->rdf_world->expand_uri(plugin_node.to_c_string()); 
     719        const string plugin_uri = world->rdf_world()->expand_uri(plugin_node.to_c_string()); 
    696720        Resource::Properties props; 
    697721        props.insert(make_pair(uris.rdf_type,       Raul::URI(uris.ingen_Node))); 
     
    712736                const Raul::Path&               parent) 
    713737{ 
    714         Redland::Query query(*world->rdf_world, Glib::ustring( 
     738        Redland::Query query(*world->rdf_world(), Glib::ustring( 
    715739                "SELECT DISTINCT ?src ?dst WHERE {\n") 
    716740                        + subject.to_turtle_token() + " ingen:connection  ?connection .\n" 
     
    721745        const Glib::ustring& base_uri = model.base_uri().to_string(); 
    722746 
    723         Redland::Query::Results results = query.run(*world->rdf_world, model); 
     747        Redland::Query::Results results = query.run(*world->rdf_world(), model); 
    724748        for (Redland::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { 
    725                 Glib::Mutex::Lock lock(world->rdf_world->mutex()); 
     749                Glib::Mutex::Lock lock(world->rdf_world()->mutex()); 
    726750                const Path src_path(parent.child(relative_uri(base_uri, (*i)["src"].to_string(), false))); 
    727751                const Path dst_path(parent.child(relative_uri(base_uri, (*i)["dst"].to_string(), false))); 
     
    744768        const Glib::ustring& subject = subject_node.to_turtle_token(); 
    745769 
    746         Redland::Query query(*world->rdf_world, Glib::ustring( 
     770        Redland::Query query(*world->rdf_world(), Glib::ustring( 
    747771                "SELECT DISTINCT ?key ?val WHERE {\n") + 
    748772                        subject + " ?key ?val .\n" 
     
    750774 
    751775        Resource::Properties properties; 
    752         Redland::Query::Results results = query.run(*world->rdf_world, model); 
     776        Redland::Query::Results results = query.run(*world->rdf_world(), model); 
    753777        for (Redland::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { 
    754                 Glib::Mutex::Lock lock(world->rdf_world->mutex()); 
     778                Glib::Mutex::Lock lock(world->rdf_world()->mutex()); 
    755779                const string         key = string((*i)["key"]); 
    756780                const Redland::Node& val = (*i)["val"]; 
  • trunk/ingen/src/serialisation/Parser.hpp

    r2409 r2533  
    2020 
    2121#include <string> 
     22#include <list> 
    2223#include <glibmm/ustring.h> 
    2324#include <boost/optional.hpp> 
     
    6970                        boost::optional<Raul::Symbol> symbol=boost::optional<Raul::Symbol>(), 
    7071                        boost::optional<Properties>   data=boost::optional<Properties>()); 
     72 
     73        struct PatchRecord { 
     74                PatchRecord(const Raul::URI& u, const Glib::ustring& f) : uri(u), filename(f) {} 
     75                const Raul::URI     uri; 
     76                const Glib::ustring filename; 
     77        }; 
     78 
     79        typedef std::list<PatchRecord> PatchRecords; 
     80 
     81        virtual PatchRecords find_patches( 
     82                        Ingen::Shared::World* world, 
     83                        const Glib::ustring&  manifest_uri); 
    7184 
    7285private: 
  • trunk/ingen/src/serialisation/Serialiser.cpp

    r2525 r2533  
    3030#include <glib/gstdio.h> 
    3131#include <glibmm/convert.h> 
     32#include <glibmm/miscutils.h> 
     33#include <glibmm/fileutils.h> 
    3234#include "raul/log.hpp" 
    3335#include "raul/Atom.hpp" 
     
    102104                           const Records&     records) 
    103105{ 
    104         const string filename = Glib::filename_from_uri(bundle_uri) + "manifest.ttl"; 
     106        const string bundle_path(Glib::filename_from_uri(bundle_uri)); 
     107        const string filename(Glib::build_filename(bundle_path, "manifest.ttl")); 
    105108        start_to_filename(filename); 
    106109    _model->set_base_uri(bundle_uri); 
     
    108111                SharedPtr<Patch> patch = PtrCast<Patch>(i->object); 
    109112                if (patch) { 
    110                         const Redland::Resource subject(_model->world(), uri_to_symbol(i->uri)); 
     113                        const std::string filename = uri_to_symbol(i->uri) + INGEN_PATCH_FILE_EXT; 
     114                        const Redland::Resource subject(_model->world(), filename); 
    111115                        _model->add_statement(subject, "rdf:type", 
    112116                                Redland::Resource(_model->world(), "ingen:Patch")); 
     
    114118                                Redland::Resource(_model->world(), "lv2:Plugin")); 
    115119                        _model->add_statement(subject, "rdfs:seeAlso", 
    116                                 Redland::Resource(_model->world(), i->uri)); 
     120                                Redland::Resource(_model->world(), filename)); 
     121                        _model->add_statement(subject, "lv2:binary", 
     122                                Redland::Resource(_model->world(), 
     123                                        Glib::Module::build_path("", "ingen_lv2"))); 
     124                        symlink(Glib::Module::build_path(INGEN_MODULE_DIR, "ingen_lv2").c_str(), 
     125                                        Glib::Module::build_path(bundle_path, "ingen_lv2").c_str()); 
    117126                } 
    118127        } 
     
    179188        else 
    180189                _base_uri = filename; 
    181         _model = new Redland::Model(*_world.rdf_world); 
     190        _model = new Redland::Model(*_world.rdf_world()); 
    182191    _model->set_base_uri(_base_uri); 
    183192        _mode = TO_FILE; 
     
    202211        _root_path = root; 
    203212        _base_uri = base_uri; 
    204         _model = new Redland::Model(*_world.rdf_world); 
     213        _model = new Redland::Model(*_world.rdf_world()); 
    205214    _model->set_base_uri(base_uri); 
    206215        _mode = TO_STRING; 
     
    311320                        Redland::Resource(_model->world(), "lv2:Plugin")); 
    312321 
    313         GraphObject::Properties::const_iterator s = patch->properties().find("lv2:symbol"); 
    314         // If symbol is stored as a property, write that 
    315         if (s != patch->properties().end() && s->second.is_valid()) { 
    316                 _model->add_statement(patch_id, "lv2:symbol", 
    317                         Redland::Literal(_model->world(), s->second.get_string())); 
    318         // Otherwise take the one from our path (if possible) 
    319         } else if (!patch->path().is_root()) { 
    320                 _model->add_statement(patch_id, "lv2:symbol", 
    321                                 Redland::Literal(_model->world(), patch->path().symbol())); 
     322        const LV2URIMap& uris = *_world.uris().get(); 
     323 
     324        // Always write a symbol (required by Ingen) 
     325        string symbol; 
     326        GraphObject::Properties::const_iterator s = patch->properties().find(uris.lv2_symbol); 
     327        if (s == patch->properties().end() 
     328                        || !s->second.type() == Atom::STRING 
     329                        || !Symbol::is_valid(s->second.get_string())) { 
     330                symbol = Glib::path_get_basename(Glib::filename_from_uri(_model->base_uri().to_c_string())); 
     331                symbol = Symbol::symbolify(symbol.substr(0, symbol.find('.'))); 
     332                _model->add_statement(patch_id, uris.lv2_symbol.c_str(), 
     333                        Redland::Literal(_model->world(), symbol)); 
    322334        } else { 
    323                 LOG(warn) << "Patch has no lv2:symbol" << endl; 
    324         } 
     335                symbol = s->second.get_string(); 
     336        } 
     337 
     338        // If the patch has no doap:name (required by LV2), use the symbol 
     339        if (patch->meta().properties().find(uris.doap_name) == patch->meta().properties().end()) 
     340                _model->add_statement(patch_id, uris.doap_name.c_str(), 
     341                                Redland::Literal(_model->world(), symbol)); 
    325342 
    326343        serialise_properties(patch_id, NULL, patch->meta().properties()); 
     
    428445                                class_rdf_node(port->path())); 
    429446 
     447        _model->add_statement(port_id, "lv2:symbol", 
     448                        Redland::Literal(_model->world(), port->path().symbol())); 
     449 
    430450        serialise_properties(port_id, &port->meta(), port->properties()); 
    431451} 
     
    450470        _model->add_statement(port_id, "lv2:index", 
    451471                        AtomRDF::atom_to_node(*_model, Atom((int)port->index()))); 
     472 
     473        _model->add_statement(port_id, "lv2:symbol", 
     474                        Redland::Literal(_model->world(), port->path().symbol())); 
    452475 
    453476        if (!port->get_property("http://lv2plug.in/ns/lv2core#default").is_valid()) { 
     
    481504                : class_rdf_node(connection->dst_port_path()); 
    482505 
    483         const Redland::Node connection_node = _world.rdf_world->blank_id(); 
     506        const Redland::Node connection_node = _world.rdf_world()->blank_id(); 
    484507        _model->add_statement(connection_node, "ingen:source", src_node); 
    485508        _model->add_statement(connection_node, "ingen:destination", dst_node); 
  • trunk/ingen/src/serialisation/serialisation.cpp

    r2314 r2533  
    2626struct IngenModule : public Shared::Module { 
    2727        void load(Shared::World* world) { 
    28                 world->parser = SharedPtr<Serialisation::Parser>( 
    29                                 new Serialisation::Parser()); 
    30                 world->serialiser = SharedPtr<Serialisation::Serialiser>( 
    31                                 new Serialisation::Serialiser(*world, world->store)); 
     28                world->set_parser(SharedPtr<Serialisation::Parser>( 
     29                                new Serialisation::Parser())); 
     30                world->set_serialiser(SharedPtr<Serialisation::Serialiser>( 
     31                                new Serialisation::Serialiser(*world, world->store()))); 
    3232        } 
    3333}; 
  • trunk/ingen/src/shared/Builder.cpp

    r2491 r2533  
    3333 
    3434 
    35 Builder::Builder(CommonInterface& interface) 
    36         : _interface(interface) 
     35Builder::Builder(SharedPtr<Shared::LV2URIMap> uris, CommonInterface& interface) 
     36        : _uris(uris) 
     37        , _interface(interface) 
    3738{ 
    3839} 
     
    4243Builder::build(SharedPtr<const GraphObject> object) 
    4344{ 
    44         const LV2URIMap& uris = Shared::LV2URIMap::instance(); 
     45        const LV2URIMap& uris = *_uris.get(); 
    4546        SharedPtr<const Patch> patch = PtrCast<const Patch>(object); 
    4647        if (patch) { 
  • trunk/ingen/src/shared/Builder.hpp

    r2398 r2533  
    2626namespace Shared { 
    2727 
     28class CommonInterface; 
    2829class GraphObject; 
    29 class CommonInterface; 
     30class LV2URIMap; 
    3031 
    3132 
     
    3738{ 
    3839public: 
    39         Builder(CommonInterface& interface); 
     40        Builder(SharedPtr<Shared::LV2URIMap> uris, CommonInterface& interface); 
    4041        virtual ~Builder() {} 
    4142 
     
    4647        void build_object(SharedPtr<const GraphObject> object); 
    4748 
    48         CommonInterface& _interface; 
     49        SharedPtr<Shared::LV2URIMap> _uris; 
     50        CommonInterface&             _interface; 
    4951}; 
    5052 
  • trunk/ingen/src/shared/LV2Features.cpp

    r2408 r2533  
    2929LV2Features::LV2Features() 
    3030{ 
    31         add_feature(LV2_URI_MAP_URI, SharedPtr<Feature>(new LV2URIMap())); 
    3231} 
    3332 
  • trunk/ingen/src/shared/LV2Object.cpp

    r2409 r2533  
    3333 
    3434bool 
    35 to_atom(const LV2_Object* object, Raul::Atom& atom) 
     35to_atom(const Shared::LV2URIMap& uris, const LV2_Object* object, Raul::Atom& atom) 
    3636{ 
    37         const LV2URIMap& uris = Shared::LV2URIMap::instance(); 
    38  
    3937        if (object->type == uris.object_class_string.id) { 
    4038                atom = Raul::Atom((char*)(object + 1)); 
     
    5856 */ 
    5957bool 
    60 from_atom(const Raul::Atom& atom, LV2_Object* object) 
     58from_atom(const Shared::LV2URIMap& uris, const Raul::Atom& atom, LV2_Object* object) 
    6159{ 
    62         const LV2URIMap& uris = Shared::LV2URIMap::instance(); 
    63  
    6460        char* str; 
    6561        switch (atom.type()) { 
  • trunk/ingen/src/shared/LV2Object.hpp

    r2492 r2533  
    2626 
    2727class World; 
     28class LV2URIMap; 
    2829 
    2930namespace LV2Object { 
    3031 
    31         bool to_atom(const LV2_Object* object, Raul::Atom& atom); 
    32         bool from_atom(const Raul::Atom& atom, LV2_Object* object); 
     32        bool to_atom(const Shared::LV2URIMap& uris, const LV2_Object* object, Raul::Atom& atom); 
     33        bool from_atom(const Shared::LV2URIMap& uris, const Raul::Atom& atom, LV2_Object* object); 
    3334 
    3435} // namespace LV2Object 
  • trunk/ingen/src/shared/LV2URIMap.cpp

    r2492 r2533  
    2020#include <stdint.h> 
    2121#include <glib.h> 
     22#include <boost/shared_ptr.hpp> 
    2223#include "raul/log.hpp" 
    2324#include "object.lv2/object.h" 
    2425#include "LV2URIMap.hpp" 
    25 #include "module/ingen_module.hpp" 
    26 #include "module/World.hpp" 
    2726 
    2827using namespace std; 
     
    3736        , id(g_quark_from_string(c_str)) 
    3837{ 
     38} 
     39 
     40const char* 
     41LV2URIMap::Quark::c_str() const 
     42{ 
     43        return g_quark_to_string(id); 
    3944} 
    4045 
     
    115120 
    116121 
    117 const LV2URIMap& 
    118 LV2URIMap::instance() 
    119 { 
    120         return *ingen_get_world()->uris; 
    121 } 
     122struct null_deleter { void operator()(void const *) const {} }; 
    122123 
    123124 
     
    126127                     const char* uri) 
    127128{ 
    128         const uint32_t ret = static_cast<uint32_t>(g_quark_from_string(uri)); 
    129         debug << "[LV2URIMap] "; 
    130         if (map) 
    131                 debug << map << " : "; 
    132         debug << uri << " => " << ret << endl; 
    133         return ret; 
     129        return static_cast<uint32_t>(g_quark_from_string(uri)); 
    134130} 
    135131 
  • trunk/ingen/src/shared/LV2URIMap.hpp

    r2492 r2533  
    3939        } 
    4040 
    41         uint32_t uri_to_id(const char* map, const char* uri); 
    42  
    43         static const LV2URIMap& instance(); 
     41        virtual uint32_t uri_to_id(const char* map, const char* uri); 
    4442 
    4543private: 
     
    5452        struct Quark : public Raul::URI { 
    5553                Quark(const char* str); 
     54                const char* c_str() const; 
    5655                uint32_t id; 
    5756        }; 
  • trunk/ingen/src/shared/ResourceImpl.cpp

    r2468 r2533  
    6868ResourceImpl::remove_property(const Raul::URI& uri, const Raul::Atom& value) 
    6969{ 
    70         const LV2URIMap& uris = Shared::LV2URIMap::instance(); 
    71         if (value == uris.wildcard) { 
     70        if (value == _uris.wildcard) { 
    7271                _properties.erase(uri); 
    7372        } else { 
     
    114113bool 
    115114ResourceImpl::type( 
     115                const LV2URIMap&  uris, 
    116116                const Properties& properties, 
    117117                bool& patch, 
     
    120120{ 
    121121        typedef Resource::Properties::const_iterator iterator; 
    122         const LV2URIMap& uris = Shared::LV2URIMap::instance(); 
    123122        const std::pair<iterator,iterator> types_range = properties.equal_range(uris.rdf_type); 
    124123 
     
    199198ResourceImpl::remove_properties(const Properties& p) 
    200199{ 
    201         const LV2URIMap& uris = Shared::LV2URIMap::instance(); 
    202200        typedef Resource::Properties::const_iterator iterator; 
    203201        for (iterator i = p.begin(); i != p.end(); ++i) { 
    204                 if (i->second == uris.wildcard) { 
     202                if (i->second == _uris.wildcard) { 
    205203                        _properties.erase(i->first); 
    206204                } else { 
  • trunk/ingen/src/shared/ResourceImpl.hpp

    r2442 r2533  
    2222#include <sigc++/sigc++.h> 
    2323#include "raul/URI.hpp" 
     24#include "raul/SharedPtr.hpp" 
    2425#include "interface/Resource.hpp" 
    2526#include "interface/PortType.hpp" 
     
    2829namespace Shared { 
    2930 
     31class LV2URIMap; 
     32 
    3033class ResourceImpl : virtual public Resource 
    3134{ 
    3235public: 
    33         ResourceImpl(const Raul::URI& uri) : _uri(uri) {} 
     36        ResourceImpl(LV2URIMap& uris, const Raul::URI& uri) 
     37                : _uris(uris), _uri(uri) {} 
     38 
     39        LV2URIMap& uris() const { return _uris; } 
    3440 
    3541        virtual void             set_uri(const Raul::URI& uri) { _uri = uri; } 
     
    5763         */ 
    5864        static bool type( 
     65                        const LV2URIMap&  uris, 
    5966                        const Properties& properties, 
    6067                        bool& patch, 
     
    6774protected: 
    6875        Raul::Atom& set_property(const Raul::URI& uri, const Raul::Atom& value) const; 
     76 
     77        LV2URIMap& _uris; 
    6978 
    7079private: 
  • trunk/ingen/src/shared/runtime_paths.cpp

    r2518 r2533  
    4242        dladdr(function, &dli); 
    4343 
     44#ifdef BUNDLE 
    4445        char bin_loc[PATH_MAX]; 
    4546        realpath(dli.dli_fname, bin_loc); 
     47#else 
     48        const char* bin_loc = dli.dli_fname; 
     49#endif 
    4650 
    47 #ifdef BUNDLE 
    4851        string bundle = bin_loc; 
    4952        bundle = bundle.substr(0, bundle.find_last_of(G_DIR_SEPARATOR)); 
    5053        bundle_path = bundle; 
    51 #endif 
    5254} 
    5355 
     56 
     57void 
     58set_bundle_path(const char* path) 
     59{ 
     60        bundle_path = path; 
     61} 
     62 
     63 
     64/** Return the absolute path of a file in an Ingen LV2 bundle 
     65 */ 
     66std::string 
     67bundle_file_path(const std::string& name) 
     68{ 
     69        return Glib::build_filename(bundle_path, name); 
     70} 
    5471 
    5572/** Return the absolute path of a 'resource' file. 
     
    5875data_file_path(const std::string& name) 
    5976{ 
    60         std::string ret; 
    6177#ifdef BUNDLE 
    62         ret = Glib::build_filename(bundle_path, Glib::build_path(INGEN_DATA_DIR, name)); 
     78        return Glib::build_filename(bundle_path, Glib::build_path(INGEN_DATA_DIR, name)); 
    6379#else 
    64         ret = Glib::build_filename(INGEN_DATA_DIR, name); 
     80        return Glib::build_filename(INGEN_DATA_DIR, name); 
    6581#endif 
    66         return ret; 
    6782} 
    6883 
     
    7388module_path(const std::string& name) 
    7489{ 
    75         std::string ret; 
    7690#ifdef BUNDLE 
    77         ret = Glib::Module::build_path(Glib::build_path(bundle_path, INGEN_MODULE_DIR), name); 
     91        return Glib::Module::build_path(Glib::build_path(bundle_path, INGEN_MODULE_DIR), name); 
    7892#else 
    79         ret = Glib::Module::build_path(INGEN_MODULE_DIR, name); 
     93        return Glib::Module::build_path(INGEN_MODULE_DIR, name); 
    8094#endif 
    81         return ret; 
    8295} 
    8396 
  • trunk/ingen/src/shared/runtime_paths.hpp

    r2398 r2533  
    2828namespace Shared { 
    2929 
     30void set_bundle_path(const char* path); 
    3031void set_bundle_path_from_code(void* function); 
    3132 
     33std::string bundle_file_path(const std::string& name); 
    3234std::string data_file_path(const std::string& name); 
    3335std::string module_path(const std::string& name); 
  • trunk/ingen/src/shared/wscript

    r2334 r2533  
    1010                Builder.cpp 
    1111                ClashAvoider.cpp 
     12                Configuration.cpp 
    1213                LV2Features.cpp 
    1314                LV2Object.cpp 
  • trunk/raul/raul/Thread.hpp

    r2364 r2533  
    1919#define RAUL_THREAD_HPP 
    2020 
     21#include <set> 
    2122#include <string> 
    2223#include <iostream> 
     
    6061        void set_name(const std::string& name) { _name = name; } 
    6162 
    62         unsigned context() const               { return _context; } 
    63         void     set_context(unsigned context) { _context = context; } 
     63        bool is_context(unsigned context) const { return _contexts.find(context) != _contexts.end(); } 
     64        void set_context(unsigned context) { _contexts.insert(context); } 
    6465 
    6566protected: 
     
    9394        static pthread_once_t _thread_key_once; 
    9495 
    95         unsigned    _context; 
    96         std::string _name; 
    97         bool        _pthread_exists; 
    98         bool        _own_thread; 
    99         pthread_t   _pthread; 
     96        std::set<unsigned> _contexts; 
     97        std::string        _name; 
     98        bool               _pthread_exists; 
     99        bool               _own_thread; 
     100        pthread_t          _pthread; 
    100101}; 
    101102 
  • trunk/raul/src/Thread.cpp

    r2432 r2533  
    3333Thread::Thread(const std::string& name) 
    3434        : _exit_flag(false) 
    35         , _context(0) 
    3635        , _name(name) 
    3736        , _pthread_exists(false) 
     
    4645Thread::Thread(pthread_t thread, const std::string& name) 
    4746        : _exit_flag(false) 
    48         , _context(0) 
    4947        , _name(name) 
    5048        , _pthread_exists(true) 
  • trunk/raul/wscript

    r2514 r2533  
    55 
    66# Version of this package (even if built as a child) 
    7 RAUL_VERSION = '0.6.5' 
     7RAUL_VERSION = '0.6.6' 
    88 
    99# Library version (UNIX style major, minor, micro) 
     
    2121#   0.6.4 = 7,0,0 (unreleased) 
    2222#   0.6.5 = 8,0,0 (unreleased) 
    23 RAUL_LIB_VERSION = '8.0.0' 
     23#   0.6.6 = 9,0,0 (unreleased) 
     24RAUL_LIB_VERSION = '9.0.0' 
    2425 
    2526# Variables for 'waf dist'