Re: WG: Problem testing corba application

Darren Middleman <[email protected]> Fri, 9 Dec 2005 16:52:45 -0330
Newsgroups gmane.comp.corba.orbacus
Organization IONA | Making Software Work Together TM
Message-ID <[email protected]>
Hi Jean-Louis,

> I try now to better explain what I am trying to do.
> 
> In IDL I have two interfaces
> // IDL
> module eLockidl {
> 	// Place definition
> 	interface placeCorba {
> 		typedef string  description;
> 		string	getDescription();
> 		void	setDescription(in string inDescription);
> 		void	save();
> 	};
> 	// PlaceTable definition
> 	interface placetableCorba {
> 		placeCorba	getNew();
> 	};
> };
> 
> The client uses the getNew function to get a new placeCorba:
> 
> class obj_Place : virtual public POA_eLockidl::placeCorba {
> 	public:
> 			obj_Place(table* inTable);
> 		virtual	~obj_Place();
> 
> 		char*	getDescription(); 
> 		void	setDescription(const char* inDescription);
> 		void	save();
> 	private:
> 		char*	description;
> };.
> 
> class vdb_placetable: public table, virtual public POA_eLockidl::placetableCorba {
> 	public:
> 		vdb_placetable();
> 		~vdb_placetable();
> 	public:
> 		::eLockidl::placeCorba_ptr getNew();
> };
> //
> // This method returns an obj_Place object
> //
> ::eLockidl::placeCorba_ptr	vdb_placetable::getNew() {
> 		//return new obj_Place(this);
> 		return	(::eLockidl::placeCorba_ptr) new obj_Place(this);
> 		}
> 
> <snip>

The problem here is that you can't simply cast your obj_Place object to a 
::eLockidl::placeCorba_ptr.  Instead, you need to create a new instance of
your obj_Place objects and then call the '_this()' operation to obtain
::eLockidl::placeCorba_ptr you are looking for.  It should look something
like this:

    obj_Place* myObjPlace = new obj_Place(this);
    ::eLockidl::placeCorba_var placeRef = myObjPlace -> _this();
    return placeRef._retn();

Have a look at the hello demo server code to see a similar sort of thing
done to create the implementation object right after the POA manager
reference is obtained.

Regards,
Darren

-- 
Darren Middleman, Software Engineer
Team Orbacus - Your CORBA Source
Email: mailto:[email protected]
WWW: http://www.orbacus.com/
_______________________________________________
OB-Users Mailing List - [email protected]
http://mail.ooc.nf.ca/mailman/listinfo/ob-users
Visit our support FAQ before you send a message.
http://www.orbacus.com/faq/support.html