Creating a Directory of Registered Shapes and Templates
Referring to a Shape or Template as a pointer to a function can be limiting. The ability to reference a Thing or Shape by a name allows for the verification of the presence of the Shape or Thing. In addition, when the name is resolved, your application can perform additional construction activities. The C Edge Extensions maintain a directory of available Thing and Shape names in the form of a Hash Table that converts the Name into a construction function.
To register a shape constructor function and its name, call:

void twExt_RegisterTemplate(char *templateName, templateHandlerFunction
To register a template constructor function and its name, call:

void twExt_RegisterShape(char *shapeName, shapeHandlerFunction
The registration functions allow the constructor functions to be looked up when the call to create an instance of an EdgeThing is made:

void twExt_CreateThingFromTemplate(char* thingName,
char* templateName, ...);
twExt_CreateThingFromTemplate requires the following parameters:
thingName—The name of the Thing to create.
templateName—The name of a single Thing Template on which to base the new Thing.
A NULL terminated list of strings that contains the shapes that you want to include.
An example of using this call would be:

Note that the last parameter MUST be NULL to signal the end of the list of Shapes. Also note that no reference to the created Thing is returned. Another API call, which references the Thing by its thingName, accesses the properties of that Thing.
The task of registering shapes and templates must occur before any Edge Extension can be used by twExt_CreateThingFromTemplate().
Was this helpful?