Re: Call a method from a class [message #47586 is a reply to message #47563] |
Wed, 15 February 2006 11:41  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
vcarlos writes:
> In some languages is possible to call methods from a Class, instead of
> a object. For instance, the class Messager could call a method
> reportError, message. This is useful when I just need a "instance" of
> that object and everybody takes advantage of that (I think that is
> similar to Singleton design pattern). Is there any way to the same in
> IDL? Or I should set up some kind of library procedures/functions and
> use through my program?
IDL's object programming abilities are not want you might
call "state of the art." "Middling" might be a better word.
In any case, there is no good way to create a singleton
object, although you will find many fascinating discussions
of how you might fake a singleton object if you search the
archives of this newsgroup with the term "singleton object".
Most of them boil down to either (1) saving an object
in a system variable you create for this purpose, or
(2) tricking up some kind of fancy common block name
that only you are ever likely to think of. I have used
both successfully, although I usually go for the common
block method, since it is so much fun to think up those
names!
A third approach is to include messaging functionality
in a low-level object that is inherited by every other
object that needs this functionality. This is a little more
work, but also works well.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|