Archived

This forum has been archived. Please start a new discussion on GitHub.

Objects as argument ?

Hello,

from the documentation I see that objects can be passed as argument.
Since the client was generated using the Slice definition this should work. But what if the servant has referenced a derived class the client does not know about ?

What is sent to the client ? What does it instantiate ? Does it throw an exception ?


It would be ok if only structures without methods would be passed along. If the servant had a derived class it would only copy the struct corresponding to the argument type.


Passing objects is a nice and desirable feature but I think it is also problematic since we can't send methods.

Comments

  • For classes with operations, you must install an object factory. Have a look at demo/Ice/value for an example.
  • Re: Objects as argument ?
    Originally posted by ChMeessen
    Hello,

    from the documentation I see that objects can be passed as argument.
    Since the client was generated using the Slice definition this should work. But what if the servant has referenced a derived class the client does not know about ?

    What is sent to the client ? What does it instantiate ? Does it throw an exception ?

    If a class has operations, it is abstract and you need to install a factory for the concrete type of the class (or, at least, a factory for one of the base types of the class). If a class has only data members and no operations, the class is concrete and does not require a factory.

    If the sender sends a class instance that is more derived than the formal type and the receiver does not have static knowledge of the actual run-time type of the instance, the instance is sliced to the most derived type that the receiver understands. The value demo in the Ice distribution illustrates this.

    Cheers,

    Michi.