Go Back   ZeroC Forums > Help Center

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 04-05-2004
catalin catalin is offline
Registered User
 
 
Join Date: Jul 2003
Location: Oslo, Norway
Posts: 57
Going from "in" to "out" param, using a class as a union

Hi!

Given the following slice defs:

class A {...}; // no methods
class B extends A {...}; // no methods
class C extends A {...}; // no methods

interface IceIsCool {
bool Wow(A);
};


I am using the A class as a "union", because in my code I instantiate objects of say type BPtr , and make proxy calls like

MyIceIsCoolPrx->Wow(myBPointerObject);

In the implementation of the Wow operation, on the server side, I am doing a BPtr::dynamicCast(myAPtrParameter) in order to access all of B's members. Everything worked fine until I realized I would like to make the parameter to the Wow operation an "out" parameter.

So I changed my slice definitions to

class A {...}; // no methods
class B extends A {...}; // no methods
class C extends A {...}; // no methods

interface IceIsCool {
bool Wow(out A);
};


and in my implementation of the IceIsCoolI class I removed the const keyword from the operation's signature to make it compliant with the slice2cpp's output.

When I recompile now, I get an error message because the compiler expects an object of type APtr as a parameter to the MyIceIsCoolPrx->Wow(myBPointerObject); call.

So my question is, why was it OK to pass an object of type BPtr to the operation call when it had an "in" parameter and it is not OK when the parameter is declared as an "out" parameter? A call like MyIceIsCoolPrx->Wow(APtr::dynamicCast(myBPointerObject)); doesn't help either.

Thanks
Catalin
Reply With Quote
  #2 (permalink)  
Old 04-05-2004
marc's Avatar
marc marc is offline
ZeroC Staff
 
Name: Marc Laukien
Organization: ZeroC, Inc.
Project: The Internet Communications Engine
 
Join Date: Feb 2003
Location: Florida
Posts: 1,781
Consider your server would return a C, and not a B. In this case, you would try to assign a C to a B. So this cannot work. You can only use:
Code:
APtr a;
MyIceIsCoolPrx->Wow(a);
BPtr b = BPtr::dynamicCast(a);
I.e., Ice cannot implicitly downcast.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Unknow exception in "Printer" sample code wangh705 Help Center 6 10-26-2006 01:01 PM
Don't "Ice-3.1.1-VC71.msi " include the "slice2java.exe"? Jason Gao Help Center 4 10-26-2006 12:23 PM
Icepack registry "TimeOut" exception with heavy load eaglecn Help Center 1 05-26-2006 01:02 AM
PermissionDeniedException ,reason is "internal server error" ewiniar Help Center 2 05-18-2006 06:55 AM
"Invalid UTF8 string" when transer chinese chars between cpp server and csharp client raygo Help Center 8 03-21-2006 09:34 PM


All times are GMT -4. The time now is 11:56 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.