Reputation: 1773
I'm new to using CORBA and I'm struggling with correctly passing the parameters to a method that I want to invoke. The method has the IDL
signature
void addUpdateListener(out OpStatus opStatus, in IPlanningUpdateListener listener);
OpStatus
is a struct defined as
struct OpStatus {
EComponent EComp;
EStatus State;
string Message;
}
enum EComponent { CompA, CompB, CompC };
enum EStatus { SUCCESS, FAILURE, RETRY };
and IPlanningUpdateListener
is itself an IDL
interface.
I've implemented the _impl
of the class looks like
void addUpdateListener(OpStatus_out opStatus, _objref_IPlanningUpdateListener* listener) {
std::cout << "addUpdateListener called\n";
}
I've managed to register all my services with the ORB correctly and but I don't know how to actually call this method. I've got a pointer to the service that I want to be added as a listener but it's not of the correct type. Does anyone know why omniidl
converts the existing OpStatus and IPlanningUpdateListener types in the IDL
into the new OpStatus_out
and _objref_IPlanningUpdateListener
types. I thought for out parameters all I needed to do was pass a reference.
IPlanningUpdateListener_impl* listener // initialised and registered earlier
OpStatus opStatus;
myClass->addUpdateListener(opStatus, listener);
My two questions are how do I get this method to accept my implementation of the IPlanningUpdateListener as a parameter and what do I need to do to convert the OpStatus struct into the OpStatus_out type that the omniidl
has created?
Upvotes: 0
Views: 1533
Reputation: 1391
In the client change OpStatus to a _var.
OpStatus_var opStatus;
myClass->addUpdateListener(opStatus, listener);
The implementation will create a new struct to return.
void addUpdateListener(OpStatus_out opStatus, _objref_IPlanningUpdateListener* listener)
{
opStats = new OpStatus;
...
}
Upvotes: 4