[ofw] RE: interface GUIDs and versioning
Fab Tillier
ftillier at windows.microsoft.com
Wed Jul 8 16:38:03 PDT 2009
>>>> Should users always call QueryInterface to ensure that they have the
>>>> correct interface, or should the interface GUIDs be input into any
>>>> calls that return an interface? Thoughts anyone?
>>>
>>> How will ND handle this?
>>
>> What we did when we changed some interfaces was change the GUID of
>> any parent object that would return a changed interface.
>>
>> So in your case, the IWVDevice and IWVProvider interfaces would
>> change
> too.
>
> Ok - then the WvProvider GUID basically controls all sub-interfaces
> then. I like this better than forcing the user to call QueryInterface
> to get an updated interface. Did you consider passing in the GUID to
> all calls that return an object? If so, why didn't you select this
> option? (I'm not suggesting that I like it better, just if there was
> a reason not to use it.)
The problem with passing the IID into the function is it assumes that the rest of the parameters are correct for the different interfaces, which may not be the case.
You could go with a model where you instantiate objects separately from initialization. That is, a single call (CreateInstance?), that takes the IID of the child, and then the returned child interface would have an appropriate Initialize call that would take the actual parameters and perform the initialization.
For what we were doing it seemed less user-friendly, and much of what we were trying to do with NetworkDirect was create an interface that exposed common functionality in RDMA hardware while keeping it fairly straight forward to use (hence some of the design decisions like hiding protection domains, eliminating access rights form registrations and using windows for remote access, hiding work requests and work completions, etc.)
In any case, the provider implementation tends to split the constructor and initializer if you want to avoid throwing exceptions from the constructor anyway, so exposing that through the interfaces isn't a huge deal.
The main advantage with the CreateInstance/Initialize pairs is that it lets you extend the interfaces without having to rev all the GUIDs all the time. It comes down with how often you expect to change interfaces, and how many prior interface versions you intend on supporting.
-Fab
More information about the ofw
mailing list