Skip to content

Instantly share code, notes, and snippets.

@mattcox
Created February 15, 2019 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattcox/37736abfe2c4547d5d6843a159059031 to your computer and use it in GitHub Desktop.
Save mattcox/37736abfe2c4547d5d6843a159059031 to your computer and use it in GitHub Desktop.
Demonstrates how to implement a custom Polymorph object that implements the SetCOM method. When the COM object is allocated, the SetCOM method will be passed a copy of the object, which can be useful if the allocated object needs passing to additional methods from within the COM implementation. Note: As the COM object is maintaining a pointer to…
class SomeInterface :
public CLxImpl_Foo
{
public:
class MyPolymorph :
public CLxPolymorph<SomeInterface>
{
public:
virtual void
SetCOM(
SomeInterface *implementation,
ILxUnknownID obj) LXx_OVERRIDE
{
implementation->SetObject(obj);
}
};
static void
initialize ()
{
MyPolymorph *srv = new MyPolymorph;
srv->AddInterface(new CLxIfc_Foo<SomeInterface>);
lx::AddServer("foo", srv);
}
SomeInterface() :
mObj(NULL) { }
void
SetObject(
ILxUnknownID obj)
{
// Do not add-ref.
mObj = obj;
}
private:
ILxUnknownID mObj;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment