fourdst_plugin 0.0.1a
C++ Plugin Manager
Loading...
Searching...
No Matches
plugin_factory.h File Reference

Plugin factory system and macros for creating loadable plugins. More...

Classes

class  fourdst::plugin::IPluginBase
 Base class providing default implementations for plugin identification. More...
 
class  fourdst::plugin::PluginBase
 

Namespaces

namespace  fourdst
 
namespace  fourdst::plugin
 Main namespace for the FourDST plugin system.
 

Macros

#define FOURDST_PLUGIN_EXPORT   extern "C"
 Platform-specific macro for exporting plugin symbols on other compilers.
 
#define FOURDST_DECLARE_PLUGIN(className, pluginName, pluginVersion)
 Macro to declare a plugin with automatic factory function generation.
 

Typedefs

typedef IPlugin *(* fourdst::plugin::plugin_creator_t) ()
 Function pointer type for plugin creation functions.
 
typedef void(* fourdst::plugin::plugin_destroyer_t) (IPlugin *)
 Function pointer type for plugin destruction functions.
 

Detailed Description

Plugin factory system and macros for creating loadable plugins.

This file provides the infrastructure for creating dynamically loadable plugins. It includes platform-specific export macros, base classes for plugin implementation, and convenience macros for plugin declaration.

Macro Definition Documentation

◆ FOURDST_DECLARE_PLUGIN

#define FOURDST_DECLARE_PLUGIN ( className,
pluginName,
pluginVersion )
Value:
static_assert(std::is_base_of_v<fourdst::plugin::PluginBase, \
className>, \
#className " must inherit from fourdst::plugin::PluginBase"); \
return new className(pluginName, pluginVersion); \
} \
FOURDST_PLUGIN_EXPORT void destroy_plugin(fourdst::plugin::IPlugin* plugin) { \
delete plugin; \
}
Abstract base interface for all plugins.
Definition iplugin.h:24
Definition plugin_factory.h:70
#define FOURDST_PLUGIN_EXPORT
Platform-specific macro for exporting plugin symbols on other compilers.
Definition plugin_factory.h:26

Macro to declare a plugin with automatic factory function generation.

This macro should be used in exactly one source file per plugin to generate the required factory functions and define the plugin metadata. It creates:

  • Global variables for plugin name and version
  • create_plugin() function that instantiates the plugin class
  • destroy_plugin() function that safely deletes the plugin instance
Parameters
classNameThe C++ class name that implements the plugin interface
pluginNameA string literal containing the plugin's name
pluginVersionA string literal containing the plugin's version
Note
This macro must be used exactly once per plugin library
The className must be a complete type at the point of macro expansion
The className must be default-constructible

Example usage:

class MyPlugin : public fourdst::plugin::PluginBase {
// ... plugin implementation
};
FOURDST_DECLARE_PLUGIN(MyPlugin, "my_plugin", "1.0.0");
#define FOURDST_DECLARE_PLUGIN(className, pluginName, pluginVersion)
Macro to declare a plugin with automatic factory function generation.
Definition plugin_factory.h:123

◆ FOURDST_PLUGIN_EXPORT

#define FOURDST_PLUGIN_EXPORT   extern "C"

Platform-specific macro for exporting plugin symbols on other compilers.