On Tue, 2007-12-04 at 09:42 +0000, Krzysztof Foltman wrote:
Dave Robillard wrote:
Using a uint32_t (which is a reasonable limit for
number of symbols in
pretty much any system) and just not using out of range numbers for the
event ones doesn't seem so bad, just in case. It's one line in a
comment somewhere, BFD.
I'm thinking of something else - like having different "domains" for
mappings. Like
http://whatever/parameter-value gets number 10 in
URI-to-event-type mapping, and number 16777216 in URI-to-global-numbers
mapping. Basically, same class (URI-to-int mapper), different objects
(event type URI registry, plugin port URI registry, plugin URI registry,
and so on). Different dictionaries, same dictionary interface.
I'm not insisting this is a good idea - just that it could solve the
"max 65536 types" thing nicely while preserving some (not all)
generality. It could also lead to a mess if somebody used wrong type ID
(when the same URI is in two registries).
Not really 'nicely'... essentially implementing the exact same thing n
times. Why bother?
Also, I would be for a requirement that numbers are
always assigned (by
host) sequentially starting from 0, not by - for example - hashing,
because then some plugins could use small arrays to store
event-type-to-handler mapping (or
something-id-to-whatever-data-structure). Is that OK?
The interface for the dynamic part would have to be figured out before
this can be decided.
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);
};
... did I stumble on to the Java 101 mailing list by mistake? ;)
-DR-