Parasol Framework
  • Gallery
  • API
  • Wiki
  • GitHub
    • Audio
    • Core
    • Display
    • Fluid
    • Font
    • Network
    • Vector
    • Audio
    • Sound
    • File
    • MetaClass
    • Module
    • StorageDevice
    • Task
    • Thread
    • Time
    • Compression
    • Config
    • Script
    • XML
    • Controller
    • BlurFX
    • ColourFX
    • CompositeFX
    • ConvolveFX
    • DisplacementFX
    • FilterEffect
    • FloodFX
    • ImageFX
    • LightingFX
    • MergeFX
    • MorphologyFX
    • OffsetFX
    • RemapFX
    • SourceFX
    • TurbulenceFX
    • WaveFunctionFX
    • Scintilla
    • ScintillaSearch
    • Bitmap
    • Clipboard
    • Display
    • Document
    • Font
    • Picture
    • Pointer
    • Surface
    • SVG
    • ClientSocket
    • HTTP
    • NetSocket
    • Proxy
    • Vector
    • VectorClip
    • VectorColour
    • VectorEllipse
    • VectorFilter
    • VectorGradient
    • VectorGroup
    • VectorImage
    • VectorPath
    • VectorPattern
    • VectorPolygon
    • VectorRectangle
    • VectorScene
    • VectorShape
    • VectorSpiral
    • VectorText
    • VectorTransition
    • VectorViewport
    • VectorWave

MetaClass Class

The MetaClass is used to manage all classes supported by the system core.

The MetaClass is responsible for managing the construction of new classes. Each MetaClass object remains active for the lifetime of the running program, and provides the benefit of run-time introspection so that detailed class information can be retrieved at any time. This enables scripting languages such as Fluid to interact with all class types without needing active knowledge of their capabilities.

A number of additional functions are available in the Core for the purpose of class management and introspection. FindClass() allows all registered classes to be scanned. CheckAction() verifies if a specific action is supported by a class. FindField() confirms if a specific field is declared in the class specification.

Classes are typically declared in modules, but if a class is intended to be private for an executable then declaring it within the application code is feasible also.

Further discussion on classes and their technical aspects can be found in the Parasol Wiki.

Structure

The MetaClass class consists of the following fields:

Access
NameTypeComment
  ActionTableAPTR []This field can be read to retrieve a MetaClass object's internal action table.

This field retrieves the internal action table of a class. The action table is arranged into a jump table of action routines, with each routine pointing directly to the object support functions. The size of the jump table is defined by the global constant AC::END. The table is sorted by action ID.

It is possible to check if an action is supported by a class by looking up its index within the ActionTable, for example Routine[AC::Read]. Calling an action routine directly from client code is an illegal operation.

  ActionsAPTRDefines the actions supported by the class.

Action routines are associated with a new class by referring to a list of ActionArray items in this field. Each provided action ID must be paired with its associated routine.

Internally, the provided list is copied to the ActionTable and the original values will serve no further purpose.

The following example shows a list of ActionArray structures borrowed from the Picture class. Note that such lists can also be auto-generated using our IDL scripts - an approach that we strongly recommend.

ActionArray clActions[] = {
   { AC::Free,          PIC_Free },
   { AC::NewObject,     PIC_NewObject },
   { AC::Init,          PIC_Init },
   { AC::Query,         PIC_Query },
   { AC::Read,          PIC_Read },
   { AC::SaveToObject,  PIC_SaveToObject },
   { AC::Seek,          PIC_Seek },
   { AC::Write,         PIC_Write },
   { 0, NULL }
};

Note: Never refer to method ID's in an action list - the Methods field is provided for this purpose.

  BaseClassIDCLASSIDSpecifies the base class ID of a class object.

The BaseClassID must always be set prior to the initialisation of a new MetaClass object unless ClassName is considered sufficient. If the BaseClassID is zero then the hash of ClassName is computed and set as the value of BaseClassID.

When defining a sub-class, it is required that the BaseClassID refers to the class that is being supported.

  CategoryCCFThe system category that a class belongs to.

When designing a new class it is recommended that a suitable category is chosen and declared in this field. It is acceptable for a class to be a member of multiple categories by combining category flags together.

NameDescription
CCF::AUDIOAudio classes interface with audio hardware and drivers for audio playback and recording purposes.
CCF::COMMANDCommand classes perform specific procedures, like copying or moving a file, managing volumes or executing a program.
CCF::DATAData classes parse, query and manipulate data.
CCF::FILESYSTEMFileSystem classes are based on file management and interaction with file based data.
CCF::GRAPHICSGraphics classes provide graphics management and drawing services.
CCF::GUIGUI classes are used in the development of graphical user interfaces.
CCF::IOI/O classes manage hardware and software based input and output.
CCF::MISCMiscellaneous classes do not fit into any of the other available categories.
CCF::MULTIMEDIAClasses that represent more than one media type, e.g. video files.
CCF::NETWORKNetwork classes interface with system drivers to simplify network communications.
CCF::SYSTEMSystem classes are designed to provide low-level services related to system management.
CCF::TOOLTools provide interactive services for the user.
  ClassIDCLASSIDSpecifies the ID of a class object.

The ClassID uniquely identifies a class. If this value differs from the BaseClassID, then the class is determined to be a sub-class. The ClassID value always reflects the strihash() computation of the ClassName, and is automatically set on initialisation if not already set by the client.

  ClassNameCSTRINGThe name of the represented class.

This field specifies the name of the represented class. Characters should be limited to those in the range of A-Z and written in camel case, e.g. KeyValue and not Keyvalue or KEYVALUE. Setting this field value is compulsory prior to initialisation.

  ClassVersionDOUBLEThe version number of the class.

This field value must reflect the version of the class structure. Legal version numbers start from 1.0 and ascend. Revision numbers can be used to indicate bug-fixes or very minor changes.

If declaring a sub-class then this value can be 0, but base classes must set a value here.

  Dictionarystruct Field *Returns a field lookup table sorted by field IDs.

Following initialisation of the MetaClass, the Dictionary can be read to retrieve the internal field lookup table. For base-classes, the client can use the binary search technique to find fields by their ID. For sub-classes, use linear scanning.

  Fieldsconst struct FieldArray *Points to a FieldArray that describes the class' object structure.

This field points to an array that describes the structure of objects that will be generated for this class. It is compulsory that base classes define this array. Sub-classes will inherit the structure of their base, but they may set Fields with additional virtual fields if desired.

Refer to the Parasol Wiki on class development for more information.

  FileDescriptionCSTRINGDescribes the file type represented by the class.

This field allows you to specify a description of the class' file type, if the class is designed to be file related. This setting can be important, as it helps to distinguish your class from the other file based classes. Always make sure that your file description is short, descriptive and unique. A file description such as JPEG is not acceptable, but JPEG Picture would be appropriate.

  FileExtensionCSTRINGDescribes the file extension represented by the class.

This field describes the file extension/s that the class will recognise. For example: *.wav|*.wave|*.snd.

Use of the vertical bar allows more than one file extension to be supported by the class. The file extension that is preferred for saving data must come first.

  FileHeaderCSTRINGDefines a string expression that will allow relevant file data to be matched to the class.

If a class supports file data, then the FileHeader field is used to identify the types of data that the class supports. This feature is used by routines that need to analyse files and determine which classes support them.

For example, the JPEG class supports files that start with a 32-bit token to identify them as JPEG. Declaring a FileHeader expression to match these tokens will allow the FileView feature to detect JPEG files and display an appropriate icon for each JPEG entry in the file list.

The expression format is [Offset:Value]...

The offset is an integer that identifies the byte position at which the given Value will be present. The Value is expressed as a hexadecimal number if it is prefixed with a dollar sign $, otherwise the Value is treated as case-sensitive text. Multiple expressions can be specified in sequence if there is more than one comparison to be made - so [0:$ff][8:$fe] would require $ff at offset 0 and $fe at offset 8 in order to generate a match.

In some cases, a series of unrelated token sequences may need to be used to match against files. This is true for the JPEG class, which supports three different tokens all at offset 0 for identification. Each matching sequence must be separated with an OR symbol | as demonstrated in this example for the JPEG header: [0:$ffd8ffe0]|[0:$ffd8ffe1]|[0:$ffd8fffe].

  FlagsCLFOptional flag settings.
NameDescription
CLF::INHERIT_LOCALInherit the functionality of local objects defined in the class spec.
CLF::NO_OWNERSHIPObjects created will not be tracked to the creating process, nor any parent object (SetOwner() will not work either).
  IconCSTRINGAssociates an icon with the file data for this class.

Files that belong to a class can be associated with an icon that is declared in this field. The icon string format is folder/icon. Valid icons are available in the icon database.

  LocationSTRINGReturns the path from which the class binary is loaded.

The path from which the class binary was loaded is readable from this field. The path may not necessarily include the file extension of the source binary.

  MethodsSTRUCT []Set this field to define the methods supported by the class.

If a class design will include support for methods, create a MethodEntry list and set this field prior to initialisation. The array must provide information on each method's ID, name, parameters, and structure size.

Note that method lists can be auto-generated using our IDL scripts - an approach that we strongly recommend.

  ModuleSTRINGThe name of the module binary that initialised the class.
  ObjectsINT []Returns an allocated list of all objects that belong to this class.

This field will compile a list of all objects that belong to the class. The list is sorted with the oldest object appearing first.

The resulting array must be terminated with FreeResource() after use.

  OpenCountINTThe total number of active objects that are linked back to the MetaClass.

This field reveals the total number of objects that reference the class. This figure will fluctuate over time as new objects are created and old ones are destroyed. When the OpenCount reaches zero, the Core may flush the Module that the class is related to, so long as no more programs are using it or any other classes created by the module.

  PathCSTRINGThe path to the module binary that represents the class.

The Path field must be set on initialisation and refers to the default location of the class' module binary, for example modules:display. For reasons of platform portability, the file extension must not be specified at the end of the file name.

  RootModuleOBJECTPTRReturns a direct reference to the RootModule object that hosts the class.
  SizeINTThe total size of the object structure represented by the MetaClass.

This field value must indicate the byte size of the objects that will be created from the MetaClass. For example, the Picture class defines this value as sizeof(objPicture).

If the size is not explicitly defined, the initialisation process will determine the structure size by evaluating the field definitions that have been provided.

Methods

The following methods are currently supported:

FindFieldSearch a class definition for a specific field.
ERR mc::FindField(OBJECTPTR Object, INT ID, struct Field ** Field, objMetaClass ** Source)
ParameterDescription
IDThe field ID to search for. Field names can be converted to ID's by using the strihash() function.
FieldPointer to the Field if discovered, otherwise NULL.
SourcePointer to the class that is associated with the Field (which can match the caller), or NULL if the field was not found.

This method checks if a class has defined a given field by scanning its blueprint for a matching ID. If found, a direct pointer to the Field struct will be returned to the client.

In some clases the field might not be present in the main class spec, but does appear in an integral class. In that case, a reference to the class will be returned in the Source parameter.

MetaClass class documentation © Paul Manias 1996-2025

CCF Type

Class categories

NameDescription
CCF::AUDIOAudio classes interface with audio hardware and drivers for audio playback and recording purposes.
CCF::COMMANDCommand classes perform specific procedures, like copying or moving a file, managing volumes or executing a program.
CCF::DATAData classes parse, query and manipulate data.
CCF::FILESYSTEMFileSystem classes are based on file management and interaction with file based data.
CCF::GRAPHICSGraphics classes provide graphics management and drawing services.
CCF::GUIGUI classes are used in the development of graphical user interfaces.
CCF::IOI/O classes manage hardware and software based input and output.
CCF::MISCMiscellaneous classes do not fit into any of the other available categories.
CCF::MULTIMEDIAClasses that represent more than one media type, e.g. video files.
CCF::NETWORKNetwork classes interface with system drivers to simplify network communications.
CCF::SYSTEMSystem classes are designed to provide low-level services related to system management.
CCF::TOOLTools provide interactive services for the user.
MetaClass module documentation © Paul Manias 1996-2025

CLF Type

Flags for the MetaClass.

NameDescription
CLF::INHERIT_LOCALInherit the functionality of local objects defined in the class spec.
CLF::NO_OWNERSHIPObjects created will not be tracked to the creating process, nor any parent object (SetOwner() will not work either).
MetaClass module documentation © Paul Manias 1996-2025

ActionArray Structure

FieldTypeDescription
RoutineAPTRPointer to the function entry point
ActionCodeACAction identifier
MetaClass class documentation © Paul Manias 1996-2025

Field Structure

Used to describe the public fields of a class.

FieldTypeDescription
ArgMAXINTAn option to complement the field type. Can be a pointer or an integer value
GetValueFUNCTION *A virtual function that will retrieve the value for this field.
SetValueAPTRA virtual function that will set the value for this field.
WriteValueFUNCTION *An internal function for writing to this field.
NameCSTRINGThe English name for the field, e.g. Width
FieldIDUINTProvides a fast way of finding fields, e.g. FID_Width
OffsetUINT16Field offset within the object
IndexUINT16Field array index
FlagsUINTSpecial flags that describe the field
MetaClass class documentation © Paul Manias 1996-2025

FieldArray Structure

Used to construct class blueprints for the MetaClass.

FieldTypeDescription
NameCSTRINGThe name of the field, e.g. Width
GetFieldAPTRvoid GetField(*Object, APTR Result);
SetFieldAPTRERR SetField(*Object, APTR Value);
ArgMAXINTCan be a pointer or an integer value
FlagsUINTSpecial flags that describe the field
MetaClass class documentation © Paul Manias 1996-2025