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

Home » Public Forums » archive » Abstract Objects and Methods
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
Abstract Objects and Methods [message #12126] Mon, 22 June 1998 00:00
Phillip & Suzanne is currently offline  Phillip & Suzanne
Messages: 31
Registered: June 1998
Member
While looking into using IDL's OO-based technologies, I came up with another
interesting question. Is there any way in IDL to create an abstract method?
An abstract method is a method common to all objects of a particular class
whose implementation is not defined in the parent class. For example, if I
had a class "Shape", and wanted it to have a method "Area", I would like to
declare the method Area as abstract because no particular method makes sense.
For a circle, area = pi * r^2; for a square, area = side^2; for a rectangle,
area=l*w; .... An abstract method requires subclasses to define the method,
but doesn't specify the implementation (other than perhaps the calling sequence).

Any class that contains an abstract method must also be abstract. That's an
easier problem to solve. Here's a basic abstract class:

----- Sample code -----

function abstract::init
ok = Widget_Message(/Error, $
[ 'Class ABSTRACT cannot be instantiated.', $
'It is an abstract class.', $
'You must create a subclass of it.'])
return, 0
end

pro abstract__define
struct = {ABSTRACT, NULL:0b}
end

----- End sample code -----

When you create a concrete subclass, the init method doesn't call its parent's
init method (or else it fails), but it returns success when it succeeds.

Does anyone know of any way to make sure a method has been overriden by a
child class? The only thought I have is to make the class return a
{structure/object/status} that contains a status code, with one specifying
that the abstract routine was invoked rather than the concrete subclass of the
abstract routine. Any better ideas?

Phillip
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Graphic Window
Next Topic: IDL Object for creating a Singleton

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

Current Time: Sat Oct 11 07:47:07 PDT 2025

Total time taken to generate the page: 0.40010 seconds