On Mon, Mar 16, 2009 at 10:44 AM, Dirk Reiners <[email protected]> wrote:
> Marcus Lindblom wrote:
>> Allen Bierbaum wrote:
>>> Hello all:
>>>
>>> I am just starting to play with the new WeakPtr types in OpenSG. Very nice.
>>>
>>> I have one suggestion for the documentation. I think we should
>>> recommend a usage idiom for people to only use WeakPtr's if they have
>>> first been converted to Rec/Ref Ptrs. This would be similar to the
>>> recommended usage of boost weak pointers.
>>> (http://www.boost.org/doc/libs/1_38_0/libs/smart_ptr/weak_ptr.htm)
>>>
>> +1.
>
> Can we enforce this by not having conversions for weak pointers or is that too
> much of a hassle?
I would follow boost's lead and make a method like ".lock()" that
returns the RecPtr version. Then the user has to explicitly use that
to get anything.
NodeWeakPtr n = someOtherRef;
NodeRefPtr temp_ref = n.lock();
if(temp_ref != NULL)
{
std::cout << "temp_ref points to a live Node" << std::endl;
}
-Allen
------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Opensg-core mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-core