Using Visual C++ tools to add class CPhBookObj and interfaces IReadPhBook and IManagePhBook adds code and new files
into our project. Class View should now show entries for both interfaces and CPhBookObj.
Adding COM object PhBookObj to the project added an entry to the object map
in PhBook.cpp, our server implementation file.
Each COM object within a server is bound into the ATL framework by adding it into the object map using the OBJECT_ENTRY macro.
The OBJECT_ENTRY macro takes the object's CLSID and the name of the implementation class as parameters. This identifies a specific C++ class as implementing a COM object.
Each COM object implementation class contains a COM map:
Each interface implemented by an object has a COM_INTERFACE_ENTRY macro.
COM maps add methods and data into the class used by the ATL framework to manage each interface.
ATL-based COM classes use multiple inheritance. Each class inherits from each interface it implements. Each of these interface classes is really an interface specification, for example, a class with all pure virtual methods.
We previously discussed CComObjectRoot and CComCoClass.
COM implementation class CPhBookObj is defined in header file PhBookObj.h as follows:
class CPhBookObj :
public CComCoClass <CPhBookObj,&CLSID_PhBookObj>
Macro DECLARE_REGISTRY_RESOURCEID will be discussed in the next lesson.