comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Ptr_Wrapper (Useful?)
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Ptr_Wrapper (Useful?) [message #41843 is a reply to message #41701] Tue, 23 November 2004 11:54 Go to previous message
Stein Vidar Hagfors H[2] is currently offline  Stein Vidar Hagfors H[2]
Messages: 28
Registered: October 2002
Junior Member
Nice - I see those books you recommended (thanks for the writeup, by the way -
didn't want to waste bandwidth for that alone, but here you go :-)

I would definitely find something like that useful! (Others should, too!)

gambler_1650@yahoo.com (Robert Gamble) writes:
> Greetings all. One of the first pieces of 'useful' code I wrote was
> an object that encapsulates pointer creation and deletion. It's a
> piece of simple code that utilizes David Fanning's "linkedlist".
> Everytime a pointer is created using the object, it's attached to a
> linked list. When the object is destroyed, the linked list is unwound
> and each pointer in the list is freed. There is also an explicit
> "free_ptrs" routine that allows destruction to be more controlled.
> The simplest way of using it is to create one ptr_wrapper object in
> each *.pro file and destroy it at the end. If you prefer to have
> different wrappers, each of which maintains its pointers for more
> specialized time frames for better efficiency, you can do that too.
> And finally, you can create and free pointers using the object
> methods just as you would normally in IDL.
>
> Quick example:
>
> PRO testptrs
>
> oPtr_Wrapper = Obj_New('ptr_wrapper')
> ptrA = oPtr_Wrapper->Ptr_New(/ALLOCATE_HEAP) ; Uses same keywords
> as Ptr_New
>
> .
> .
> .
>
> ptrB = oPtr_Wrapper->Ptr_New(/ALLOCATE_HEAP)
> .
> .
> .
> Obj_Destroy, oPtr_Wrapper
>
> END
>
>
> This bit of code is obviously simplistic and using the wrapper here
> would be wasteful. I've found it to be much more useful in objects
> where pointers are created in different routines. Each can be
> assigned to self.oPtr_Wrapper and then self.oPtr_Wrapper can be
> destroyed in the cleanup routine...
>
> If there's interest in the code, I'll be happy to e-mail the file or
> submit it to the RSI site.
>
> Robert Gamble

--
------------------------------------------------------------ --------------
Stein Vidar Hagfors Haugan
ESA SOHO SOC/European Space Agency Science Operations Coordinator for SOHO

NASA Goddard Space Flight Center, Tel.: 1-301-286-9028
Mail Code 682.3, Bld. 26, Room G-1, Cell: 1-240-354-6066
Greenbelt, Maryland 20771, USA. Fax: 1-301-286-0264
------------------------------------------------------------ --------------
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: FITS image with RA and DEC axis
Next Topic: Serial Port

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 12:18:19 PDT 2025

Total time taken to generate the page: 0.48125 seconds