Re: Factories, handles, and handle wrappers
// In some function, somewhere
OBJHANDLE objHandle = factoryObj.CreateObject();
factoryObj.OperateOnObject(objHandle, 42);
factoryObj.DestroyObject(objHandle);
Technically, wouldn't this be
OBJHANDLEWRAPPER objHandleWrapper = factoryObj.CreateObject();
factoryObj.OperateOnObject(objHandleWrapper, 42);
factoryObj.DestroyObject(objHandleWrapper);
Given that, you should be able to operate directly on the wrapper
with:
objHandleWrapper.OperateOnObject(42);
Or, you could extract the handle from the wrapper and then use the
original syntax:
OBJHANDLE objHandle = objHandleWrapper.GetHandle();
factoryObj.OperateOnObject(objHandle, 42);
And obviously you could pass a pointer to the wrapper to another
function, and operate on that with:
SomeClass.SomeFunction(&objHandleWrapper);
void SomeClass::SomeFunction(OBJHANDLEWRAPPER* pObjHndWrpr)
{
pObjHndWrpr->OperateOnObject(42);
}
Just my thoughts...
John
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]