OOPortal OOPortal

ATL Development   «Prev 

Development frameworks

Data-driven implementations

Many of the tasks we perform in COM are the same for every server and object. For example, to register COM objects, we always make the HKEY_CLASSES_ROOT\CLSID\{ clsid } entries. To implement IClassFactory::CreateInstance, we always create an instance of the C++ class that implements a COM object.
To implement IUnknown::QueryInterface, we always check the requested IID and (if it is supported) place an interface pointer in the output parameter and call AddRef on the pointer, and so on.
The only differences in these tasks between different projects are the CLSIDs, the IIDs, and the names of the C++ classes we use. Development frameworks such as MFC and ATL provide generic implementations of IUnknown, IClassFactory, and required in-process DLL functions (i.e., DllGetClassObject, DllRegisterServer). These implementations are data driven. We tell the framework the name of our C++ implementation classes for COM objects/interfaces, object CLSIDs, and IIDs. Using this data, the framework can carry out the requested tasks--i.e., implement CreateInstance or IUnknown.
As part of the development process, developers use tools associated with the framework to create their C++ classes and provide the framework the data it needs.