Updated: October 28, 2024 |
Suppose you have an application that needs to use screensavers. You can define screensaver interfaces and write addons that expose functionality through these interfaces. Your application can then load the available addons that implement these interfaces and call functions to start, stop, and set options for a particular screensaver.
typedef struct { int32_t (*Initialize)(void); int32_t (*Uninitialize)(void); int32_t (*Options)(void); int32_t (*Start)(void); int32_t (*Stop)(void); } ScreenSaver;
typedef struct { int32_t (*LoadPrefs)(void); int32_t (*SavePrefs)(void); } ScreenSaverPrefs;
AOInterface_t interfaces[] = { { "Name", 0, "my_screensaver" }, { "ScreenSaver", SS_VERSION, &SS2 }, { "ScreenSaverPrefs", SS_PREFSVERSION, &SSP2 }, { 0, 0, 0 } };
The first interface, Name, makes the interface set discoverable to the library. Note the last dummy entry in the interface set; this is an end-of-list marker.
Your application can now use the AOI library to find the available addons (which are DLLs) that implement this set of interfaces. It can then allow the user to select and configure options for a particular screensaver. For an explanation of how your application can access and use the addon interfaces, see the Core API overview.
A more detailed example of writing an addon and the application code that compares addon ratings, selects the best one, and then uses it is given in the AoIterate() reference.