我是 CORBA 的新手,我正在努力将参数正确地传递到我想要调用的方法。该方法具有 IDL
签名
void addUpdateListener(out OpStatus opStatus, in IPlanningUpdateListener listener);
OpStatus
是一个结构体,定义为
struct OpStatus {
EComponent EComp;
EStatus State;
string Message;
}
enum EComponent { CompA, CompB, CompC };
enum EStatus { SUCCESS, FAILURE, RETRY };
和IPlanningUpdateListener
本身就是一个IDL
接口(interface)。
我已经实现了类的_impl
void addUpdateListener(OpStatus_out opStatus, _objref_IPlanningUpdateListener* listener) {
std::cout << "addUpdateListener called\n";
}
我已经成功地向 ORB 正确注册了我的所有服务,但我不知道如何实际调用此方法。我有一个指向我想添加为监听器的服务的指针,但它的类型不正确。有谁知道为什么 omniidl
将 IDL
中现有的 OpStatus 和 IPlanningUpdateListener 类型转换为新的 OpStatus_out
和 _objref_IPlanningUpdateListener
类型.我想到了输出参数,我需要做的就是传递一个引用。
IPlanningUpdateListener_impl* listener // initialised and registered earlier
OpStatus opStatus;
myClass->addUpdateListener(opStatus, listener);
我的两个问题是如何让此方法接受我的 IPlanningUpdateListener 实现作为参数,以及我需要做什么才能将 OpStatus 结构转换为 omniidl
具有的 OpStatus_out 类型创建?
最佳答案
在客户端中将 OpStatus 更改为 _var。
OpStatus_var opStatus;
myClass->addUpdateListener(opStatus, listener);
该实现将创建一个新结构以返回。
void addUpdateListener(OpStatus_out opStatus, _objref_IPlanningUpdateListener* listener)
{
opStats = new OpStatus;
...
}
关于c++ - 将参数传递给 C++ CORBA 方法实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7839170/