I am a newbie C++ developer (lots of Java experience). I am trying to create a very simple servlet container based on Poco, and need to use some dynamic instance creation to perform servlet to path mapping based on a configuration file.
I found the Reflex framework and was trying out a simple sample program based on the example code given at seal-reflex.web.cern.ch/seal-ref … mples.html. I got the basics working, but ran into a roadblock when trying to add some extra code. I looked at the unit test suite, and the tests invoking retrieving the returned value from the Invoke method have been commented out (as has the API changed from what the online documentation shows).
I added the following code to my simple test:
Member fm = t.FunctionMemberByName("getVal");
Object result( Type::ByName( "int" ) );
fm.Invoke(o, &result);
The question is, how do I get the result value that is stored in result? In my case I should be getting an integer, but I cannot seem to find the proper way to get at the value from the documentation.
Thanks in advance for all help and suggestions.
Rakesh
Okay, I found the Address method, but it still does not work properly
[code] Member dm = t.DataMemberByName(“val”);
cout << "Data member " << dm.Name() << " is of type " << dm.TypeOf().Name() << endl;
int i = Object_Cast(dm.Get(o));
cout << "Data member " << dm.Name() << " value is " << i << endl;
++i;
dm.Set(o,&i);
cout << "Data member " << dm.Name() << " set to " << Object_Cast(dm.Get(o)) << endl;
Member fm = t.FunctionMemberByName("getVal");
cout << "Function " << fm.Name() << " is of type " << fm.TypeOf().Name() << endl;
Object result( Type::ByName( "int" ) );
fm.Invoke(o, &result);
int *val = static_cast<int *>( result.Address() );
cout << "Function getVal returned " << val << endl;[/code]
The last line prints the value is 0 (null pointer?), while I had set the value to 1 through the previous dm.Set call. If I try to dereference the val pointer, I get a memory fault. Any ideas as to what I am doing wrong?