Regular methods on the class object
-
Dear folks, Consider 2 components, COuter that implements IOuter and CInner that implements IInner. OTOH, CInner is *auto aggregated* within COuter. By auto aggregation I mean it's aggregated within the COuter class using COM_INTERFACE_ENTRY_AUTOAGGREGATE ATL's macro. Moreover, I've got some regular member methods on CInner, say, SetId, SetOrigin, and the like. These method *are not* on my IInner interface, they are placed as member functions of the class (as mentioned above). The IInner contains "Get" accessors, say, GetId, GetOrigin and the like so that the user could *only* obtain some information using the IInner interface. She cannot set anything on the object, since there's no "Set" accessors on IInner. Now, I'm going to use the objects mentioned above, so that I can call those Set accessors within the program and the user could successfully get these values using the Get methods on IInner. I tried the following: IOuterPtr spOuter; HRESULT hRes = COuter::_CreatorClass::CreateInstance(NULL, IID_IOuter, (void **)&spOuter); if(FAILED(hRes)) return FALSE; CComAggObject *pInner; hRes = CComAggObject::CreateInstance(spOuter, &pInner); if(FAILED(hRes)) return FALSE; pInner->m_contained.SetId(24950); IInnerPtr spInner; hRes = pInner->QueryInterface(IID_IInner, (void **)&spInner); if(FAILED(hRes)) return FALSE; But this is basically wrong, since the Inner object is *auto aggregated* ! Do you have any idea how I can create such things? Something like ITCallInfoChangeEvent that gives the user some informaiton via it's Get accessors, (get_Call and get_Cause to name a few) and user cannot set anything on this object, since it's got no Set accessor. Any help would be highly appreciated, Cheers Mehdi Mousavi
-
Dear folks, Consider 2 components, COuter that implements IOuter and CInner that implements IInner. OTOH, CInner is *auto aggregated* within COuter. By auto aggregation I mean it's aggregated within the COuter class using COM_INTERFACE_ENTRY_AUTOAGGREGATE ATL's macro. Moreover, I've got some regular member methods on CInner, say, SetId, SetOrigin, and the like. These method *are not* on my IInner interface, they are placed as member functions of the class (as mentioned above). The IInner contains "Get" accessors, say, GetId, GetOrigin and the like so that the user could *only* obtain some information using the IInner interface. She cannot set anything on the object, since there's no "Set" accessors on IInner. Now, I'm going to use the objects mentioned above, so that I can call those Set accessors within the program and the user could successfully get these values using the Get methods on IInner. I tried the following: IOuterPtr spOuter; HRESULT hRes = COuter::_CreatorClass::CreateInstance(NULL, IID_IOuter, (void **)&spOuter); if(FAILED(hRes)) return FALSE; CComAggObject *pInner; hRes = CComAggObject::CreateInstance(spOuter, &pInner); if(FAILED(hRes)) return FALSE; pInner->m_contained.SetId(24950); IInnerPtr spInner; hRes = pInner->QueryInterface(IID_IInner, (void **)&spInner); if(FAILED(hRes)) return FALSE; But this is basically wrong, since the Inner object is *auto aggregated* ! Do you have any idea how I can create such things? Something like ITCallInfoChangeEvent that gives the user some informaiton via it's Get accessors, (get_Call and get_Cause to name a few) and user cannot set anything on this object, since it's got no Set accessor. Any help would be highly appreciated, Cheers Mehdi Mousavi
-
Well, I finally ended up in having 2 different interface on my inner object, one for initialization and the other one for Get accessors. Cheers, Mehdi Mousavi