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

Home » Public Forums » archive » Re: singleton usage
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: singleton usage [message #47604] Tue, 21 February 2006 10:28 Go to previous message
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Tue, 21 Feb 2006 15:47:26 +0100, Antonio Santiago wrote:

> vcarlos wrote:
>> Hi Antonio,
>>
>> I saw the system variable singleton implementation, but what I am in
>> doubt is about the usage of the pattern itself. Since everytime I need a
>> reference to the singleton object in my objects I need to call a
>> myObject = Singleton() statement, or initialize an attribute in every
>> object needing a reference to the singleton. But what if I just create a
>> read only system variable and use it over my whole program? (this
>> variable would be an instance of my "singleton" class)
>>
> Ok sorry, I don't understand you in the first email. Yes, I think you can
> do it, but this is a convention that you use in your program. Then you
> need to document very well that variable XXX is a "reference" to a
> singleton object in your whole application.

Using a singleton generator is easy (see various threads dating back
several years). As far as preventing rogue "obj_new()" calls, you can
also check the common block or system variable explicitly in the Init
function and generate an error if anyone uses it directly (except for
the first call).

JD
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: IDL Graphics Objects & Heap Variables
Next Topic: Adding a GEOTIFF header to a (large) TIF file

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

Current Time: Fri Oct 10 10:33:29 PDT 2025

Total time taken to generate the page: 1.36482 seconds