the sid::component_library interface

Every component library must contain a sid::component_library structure in order for SID to load and instantiate its components. For example, assuming the definition of suitable functions exampleListTypes, exampleCreate, and exampleDelete, the following declaration would provide an interface for SID to instantiate components:

      extern const component_library example_component_library;
      const component_library example_component_library DLLEXPORT =
       & exampleListTypes,
       & exampleCreate,
       & exampleDelete

The precise type and meaning of these fields follows.

      host_int_4 magic;

      vector<string> (*list_component_types) ();

      component* (*create_component) (const string& typeName);
      void (*delete_component) (component* c);

The sid::component_library structure contains a magic number, for API version compatibility assurance, as well as pointers to 3 functions. The magic number should be initialized to the constant COMPONENT_LIBRARY_MAGIC, provided in SID's headers. The function pointed to by list_component_types must return a vector containing the string names of each type of component found in this library. These names are the same names used in the configuration command language, for example:

The function pointed to by create_component takes such a component name, and should construct a component of the given type and returns a pointer to it. If construction fails or an unknown type of component was requested, the function may return the value 0 to indicate failure. The function pointed to by delete_component should delete the provided component.