On Wed, 2007-12-05 at 09:25 +0000, Krzysztof Foltman wrote:
> /******* functions in IURIRegistryObserver_funcs are only implemented by
> the plugin when it wants notifications about new types ****************/
>
> struct IURIRegistryObserver;
>
> struct IURIRegistryObserver_funcs
> {
> // function in a plugin called by host on new URI registration
> void (*mapping_added)(struct IURIRegistryObserver *observer, int id,
> const char *uri);
> };
>
> struct IURIRegistryObserver
> {
> struct IURIRegistryObserver_funcs *functions;
> // plugin may place it in a larger structure, and cast a pointer
> };
>
> /* functions implemented by host, used for mapping URIs and numbers */
>
> struct IURIRegistry_funcs
> {
> // returns -1 if new registrations are not supported
> int (*uri_to_id)(struct IURIRegistry *registry, const char *uri, bool
> create_if_absent);
>
> // returns pointer to the URI (host-owned), or NULL
> const char *(*id_to_uri)(struct IURIRegistry *registry, int id);
>
> // might be a do-nothing if the host doesn't support registering uris
> on the fly
>
> void (*add_observer)(struct IURIRegistryObserver *observer);
>
> // might be a do-nothing if the host doesn't support registering uris
> on the fly
> void (*remove_observer)(struct IURIRegistryObserver *observer);
> };
>
> /* structure returned by get_registry */
> struct IURIRegistry
> {
> struct IURIRegistry_funcs *functions;
> // host may place it in a larger structure, and cast a pointer
> };
>
> // structure on host side
> struct IURIRegistries_funcs
> {
> struct IURIRegistry *get_registry(const char *uri);
> };
>
> // structure on host side
> struct IURIRegistries
> {
> IURIRegistries_funcs *functions;
> // host may place it in a larger structure, and cast a pointer
> };
>
> Or to C++:
>
> class IURIRegistryObserver
> {
> virtual void mapping_added(int id, const char *uri) = 0;
> };
>
> class IURIRegistry
> {
> virtual int uri_to_id(const char *uri, bool create_if_absent) = 0;
> virtual const char *id_to_uri(int id) = 0;
> virtual void add_observer(IURIRegistryObserver *observer) {}
> virtual remove_observer(IURIRegistryObserver *observer) {}
> };
>
> class IURIRegistries
> {
> virtual IURIRegistry *get_registry(const char *registry_uri) = 0;
> };
There are times when 'GoF Patterns in Java' style is appropriate for
discussion solutions.
This isn't one of them.
-DR-
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-dev
Received on Thu Dec 6 08:15:02 2007
This archive was generated by hypermail 2.1.8 : Thu Dec 06 2007 - 08:15:02 EET