COM Utility Classes
A version of this page is also available for
4/8/2010
COM interface classes in DirectShow fall into the following groups: object creation and interface implementation. Class factory classes are provided for object creation, and other classes are provided to implement existing COM interfaces.
The COM utility classes include the following:
- CClassFactory
- CFactoryTemplate
The following illustration shows the relationship between the COM classes and the interfaces they implement.
CClassFactory and CFactoryTemplate are implemented by the base classes to handle automatic instantiation of filters, pins, and other DirectShow COM objects. These classes provide a scaffolding for object construction that wraps the actual COM elements required to construct an object.
CClassFactory, located in Dllentry.cpp, inherits from CBaseObject and implements the COM IClassFactory interface. This interface is used by CoCreateInstance, which instantiates a COM object by calling IClassFactory::CreateInstance, which, in turn, calls the static CreateInstance member function in your derived class.
The base classes use CFactoryTemplate to provide CClassFactory with a template containing the CLSID of your object and a pointer to the static CreateInstance function for your object class.