The most natural way to express member instance (C++) in Slice

in Help Center
For performance reasons, I use class instances that are direct members of other instances all over the place:
class A {int foo();};
class B {A bar;};
class C {B blah;};
What is the natural (with little boilerplate code) way to express this situation in Slice, so that, in the ideal case, remote calls look like the local ones, i.e.
C a;
a.blah.bar.foo()
I have a feeling that this pattern would have refcounting issues...
(I know I could have probably answered this question myself if I read the manual carefully, but I need a quick estimate of the amount of work needed to accomplish this in an elegant way.)
Thanks for any information!
class A {int foo();};
class B {A bar;};
class C {B blah;};
What is the natural (with little boilerplate code) way to express this situation in Slice, so that, in the ideal case, remote calls look like the local ones, i.e.
C a;
a.blah.bar.foo()
I have a feeling that this pattern would have refcounting issues...
(I know I could have probably answered this question myself if I read the manual carefully, but I need a quick estimate of the amount of work needed to accomplish this in an elegant way.)
Thanks for any information!
0
Comments
Are the 3 class instances supposed to be distributed within different processes or will they always be within the same process? There are several ways to write the Slice for the classes you describe.
Here are 2 examples which should highlight this:
Second example:
In the first example, the Slice uses proxies. The Ice object for A, B and C can be hosted in different processes.
In the second example, the Slice uses class references. When a C instance is passed to the op() implementation, the whole object graph associated to C is provided to the op method.
In any case there shouldn't be reference counting issues. See the sections starting at "Smart Pointers and Cycles" in the C++ mapping reference for more information.
Cheers,
Benoit.
Instead you would need to specify accessors for each attribute. You would also typically instead just use Slice interfaces. So here's the correct first example:
Cheers,
Benoit.