Tobias Oberstein wrote:
> With parameters in ContractIDs I mean something like this:
>
> "@xyz.com/some-module/foobar;1?param1=small;param2=blue"
>
> where param1 and param2 can take values of some predefined
>
> sets {'small', 'medium', 'big'} and {'red', 'blue'}.
It is not clear what you are asking. contract IDs are unique(ish)
strings. For every known contract ID, there is a class ID, which
uniquely identifies a component, as implemented in some source file
(generally .c/cpp or .js)
So all you need to do is register an xpcom component with the contract
ID "@xyz.com/some-module/foobar;1?param1=small;param2=blue"
> Further, it should be acceptable that a client may _not_ resort
> parameters like this:
>
> "@xyz.com/some-module/foobar;1?param2=blue;param1=small"
No problem - that is a different, unknown string.
> 1. Are there established patterns of design to realize such stuff?
> a) .. where there is one implementing class and the ContractID
> parameters are used to initialize some member vars of the
> implementing class
The contract ID generally exists in a source file. One source file
could implement many components.
> b) .. where there are multiple implementing classes and the
> parameters are used to choose the appropriate implementation
It is only ever done (as far as I know) using different contract IDs.
Not params as such, but call it that if you like :)
> i) .. and the different implementations are manually programmed
> implementation classes
Not sure what you are asking.
>
> ii) .. and the different implementations are compile time
> generated via C++ template classes
I can't recall seeing any such samples, and according to the C++ style
guide (see mozilla.org) that would not be portable. Could be done
pretty simply though.
> 2. If there are different ways of doing it, what questions should
> I ask myself in choosing my way?
Should you be using javascript or Python? Or using simple C++ inheritance?
[snipped way more code than I have time to play with]
Mark.