Created
February 15, 2019 15:27
-
-
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…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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