Archived

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

C++ class replication where member variables are pointers to slice classes

Hi there,

I just wanted to confirm that it is NOT possible to replicate the following "child" class using ICE :

slice :
class parent {
int var;
};

C++ :

class parentI : public parent {
};

class child {
vector<parentI*> vars;
};

Comments

  • benoit
    benoit Rennes, France
    Hi,

    It's not clear to me what you're trying to do. If you want to perform a shallow copy of the object, assuming the Slice class is not abstract, you can use ice_clone, see here for more information.

    Cheers,
    Benoit.
  • Yes, I can see now in review, that my question isn't very clear. Thanks for letting me know - I am not sure if this is a shallow copy thing ... perhaps I can elaborate ...

    Try this ....

    slice :
    interface base {}

    class parent {
    int var;
    };

    C++ :

    class child : public base {
    vector<parent*> vars;
    };

    Essentially, I want to ObjectAdapter::add the "child" to the adapter on one side of the network and then ObjectAdapter::find it on the other side of the network. However, the point is that I would like the 'find' to return the object pointer with all of the vars->var values to be the same on both sides for all i.

    My current belief is that it isn't possible without a more significant amount of work (by adding and finding each of the vars for all i) or without changing my abstract classes... because the system will not copy the states of the vector vars for me unless they are registered with the adapter first and then individually requested from the adapter using find. Is that correct ? Or is there perhaps some trick or knowledge I am missing ?

    Matt