Index

Package: Object_Factory (generic)

Description

generic
    type Object_Class (<>) is abstract tagged limited private;
    type Object_Access is access Object_Class'Class;

    with procedure Delete( e : in out Object_Access );

-- This generic package is

Classes

Object_Class (abstract)

type Object_Class (<>) is abstract tagged limited private;

Types

Object_Access

type Object_Access is access Object_Class'Class;

Allocator

type Allocator is access function return Object_Access;

Subprograms & Entries

Delete

procedure Delete
( e: in out Object_Access );

Initialize

procedure Initialize
( factoryName: String );
Initializes the factory by name. The name should be the root type of objects that it manufactures. (ex: "entity", "actor", etc). Classes should be registered before the factory is initialized, preferably at elaboration time. Template instances of each registered class are created at initialization. An exception will be raised on error, from the first failure to instantiate a template instance.

Finalize

procedure Finalize;
Finalizes the factory, deleting template instances.

Allocate

function Allocate
( id: String ) return Object_Access;
Returns null if no allocator is registered for the given class id. If the allocator registered for 'id' raises an exception, it will be passed on to the caller.

Iterate_Classes

procedure Iterate_Classes
( examine: access procedure( id : String ) );
Iterate over the registered class id strings.

Register_Class

procedure Register_Class
( id: String;
allocate: not null Allocator );
Registers a class allocation function with a class id.

Template

function Template
( id: String ) return Object_Access;
Returns a reference to a template instantiation of the class registered with 'id'. Template entities are instantiated when the factory package is initialized. If no class is registered for the id, null will be returned. Do not modify the object that is returned!