///////////////////////////////////////////////////////////////////// // OuterComponent.h - Accepts a string from client, creates an // // InnerComponent, sends it a string for // // modification, then modifies the returned // // string before sending back to its client. // // // // Jim Fawcett, CSE775 - Distributed Objects, Spring 2007 // ///////////////////////////////////////////////////////////////////// #pragma once #include "resource.h" // main symbols #include "OuterComp.h" #include "..\InnerComp\InnerComp.h" // COuterComponent class ATL_NO_VTABLE COuterComponent : public CComObjectRootEx, public CComCoClass, public IDispatchImpl { public: COuterComponent() { HRESULT hr = pInner.CoCreateInstance(CLSID_InnerComponent); } DECLARE_REGISTRY_RESOURCEID(IDR_OUTERCOMPONENT) BEGIN_COM_MAP(COuterComponent) COM_INTERFACE_ENTRY(IOuterComponent) COM_INTERFACE_ENTRY(IDispatch) END_COM_MAP() DECLARE_PROTECT_FINAL_CONSTRUCT() HRESULT FinalConstruct() { return S_OK; } void FinalRelease() { } public: STDMETHOD(SendStringForModification)(BSTR* str); STDMETHOD(ReturnInnerPtr)(IInnerComponent** InnerPtr); private: ///////////////////////////////////////////////// // Interface pointer wrapper that will hold onto // a pointer to the InnerComponent's interface // for the lifetime of the OuterComponent CComQIPtr pInner; }; OBJECT_ENTRY_AUTO(__uuidof(OuterComponent), COuterComponent)