C4 Engine Terathon Software C4 Engine API Documentation

• System Utilities

API Links
Developer Links

class Constructor

Defined in:  C4Construction.h
The Constructor class template encapsulates a constructor function for application-defined subclasses.
Definition

template <class type, typename param = Unpacker&> class Constructor :

public ListElement<Constructor<type, param>>

Template Parameters
type The type of the base class for the application-defined class.
param The type of the data passed to the constructor function.
Constructor

Constructor(ConstructProc *proc);

Parameters
proc A pointer to the constructor function.
Description
The Constructor class template encapsulates a constructor function that is called when the engine encounters an object that is a subclass of the template parameter, but is of an application-defined type. The ConstructProc type is defined as follows.

typedef type *ConstructProc(param data, unsigned long flags);

An application should define a function having this signature, create a Constructor instance to encapsulate it, and then install the constructor object by calling the Constructable::InstallConstructor function.

When the engine calls the constructor function specified by the proc parameter, it passes in the custom data type specified by the param template parameter, which is normally a reference to an Unpacker object. The application should examine this data (normally by calling the Unpacker::GetType function) and return a newly constructed class corresponding to that type if it is recognized. If the type is not recognized, then the function should return nullptr to indicate that the remaining installed constructor objects are to be given the opportunity to construct the subclass.
Base Classes
ListElement<Constructor<type, param>> The Constructable class holds a list of Constructor instances.
See Also
Constructable