sequences containig object references
Gary D. Duzan
gdd0@gte.com
Tue, 28 Oct 1997 09:01:36 -0500
In Message <l03020301b07ab560b68d@[130.83.16.7]> ,
Bernd Daum <daum@dik.maschinenbau.tu-darmstadt.de> wrote:
=>I have some problems with sequences containig object references:
=>
=>the idl - code:
=>
=>interface Requirement_OB {
=> attribute string name;
=> };
=>
=>typedef sequence<Requirement_OB> T_list;
=>
=>interface List_of_Requirements_OB {
=> void get_Requirements(in string name, out T_list list);
=>};
=>
=>
=>C++ -code:
=>
=>Corba-Client:
=> . .
=>T_list_var* list = new T_list();
=>objref->get_Requirements(name,list); //calling the server
=>
=>
=>
=>Corba-server: implementation of the server method:
=>
=>List_of_Requirements_OB::get_Requirements( const char * name, T_list *&
=>list) {
=> .
=> .
=> list = new T_list();
=> list->length(0);
=>
=> for (CORBA::ULong i=0;iter.next()!=0;i++)
=> {
=> Requirement_OB_i *reqobj = new Requirement_OB_i(); //instantiation
=>of a new
=> // object -
=>inherits from
=> // the class
=>_sk_Requirement_OB
=> reqobj->name("temperature"); // populating the object
=> list->length(i+1);
=> (*list)[i] = reqobj; // inserting in the 'sequence'
=> }
=>}
I believe you want:
(*list)[i] = reqobj->_this(); // inserting in the 'sequence'
Also, if you don't already do it in the constructor, you need to
register the new Requirement_OB_i with the BOA. In fact, if I'm not
mistaken, you'll need to register with the BOA before the call to
_this().
Gary D. Duzan
GTE Laboratories