PtexPtr API Suggestion: Add reset(T* ptr=0)

11 views
Skip to first unread message

Sebastian Thiel

unread,
Apr 23, 2011, 3:02:28 AM4/23/11
to ptex
Hi,

When using the PTex API and PtexPtr instances, I noticed one
inconvenience which could easily be fixed.
Assume we want to have a persistent PtexPtr to a texture, and change
the texture it points to as we go. Currently, the code for doing so
looks like this:

typedef PtexPtr<PtexTexture> PtexTexturePtr;

PtexTexturePtr ptex; // Dummy with a null pointer
m_ptex_texture.swap(ptex); // swap it in

What I am used to doing from std::auto_ptr and the likes is the
following:

m_ptex_texture.reset();

Reset could also be used to put in a new pointer

m_ptex_texture.reset(my_new_texture);

The implementation would be trivial, and it would greatly help the
ease of use of this part of the Ptex API.

Thanks,
Sebastian

brentb

unread,
May 2, 2011, 10:43:47 AM5/2/11
to ptex
On Apr 23, 12:02 am, Sebastian Thiel <byron...@googlemail.com> wrote:
> Assume we want to have a persistent PtexPtr to a texture, and change
> the texture it points to as we go.

>    m_ptex_texture.reset();
>    m_ptex_texture.reset(my_new_texture);
>
> The implementation would be trivial, and it would greatly help the
> ease of use of this part of the Ptex API.

Thanks for the sug. Sebastian. I'll look into adding the reset method.

brentb

unread,
May 2, 2011, 12:26:51 PM5/2/11
to ptex
The new reset method is there now in a new tagged version, v2.0.29.

Sebastian Thiel

unread,
May 3, 2011, 5:09:06 AM5/3/11
to ptex
Great to hear that ! Thank you very much !
Cheers,
Sebastian
Reply all
Reply to author
Forward
0 new messages