I'm new to CORBA and is trying to create a Corba interface for my QT Application. I checked the data types that you could use with CORBA, but I'm not sure if I coul开发者_StackOverflow中文版d use a QT object as a parameter in a CORBA function. What I would want to pass is QWSPointerCalibrationData. Let's say I have a CORBA server code :
//pass data.screenPoints and data.devPoints
CORBA::Boolean Calibrate( QWSPointerCalibrationData data )
{
...
}
- Is this possible?
- If yes, how do I declare it in the IDL file?
- if not, what CORBA data type can I use so I could pass these type of data?
As you have the code, this is not possible. You have to specify IDL types equivalent to those that you're using in your application, and also provide (sigh, yes) conversion functions between those types defined in CORBA IDL and the ones defined in your application. As an advantage, you blind your application to future changes in the communication (or RPC) technology, as you're using internally your own types. In this case, looking at the documentation, the QWSPointerCalibrationData
type has two data members:
QPoint devPoints[5]
QPoint screenPoints[5]
Then you should declare in your IDL first the QPoint
type and then the QWSPointerCalibrationData
(I prepend the names with C_
to denote CORBA types):
// IDL
struct C_Point { long x; long y; };
typedef sequence<C_Point> Points;
struct C_WSPointerCalibrationData
{
Points devPoints;
Points screenPoints;
};
Then, your server method has to be:
CORBA::Boolean Calibrate( C_QWSPointerCalibrationData const& data )
{
QWSPointerCalibrationData qpcd = convert_from_CORBA_QWSPointerCalibrationData(data);
// use qpcd as usual here
}
and you have to write the convert_from_CORBA_QWSPointerCalibrationData
function yourself (and the corresponding that converts that type to the CORBA counterpart). There are some tools available to do that conversion, but yes, it is a pity, that must be done.
精彩评论