Archived
This forum has been archived. Please start a new discussion on GitHub.
IceProxy : passing a method pointer as a variable
I get the following compiler error for the listed code :
error: address of overloaded function with no contextual type information
I have an ICE method :
Any help appreciated.
thanks
Matt
error: address of overloaded function with no contextual type information
I have an ICE method :
module NAMESPACE { class MyClass { void myFunc(MyClass* proxy) sequence<string> getStringVector(const string &key); } }I am trying to pass a pointer to this method as a variable using the proxy :
void MyClassI<BASECLASS>::myFunc(const NAMESPACE::MyClassPrx& proxy, const Ice::Current&) { myOtherFunc((vector<string> (*)(const string&)) (&IceProxy::NAMESPACE::MyClass::getStringVector))l }
Any help appreciated.
thanks
Matt
0
Comments
-
Hi Matt,
Welcome to our forums. slice2cpp generates two overloaded functions for each Slice operation (e.g. getStringVector), one with a context parameter (as last parameter), and one without.
What is the declaration of myOtherFunc?
Best regards,
Bernard0 -
I see what you are saying, there are 4 methods which map to the getStringVector ... is this perhaps why the compiler is getting confused ?
To answer your question :
myOtherFunc is actually a method of a different class. It is called like so :
e->myOtherFunc
where e is a pointer member variable.
The compiler actually reports the problem when I instantiate the templates :
template class MyClassI<TemplateClass1>;
template class MyClassI<TemplateClass2>;
line #1 : instantiated from here
line #1b error: address of overloaded function with no contextual type information
line #2 : instantiated from here
line #2b error: address of overloaded function with no contextual type information
where line #1 matches the template and #1b matches the myOtherFunc call.0 -
I have managed to get around this problem temporarily (although am currently dubious that it will work as I am not able to get proxy->getStringVector) by using the following :
NAMESPACE::stringVectorT (IceProxy::NAMESPACE::MyClass::*f)(const string &)=(&IceProxy::NAMESPACE::MyClass::getStringVector);
Then I use 'f' in my method :
myOtherFunc(f);
I now have the problem where the compiler wants the original method to be called with an Ice::Current variable :
void MyClassI<BASECLASS>::myFunc(const NAMESPACE::MyClassPrx& proxy, const Ice::Current&);
Where do I get Ice::Current from ?
The compiler will not let me call myFunc(proxy);
It is asking me to provide 'Ice::Current'
thanks
Matt0 -
Ice::Current is passed as the last parameter to every operation on the server side. Have a look at the documentation for details.0
-
Sure - I have given up on using proxy method passing for execution in other methods.0
-
Hi,
Based in Ice Hello demo something like this should work.// C++ code void (IceProxy::Demo::Hello::*ptSayHello)(int) = 0; void doit(HelloPrx instane, void (IceProxy::Demo::Hello::*ptSayHello)(int)) { (instane.get()->*ptSayHello)(0); } // .... int HelloClient::run(int argc, char* argv[]) { //... HelloPrx twoway = HelloPrx::checkedCast( communicator()->propertyToProxy("Hello.Proxy")->ice_twoway()->ice_timeout(-1)->ice_secure(false)); ptSayHello = &IceProxy::Demo::Hello::sayHello; doit(twoway, ptSayHello);
0 -
Thanks for the demo.
I think my problem was that the instance was templated and the compiler couldn't map to the method to call ... because of template confusion ... I tried many methods including double casts to override the problem... but to no avail !
Matt0