CMvcComponent Class

class CMvcComponent: public IQueryGuid, public IRefCount

This class combines a model, viewport, and controller into a single object. It takes the type of model, viewport, and controller as template parameters and aggregates the three objects into a single object. This is very useful for for creating MVC-based components. NOTE: The  QueryGuid function queries all three objects, so an MVC component can be cast to any interface supported by either the model, viewport, or controller.

Defined in: MvcComponent.h

Class Template Arguments

_Model

Type of model

_Viewport

Type of viewport

_Controller

Type of controller

Class Members

CMvcComponent() : m_pMdl(NULL), m_pVp(NULL), m_pCtlr(NULL)  (NULL)

Construct an MVC component object.

ULONG m_ulRefCount

Reference count

ModelClass* m_pMdl

Pointer to model object

ViewportClass* m_pVp

Pointer to viewport object

ControllerClass* m_pCtlr

Pointer to controller object

virtual bool  Create(HWND hWndParent, LPRECT rc)

Creates the viewport given a parent window and a rectangle.

void  SetViewport(ViewportClass* pViewport)

Assign the viewport object to the component.

virtual void  SetController(ControllerClass* pController)

Assign the controller object to the component.

virtual void  SetModel(ModelClass* pModel)

Assign the model object to the component.

operator ViewportClass&()

Cast the component to a viewport.

operator ModelClass&()

Cast the component to a model.

operator ControllerClass&()

Cast the component to a controller.

virtual bool  QueryGuid(REFGUID guid, void **ppvObj)

Cast object to a pointer type given a GUID.

ULONG STDMETHODCALLTYPE  AddRef()

Add a reference to this object.

ULONG STDMETHODCALLTYPE  Release()

Release a reference to this object.