Re: [cpp] Implementing structs: generic forwarders



On Tue, 2002-03-12 at 20:31, ERDI Gergo wrote:
> 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;
> }

How is it helpful to put the operator= and cast operator in a member
variable's class rather than the C++ class itself? Where did you get the
name 'forwarder' from?

-- 
Murray Cumming
murrayc@usa.net
www.murrayc.com




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]