Finally got back to this and figured it out; you need to define get_pointer for whatever smart pointer/handle is being used, in this case IceInternal::ProxyHandle, and it has to be in the proper namespace:
Code:
namespace IceProxy
{
namespace DVAC
{
template<class T> inline T* get_pointer(
IceInternal::ProxyHandle<T> const & p)
{
return p.get();
}
}
}
Now I can create boost function objects via boost::bind that will maintain the reference count for an Ice proxy.
So for an interface:
Code:
module A
{
interface B
{
void function1(int i);
};
};
I can do
Code:
class Contrived
{
public:
void setFunctionToCall(const boost::function<void(int)> & func)
{
func_ = func;
}
void doSomething(int i)
{
func_(i); // calls onto proxy.
}
private:
boost::function<void(int)> func_;
};
.
.
.
A::BPrx theProxy;
boost::function<void(int)> f = boost::bind(&IceProxy::A::B::function, theProxy, _1);
Contrived c;
c.setFunctionToCall(f);
c.doSomething(23);
As long as the c object doesn't go out of scope, the proxy will not be deleted.