1.1 --- a/core/interfaces/IPluginSys.h Fri Nov 10 18:08:13 2006 +0000
1.2 +++ b/core/interfaces/IPluginSys.h Sat Nov 11 01:19:46 2006 +0000
1.3 @@ -7,6 +7,8 @@
1.4 #define SMINTERFACE_PLUGINMANAGER_NAME "IPluginManager"
1.5 #define SMINTERFACE_PLUGINMANAGER_VERSION 1
1.6
1.7 +#define SM_CONTEXTVAR_USER 3
1.8 +
1.9 namespace SourceMod
1.10 {
1.11 /**
1.12 @@ -34,31 +36,66 @@
1.13 Plugin_BadLoad, /* Plugin failed to load */
1.14 };
1.15
1.16 +
1.17 /**
1.18 * @brief Describes the object lifetime of a plugin.
1.19 */
1.20 - enum PluginLifetime
1.21 + enum PluginType
1.22 + {
1.23 + PluginType_Private, /* Plugin is privately managed and receives no forwards */
1.24 + PluginType_MapUpdated, /* Plugin will never be unloaded unless for updates on mapchange */
1.25 + PluginType_MapOnly, /* Plugin will be removed at mapchange */
1.26 + PluginType_Global, /* Plugin will never be unloaded or updated */
1.27 + };
1.28 +
1.29 +
1.30 + class IPlugin;
1.31 +
1.32 +
1.33 + /**
1.34 + * @brief Encapsulates a basic function call.
1.35 + * NOTE: Function calls must be atomic to one execution context.
1.36 + * NOTE: This object should not be deleted. It lives for the lifetime of the plugin.
1.37 + */
1.38 + class IPluginFunction
1.39 {
1.40 - PluginLifetime_Forever, /* Plugin will never be unloaded */
1.41 - PluginLifetime_Map /* Plugin will be unloaded at mapchange */
1.42 + public:
1.43 + virtual ~IPluginFunction()
1.44 + {
1.45 + }
1.46 +
1.47 + /**
1.48 + * @brief Executes the function with the given parameter array.
1.49 + * Parameters are read in forward order (i.e. index 0 is parameter #1)
1.50 + *
1.51 + * @param param Array of cell parameters.
1.52 + * @param num_params Number of parameters to push.
1.53 + * @param result Pointer to store result of function on return.
1.54 + * @return SourcePawn error code (if any).
1.55 + */
1.56 + virtual int CallFunction(cell_t *params, unsigned int num_params, cell_t *result) =0;
1.57 +
1.58 + /**
1.59 + * @brief Returns which plugin this function belongs to.
1.60 + */
1.61 + virtual IPlugin *GetParentPlugin() =0;
1.62 };
1.63
1.64
1.65 /**
1.66 * @brief Encapsulates a run-time plugin as maintained by SourceMod.
1.67 */
1.68 - class IPlugin /*: public IUnloadableParent*/
1.69 + class IPlugin
1.70 {
1.71 public:
1.72 - /*UnloadableParentType GetParentType()
1.73 + virtual ~IPlugin()
1.74 {
1.75 - return ParentType_Module;
1.76 - }*/
1.77 - public:
1.78 + }
1.79 +
1.80 /**
1.81 * @brief Returns the lifetime of a plugin.
1.82 */
1.83 - virtual PluginLifetime GetLifetime() const =0;
1.84 + virtual PluginType GetType() const =0;
1.85
1.86 /**
1.87 * @brief Returns the current API context being used in the plugin.
1.88 @@ -111,19 +148,25 @@
1.89 virtual bool SetPauseState(bool paused) =0;
1.90
1.91 /**
1.92 - * @brief Locks or unlocks the plugin from being updated on mapchange.
1.93 - */
1.94 - virtual void SetLockForUpdates(bool lock_status) =0;
1.95 -
1.96 - /**
1.97 - * @brief Returns whether the plugin is locked from being updated on mapchange.
1.98 - */
1.99 - virtual bool GetLockForUpdates() const =0;
1.100 -
1.101 - /**
1.102 * @brief Returns the unique serial number of a plugin.
1.103 */
1.104 virtual unsigned int GetSerial() const =0;
1.105 +
1.106 + /**
1.107 + * @brief Returns a function by name.
1.108 + *
1.109 + * @param public_name Name of the function.
1.110 + * @return A new IPluginFunction pointer, NULL if not found.
1.111 + */
1.112 + virtual IPluginFunction *GetFunctionByName(const char *public_name) =0;
1.113 +
1.114 + /**
1.115 + * @brief Returns a function by its id.
1.116 + *
1.117 + * @param func_id Function ID.
1.118 + * @return A new IPluginFunction pointer, NULL if not found.
1.119 + */
1.120 + virtual IPluginFunction *GetFunctionById(funcid_t func_id) =0;
1.121 };
1.122
1.123
1.124 @@ -159,6 +202,42 @@
1.125 virtual void Release() =0;
1.126 };
1.127
1.128 + /**
1.129 + * @brief Listens for plugin-oriented events.
1.130 + */
1.131 + class IPluginsListener
1.132 + {
1.133 + public:
1.134 + /**
1.135 + * @brief Called when a plugin is created/mapped into memory.
1.136 + */
1.137 + virtual void OnPluginCreated(IPlugin *plugin)
1.138 + {
1.139 + }
1.140 +
1.141 + /**
1.142 + * @brief Called when a plugin is fully loaded successfully.
1.143 + */
1.144 + virtual void OnPluginLoaded(IPlugin *plugin)
1.145 + {
1.146 + }
1.147 +
1.148 + /**
1.149 + * @brief Called when a plugin is unloaded (only if fully loaded).
1.150 + */
1.151 + virtual void OnPluginUnloaded(IPlugin *plugin)
1.152 + {
1.153 + }
1.154 +
1.155 + /**
1.156 + * @brief Called when a plugin is destroyed.
1.157 + * NOTE: Always called if Created, even if load failed.
1.158 + */
1.159 + virtual void OnPluginDestroyed(IPlugin *plugin)
1.160 + {
1.161 + }
1.162 + };
1.163 +
1.164
1.165 /**
1.166 * @brief Manages the runtime loading and unloading of plugins.
1.167 @@ -188,7 +267,7 @@
1.168 */
1.169 virtual IPlugin *LoadPlugin(const char *path,
1.170 bool debug,
1.171 - PluginLifetime lifetime,
1.172 + PluginType type,
1.173 char error[],
1.174 size_t err_max) =0;
1.175
1.176 @@ -221,6 +300,20 @@
1.177 * Note: This pointer must be freed using EITHER delete OR IPluginIterator::Release().
1.178 */
1.179 virtual IPluginIterator *GetPluginIterator() =0;
1.180 +
1.181 + /**
1.182 + * @brief Adds a plugin manager listener.
1.183 + *
1.184 + * @param listener Pointer to a listener.
1.185 + */
1.186 + virtual void AddPluginsListener(IPluginsListener *listener) =0;
1.187 +
1.188 + /**
1.189 + * @brief Removes a plugin listener.
1.190 + *
1.191 + * @param listener Pointer to a listener.
1.192 + */
1.193 + virtual void RemovePluginsListener(IPluginsListener *listener) =0;
1.194 };
1.195 };
1.196