Navigation:  Programming Cookbook > Creating COM Components > Dolphins COM Framework >

Class Factories

Previous pageReturn to chapter overviewNext page

COM has the notion of factory objects that are responsible for creating instances of COM objects. Any COM server must expose class factories that can be used to instantiate instances of the coclasses for which it has been registered to serve.

Dolphin’s COM framework provides standard a standard class factory implementation, COMClassFactory, that is adequate for most purposes. This is itself a COM server object (i.e. COM has first-class classes, unlike some popular programming languages that are frequently used in conjunction with COM!).

COMClassFactory can be subclassed to support specialized object allocation policies if desired. As an example a class factory that always answer the same object instance is included as part of the framework, i.e. the singleton class factory, COMSingletonClassFactory.