[omniORB] Returning complex types from server

Frederico Faria fred_faria at yahoo.com.br
Wed Apr 27 01:35:35 BST 2005


Hi  Graeme, Gunion, Borg, Brunt

 Thank you very much for your information. I was not
sure about the right way to return a struct. With your
information I was able to know how return complex
types. Now I am sure about this issue.

The code is working fine now. There was a bug in the
related code.

Best regards,

Frederico Faria

 --- graeme smith <graeme.smith28 at ntlworld.com>
escreveu: 
> This looks like memory management
> 
> Here's an extract from a server sending a complex
> object, although its
> an OUT parameter rather than a return parameter the
> memory management
> rules are the same for both, I believe.
> Fintan Bolton's book goes into this in detail.
> If you want to see the IDL behind the object see
> http://www.qmiss.org.uk/download/repository/
> 
> 
> Subscriptions::DataNotification oDataNotification;
> oDataNotification.userName =
> CORBA::string_dup("UTMCSimpleServer");
> oDataNotification.tableName =
> CORBA::string_dup("HEARTBEAT" );
> oDataNotification.viewName  =
> CORBA::string_dup("HEARTBEAT");
> oDataNotification.action = Subscriptions::UPDATE;
> TabularResults::ResultSet ResultSet;
> BuildHeartbeat(ResultSet);
> oDataNotification.results = ResultSet;
>
pPushSubscriptionSupplier->SendDataNotification(oDataNotification);
> 
> 
> support code mentioned in above
> 
> void
>
CPushSubscriptionSupplier::BuildHeartbeat(TabularResults::ResultSet&
> rResultSet)
> {
> 	rResultSet.rows = 1;
> 	rResultSet.columns.length(1);
> //	Column 0- long reserved 
> 	{
> 		TabularResults::Column oColumn;
> 		oColumn.flags = TabularResults::FLAG_NOT_NULLABLE
> |
> TabularResults::FLAG_READONLY;
> 		oColumn.width = 10+1;
> 		oColumn.scale = 0;
> 		oColumn.name  = CORBA::string_dup("Reserved");
> 		oColumn.label = CORBA::string_dup("");
> 		oColumn.values.longValues(1);
> 		oColumn.nulls.length(0);
> 		oColumn.values.longValues().length(1);
> 		oColumn.values.longValues()[0] = 0;
> 
> 		// Deep copy ?
> 		rResultSet.columns[0] = oColumn;
> 	}
> }
> 
> 
> 
> void
>
CPushSubscriptionSupplier::SendDataNotification(const
> Subscriptions::DataNotification& oDataNotification)
> {
> 
> 	
>
m_pNotificationTargetVar->notificationReceived(oDataNotification);
> 
> }
> 
> 
> 
> 
> 
> 
> 
> -----Original Message-----
> From: omniorb-list-bounces at omniorb-support.com
> [mailto:omniorb-list-bounces at omniorb-support.com] On
> Behalf Of Clarke
> Brunt
> Sent: 26 April 2005 15:10
> To: omniorb-list at omniorb-support.com
> Subject: RE: [omniORB] Returning complex types from
> server
> 
> > -----Original Message-----
> > From: omniorb-list-bounces at omniorb-support.com 
> > [mailto:omniorb-list-bounces at omniorb-support.com]
> On Behalf 
> > Of Frederico Faria
> >
> >  I have a general doubt about CORBA. I want return
> a
> > struct composed from another struct from my corba
> > server. But it looks that my returned struct is
> empty
> > when the client trys print its fields.
> > How can I do the right memory allocation in the
> server
> > to return correctly the struct ?
> > 
> > Example: ( it doesnt work )
> > 
> >   struct MyTime {
> > short   day;
> > short   month;
> > short   year;
> > short   second;
> > short   minute;
> > short   hour;
> > };
> > 
> >   struct MyEvent {
> >    short eventType;   
> >    MyTime eventTime;
> > }
> > interface  I1 
> > {
> >   MyEvent   getEvent()
> > }
> > ---------------------------------------------
> > // generated serevr implementation code
> > 
> >  MyEvent getEvent()
> > {
> >   MyEvent  event;
> >  // some code
> >   
> >  return  event;
> > }
> 
> I can't see anything wrong. You have a fixed length
> struct (one of its
> members happens to be another fixed length struct).
> Fixed length struct
> is
> returned from a method by value, so the signature of
> your getEvent
> method is
> correct, and it shouldn't matter that 'event' is a
> local variable in
> getEvent(), since a copy of it is being returned.
> 
> Unless I'm missing something (or indeed there's a
> bug - possibly I never
> used a fixed length struct myself), then I can only
> suggest you trying
> more
> experiments. Try something just returning an
> integer. Then try a struct
> that
> _doesn't_ have another struct as a member. etc...
> 
> -- 
> Clarke Brunt, Principal Software Engineer,
> Trafficmaster
> 
> 
> _______________________________________________
> omniORB-list mailing list
> omniORB-list at omniorb-support.com
>
http://www.omniorb-support.com/mailman/listinfo/omniorb-list
> 
> 
> _______________________________________________
> omniORB-list mailing list
> omniORB-list at omniorb-support.com
>
http://www.omniorb-support.com/mailman/listinfo/omniorb-list
>  


	
	
		
Yahoo! Acesso Grátis - Internet rápida e grátis. 
Instale o discador agora! http://br.acesso.yahoo.com/



More information about the omniORB-list mailing list