Archived

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

Downcast for servant objects

Hi,
<1> How do I downcast an Object returned by findByProxy to a servant object. For example I am trying the following:

{
Ice::Object object_=adapter_->findByProxy(someproxy);

// now how d i convert this object_ to
// some ServantPtr objectTwo_. In short I am trying to extract a servant given the proxy.
}

<2>On another note, if i have an interface named
iMachine which is implemented by C++ class Machine.

how can iMachinePtr be converted to Machine*.

thanks
bks

Comments

  • marc
    marc Florida
    To downcast class instances, use:

    DerivedClassPtr derived = DerivedClassPtr::dynamicCast(base);

    You can downcast to an implementation by using a typedef like this:

    typedef IceUtil::Handle<Machine> MachinePtr;

    Then use MachinePtr::dynamicCast() as described above.
  • Marc,
    thanks that helped.

    bks