ThingWorx Edge SDK Extensions for the C SDK > Creating a Directory of Registered Shapes and Templates
  
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
templateConstructorFunction);
To register a template constructor function and its name, call:

void twExt_RegisterShape(char *shapeName, shapeHandlerFunction
shapeConstructorFunction);
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 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:

twExt_CreateThingFromTemplate("myNewThing","WarehouseTemplate",
"InventoryShape","AddressShape",NULL);
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 that 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().