Microsoft Windows CE 3.0  

CFactoryTemplate Class

Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

This class provides a template used by the default class factory code.

Create one CFactoryTemplateobject in an array for every object class so that the default class factory code can create new instances.

This class holds the name of the object, the object's class identifier (CLSID), and a pointer to the creation function for the corresponding object. Initialize one of these in an array called g_Templates for each CLSID the application's dynamic-link library (DLL) supports. The creation function should take an LPUNKNOWN parameter and an HRESULTpointer and return an object derived from the CBaseObjectclass. Set the HRESULTto a failed value if there is any error in construction. An example declaration (from the Gargle sample filter) follows:

// list of class ids and creator functions for
class factory CFactoryTemplate g_Templates[2]= { { L"Gargle filter"
// CFactoryTemplate.m_name , &CLSID_Gargle //
CFactoryTemplate.m_ClsID , CGargle::CreateInstance //
CFactoryTemplate.m_lpfnNew , NULL // CFactoryTemplate.m_lpfnInit ,
&sudGargle // CFactoryTemplate.m_pAMovieSetup_Filter } , {
L"Gargle filter property page" , &CLSID_GargProp ,
CGargleProperties::CreateInstance } }; int g_cTemplates =
sizeof(g_Templates) / sizeof(g_Templates[0]);

Note that the name of the object is strictly necessary only if you are using the DllRegisterServersetup routine to implement self-registering of your filter. If you are not using this feature, you can set the first element of the g_Templates instance ( m_Name) to NULL or L"".

Protected Data Members

m_ClsID Pointer to the CLSID of the object class.
m_lpfnNew Pointer to a function that creates an instance of the object class.
m_lpfnInit Pointer to a function that initializes a new instance of the object class.
m_Name Name of the filter; required when using filter self-registration services.
m_pAMovieSetup_Filter Pointer to an AMOVIESETUP_FILTERstructure; required when using filter self-registration services.

Member Functions

CreateInstance Calls the object-creation function for the class.
IsClassID Determines whether a CLSID matches this class template.