Writing Reggae classes

From MorphOS Library

Revision as of 20:40, 12 October 2010 by Krashan (talk | contribs)

Grzegorz Kraszewski


Reggae functionality can be extended by adding classes to it. New classes may be either public or private.

Private Reggae classes

Private classes are simple. They are statically linked with an application and may be only used in this single application. A private Reggae class is just a BOOPSI class derived from multimedia.class and implementing the standard set of Reggae methods. The class is created with MakeClass() and later referenced by pointer.

Public Reggae classes

A public Reggae class is more complicated. It is a separate disk based component, which may be loaded by any application. Public classes use shared library framework, so they are just a special case of MorphOS shared libraries. The differencies are as follows:

  • Public Reggae class has no shared library API, except of standard open, close and expunge vectors.
  • The class creates a named BOOPSI class at first open with MakeClass() and adds it to the system list with AddClass(). Then the class can be used by multiple applications (the code is shared) and is referenced by name, similarly to an ordinary shared library.

The following example shows the difference in creating objects of public and private class:


Object *pub, *priv;

priv = NewObject(PrivClassPointer, NULL, /* tags */, TAG_END);
pub = NewObject(NULL, "public.class", /* tags */, TAG_END);


Of course a public class has to be opened with OpenLibrary() before use (see opening and closing individual classes) and closed when no longer used.