|
to:sky_hexia
I am trying to save trouble and not write each one. CDevice refers to CDevice1 CDevice2 CDevice3. Each implementation is the same as it.
void CDevice::Regist(IDevice1* pDev1)
void CDevice::ThreadCallBack()
in reality:
void CDevice1::Regist(..){...}
void CDevice1::ThreadCallBack(){..}
void CDevice2::Regist(..){...}
...
to:koby806
Ha ha, in fact, simply put: there are many different types of equipment on the periphery.If you want to interact with a central hub module, how can you design it?
Make the structure loose, concise and efficient.
Ha ha, this is a very challenging problem, loose is not necessarily concise, just like each device defines an interface, CWhat inherits these interfaces, and then defines multiple device interfaces to allow the device to inherit (such as implementing interactive calls). (a public interface (It doesn't work, first the semantics don't work, and then the method parameters are also different).
to:druboy
If CDeviceMgr is the role of Proxy, then it will become very huge (it can be imagined to implement more than 10 types of various functional functions...);
If you use the member method, when interacting with CWhat, the situation above is inevitable. :(
In fact, I have two purposes for this consideration:
1. When the hardware of a certain type of device is updated, I can easily replace CDeviceX without modifying other modules of the system (that is, loose coupling)
2.CWhat is the heart-level control core should be kept simple and not complicated on a loose basis. |
|