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 
Switch to threaded view of this topic Create a new topic Submit Reply
Ptr_Wrapper (Useful?) [message #41701] Tue, 23 November 2004 08:01 Go to next message
gambler_1650 is currently offline  gambler_1650
Messages: 5
Registered: November 2004
Junior Member
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
Re: Ptr_Wrapper (Useful?) [message #41825 is a reply to message #41701] Wed, 24 November 2004 07:42 Go to previous messageGo to next message
gambler_1650 is currently offline  gambler_1650
Messages: 5
Registered: November 2004
Junior Member
Thanks for the responses. I'll have to look into the Heap_free
routine in more detail than I have. I've posted the file to the RSI
site, should be up in a day or so. Just as a reminder, the code
relies of David Fanning's "linkedlist_define.pro".

Robert Gamble
Re: Ptr_Wrapper (Useful?) [message #41843 is a reply to message #41701] Tue, 23 November 2004 11:54 Go to previous messageGo to next 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
------------------------------------------------------------ --------------
Re: Ptr_Wrapper (Useful?) [message #41935 is a reply to message #41825] Tue, 30 November 2004 08:41 Go to previous message
gambler_1650 is currently offline  gambler_1650
Messages: 5
Registered: November 2004
Junior Member
Just a note for anyone interested... The Ptr_Wrapper is now on the
rsinc site for download under Utilities.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: FITS image with RA and DEC axis
Next Topic: Serial Port

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

Current Time: Wed Oct 08 14:21:58 PDT 2025

Total time taken to generate the page: 0.00584 seconds