On Wed, 2007-12-05 at 04:35 +0100, Lars Luthman
wrote:
On Tue, 2007-12-04 at 09:42 +0000, Krzysztof
Foltman wrote:
What about this (translate it to C in your heads
:) ):
interface IURIRegistryObserver
{
// function in plugin etc. called by host whenever new URI is registered
void mapping_added(int id, const char *uri);
};
interface IURIRegistry
{
int uri_to_id(const char *uri, bool create_if_absent);
const char *id_to_uri(int id);
void add_observer(IURIRegistryObserver *observer);
void remove_observer(IURIRegistryObserver *observer);
};
interface IURIRegistries
{
IURIRegistry *get_registry(const char *registry_uri);
};
I don't like having something this complicated in an extension that is
going to be required if you just want to write a simple synth with a
MIDI input. Is there really any need for adding and removing mappings
dynamically?
Definitely agreed.
Just passing an array in the LV2_Feature data
would be enough for me.
Simple is nice, but somewhat closed ended.
How about simply passing a function pointer which converts a string to
an int? (in a Feature struct so things can be added for a more advanced
symbol system in the future)
Easier on the plugin author to just call a function than have to
implement that search all over the place anyway.
That sounds OK. I suggest something like this:
struct URI_Mapper {
// call this with your URI and the host_data member - not RT safe
uint16_t (map_function*)(const char* uri, void* host_data);
// pass this as the second parameter to map_function()
void* host_data;
};
It doesn't provide a way for the host to say "I'm out of IDs!" though.
Will that be needed?
--ll