Hello Johannes,
Johannes Brunen wrote:
[SNIP - code]
> So now for my questions. Can I use the XUnrecPtr pointers in the
> 'some_create_func' function, or is it necessary to use the XRecPtr
> variant?
your code is fine.
> Will my scene be correct in a cluster environment after the
> next commitChanges call?
commitChanges does not trigger a sync in the cluster or across aspects,
it calls the changed() function of containers that have modified fields
so they get a chance to update data that depends (is derived from) the
modified fields.
Your code is also fine for use in a cluster.
> Is it then correct that I only need the XRecPtr
> at the terminal points of my structures?
yes.
> Another scenario: Imagine that I have some function f which takes a
> native Node pointer parameter. This function internally does store the
> Node pointer into a Node(Un)RecPtr. Is my assumption correct that node p
> is still valid after f has finished?
it does not really matter what f is doing, since the object is
(hopefully) alive when it comes into f, it has to be alive afterwards
unless f has also access to the smart pointer maintaining the reference
to the node.
> I.e. that the OpenSG smart pointers
> are different from the boost shared_ptr pointers which would delete the
> native heap object they are responsible for?
OpenSG's pointers only modify the object's reference count, if the ref
count drops to zero the object deletes itself.
> Thinking about it, is it
> correct that the OpenSG smart pointers are like the boost intrusive
> pointers?
well, they *are* intrusive ;)
> void f(Node* p)
> {
> NodeUnrecPtr x(p);
> NodeUnrecPtr y = p;
> }
the call site for f has to look like this (the point here is that p has
to point to a Node with ref count >= 1):
Node{Unrec,Rec}Ptr n = Node::create();
// object pointed-to by n has ref count 1
f(n);
// construction of x increases the ref count to 2
// copy assignment to y increases the ref count to 2
// destruction of y decreases the ref count to 2
// destruction of x decreases the ref count to 1
Cheers,
Carsten
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users