Is there a way in C++11, to create a container with map of interfaces as key and implementation classes as value of that key. What I wan't to do, is to be able to bind interfaces with certain implementations, then instantiate quickly class assigned to that interface. I'll explain using code:
Locator locator;
// binding ILogisticsCarrierPairingModel with DummyModel:
locator.bind<ILogisticsCarrierPairingModel, DummyModel>();
// instantiating DummyModel, by calling function with interface name:
ILogisticsCarrierPairingModel* model2 = locator.get<ILogisticsCarrierPairingModel>();
// binding ILogisticsCarrierPairingModel with LogisticsCarrierPairingModel:
locator.bind<ILogisticsCarrierPairingModel, LogisticsCarrierPairingModel>();
// now instantiating LogisticsCarrierPairingModel, by calling function with interface name:
model2 = locator.get<ILogisticsCarrierPairingModel>();
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire