|Re: Can I try factory on 3.20.xx ? [message #792271 is a reply to message #629623]
||Mon, 06 February 2012 20:32
| Sasha Slijepcevic
Registered: July 2009
I know this thread is very old and probably not relevant any more to you, but I'll answer in case you come upon a similar issue later.
So, if I understand your scenario correctly, instance factories would work for you, but there could be a different solution that can be implemented without instance factories.
At runtime, you can always call
IProcProvider_create, but you have to pass something to that call that will specify one of the modules inheriting IProcProvider. What you will need to pass is basically a pointer to the virtual function table for the specific module. For example, if you have modules ProviderA and ProviderB, you can create instances of each using these two calls, and appropriate variables:
IProcProvider_Handle pA, pB;
pA = IProcProvider_create(ProviderA_Module_upCast(), (struct IProcProvider_Params*)&AParams, NULL);
pB = IProcProvider_create(ProviderB_Module_upCast(), (struct IProcProvider_Params*)&BParams, NULL);
Because IProcProvider_create returns IProcProvider_Handle, you can pass these handles directly to ProcUnit_create calls:
ProcUnit_Handle pu1, pu2;
pu1 = ProcUnit_create(pA);
pu2 = ProcUnit_create(pB);
A disadvantage of this approach is that you have to know at runtime which modules implement IProcProvider interface. But, it seemed to me from your description that you prefer to create them at runtime, and in that case modules' names have to show up in the runtime code. Even factories wouldn't help you there because they also require you to specify a module when creating instances.
Powered by FUDForum
. Page generated in 0.01760 seconds