[cpp] Implementing structs: generic forwarders
- From: ERDI Gergo <cactus cactus rulez org>
- To: orbit-list gnome org
- Subject: [cpp] Implementing structs: generic forwarders
- Date: Tue, 12 Mar 2002 20:31:39 +0100 (CET)
You need to be able to create C containers (I'm looking at structures
right now, but this might apply for arrays and sequences as well) from C++
ones, to be able to implement IDLType::getCPPStubParameterTerm for them. I
propose to use C containers internally for structures, and create
forwarder classes for their contents, since according to the OMG specs,
you need to be able to export the members as simple members of the struct.
I.e.
// IDL
struct SomeStruct
{
IFoo obj_member;
long atomic_member;
}
// C++
class IFoo_forwarder
{
Module_IFoo &c_obj;
public:
void operator= (IFoo_mgr &cpp_obj)
{
c_obj = cpp_obj._orbitcpp_get_c_object ();
}
IFoo_mgr &operator ()
{
return IFoo::_orbitcpp_wrap (c_obj);
}
}
class SomeStruct
{
private:
Module_SomeStruct c_struct;
public:
IFoo_forwarder obj_member;
CORBA::Long &atomic_member;
}
thus, you would be able to do stuff like
SomeStruct my_struct;
my_struct.obj_member = my_foo;
my_struct.atomic_member = 12;
and never notice the underlying magic.
Of course, this is a rather large deviation from the current mechanism,
and the _forwarder classes are fully orbit-specific.
--
.--= ULLA! =---------------------. `We are not here to give users what
\ http://cactus.rulez.org \ they want' -- RMS, at GUADEC 2001
`---= cactus@cactus.rulez.org =---'
I am in total control, but don't tell my wife.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]