core-1.4/IPluginManager.h
changeset 541 35a8cda28485
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/core-1.4/IPluginManager.h	Fri Nov 14 04:25:40 2008 -0600
     1.3 @@ -0,0 +1,137 @@
     1.4 +/* ======== SourceMM ========
     1.5 +* Copyright (C) 2004-2008 Metamod:Source Development Team
     1.6 +* No warranties of any kind
     1.7 +*
     1.8 +* License: zlib/libpng
     1.9 +*
    1.10 +* Author(s): David "BAILOPAN" Anderson
    1.11 +* ============================
    1.12 +*/
    1.13 +
    1.14 +#ifndef _INCLUDE_PLUGINMANAGER_H
    1.15 +#define _INCLUDE_PLUGINMANAGER_H
    1.16 +
    1.17 +/**
    1.18 + * @brief Plugin Manager interface
    1.19 + * @file IPluginManager.h
    1.20 + */
    1.21 +
    1.22 +typedef int PluginId;
    1.23 +
    1.24 +#include "ISmmPlugin.h"
    1.25 +
    1.26 +/**
    1.27 + * @brief Load sources
    1.28 + */
    1.29 +enum
    1.30 +{
    1.31 +	Pl_BadLoad=0,
    1.32 +	Pl_Console=-1,
    1.33 +	Pl_File=-2,
    1.34 +	Pl_MinId=1,
    1.35 +};
    1.36 +
    1.37 +/**
    1.38 + * @brief Status of a plugin at runtime
    1.39 + */
    1.40 +enum Pl_Status
    1.41 +{
    1.42 +	Pl_NotFound=-4,
    1.43 +	Pl_Error=-3,
    1.44 +	Pl_Refused=-2,
    1.45 +	Pl_Paused=-1,
    1.46 +	Pl_Running=0,
    1.47 +};
    1.48 +
    1.49 +typedef int PluginId;
    1.50 +struct factories;
    1.51 +
    1.52 +class ISmmPluginManager
    1.53 +{
    1.54 +public:
    1.55 +	/**
    1.56 +	 * @brief Loads a plugin and returns its id.  If this is called before DLLInit(),
    1.57 +	 *  then the plugin is considered to be "hot" - it might refuse its own load later!
    1.58 +	 *  Also, a hot plugin might not have an error message.
    1.59 +	 *
    1.60 +	 * @param file String containing file name
    1.61 +	 * @param source Specifies who loaded the plugin
    1.62 +	 * @param status Status of the plugin 
    1.63 +	 * @param ismm Pointer to Smm API
    1.64 +	 * @param error String buffer for error messages
    1.65 +	 * @param maxlen Maximum length of buffer
    1.66 +	 * @return Id of plugin
    1.67 +	 */
    1.68 +	virtual PluginId Load(const char *file, PluginId source, bool &already, char *error, size_t maxlen) =0;
    1.69 +
    1.70 +	/**
    1.71 +	 * @brief Unloads a plugin
    1.72 +	 *
    1.73 +	 * @param id Id of plugin
    1.74 +	 * @param error String buffer for error messages
    1.75 +	 * @param maxlen Maximum length of buffer
    1.76 +	 * @return True on success, false otherwise
    1.77 +	 */
    1.78 +	virtual bool Unload(PluginId id, bool force, char *error, size_t maxlen) =0;
    1.79 +
    1.80 +	/**
    1.81 +	 * @brief Pauses a plugin
    1.82 +	 *
    1.83 +	 * @param id Id of plugin
    1.84 +	 * @param error String buffer for error messages
    1.85 +	 * @param maxlen Maximum length of buffer
    1.86 +	 * @return True on success, false otherwise
    1.87 +	 */
    1.88 +	virtual bool Pause(PluginId id, char *error, size_t maxlen) =0;
    1.89 +
    1.90 +	/**
    1.91 +	 * @brief Unpauses a plugin
    1.92 +	 *
    1.93 +	 * @param id Id of plugin
    1.94 +	 * @param force If true, forces the plugin to unload
    1.95 +	 * @param error String buffer for error messages
    1.96 +	 * @param maxlen Maximum length of buffer
    1.97 +	 * @return True on success, false otherwise
    1.98 +	 */
    1.99 +	virtual bool Unpause(PluginId id, char *error, size_t maxlen) =0;
   1.100 +
   1.101 +	/**
   1.102 +	 * @brief Unloads all plugins forcefully
   1.103 +	 * 
   1.104 +	 * @return True on success, false otherwise
   1.105 +	 */
   1.106 +	virtual bool UnloadAll() =0;
   1.107 +
   1.108 +	/**
   1.109 +	 * @brief Returns information about a plugin
   1.110 +	 *
   1.111 +	 * @param id Id of plugin
   1.112 +	 * @param file Pointer to file string by reference
   1.113 +	 * @param list Pointer to factories by reference
   1.114 +	 * @param status By reference status of plugin
   1.115 +	 * @param source By reference source of plugin
   1.116 +	 * @return True on success, false if not found
   1.117 +	 */
   1.118 +	virtual bool Query(PluginId id, const char *&file, Pl_Status &status, PluginId &source) =0;
   1.119 +
   1.120 +	/** 
   1.121 +	 * @brief Checks another plugin's QueryRunning() status.
   1.122 +	 *
   1.123 +	 * @param id		Id of plugin
   1.124 +	 * @param error		Message buffer
   1.125 +	 * @param maxlen	Size of error buffer
   1.126 +	 * @return			Status value
   1.127 +	 */
   1.128 +	virtual bool QueryRunning(PluginId id, char *error, size_t maxlength) =0;
   1.129 +
   1.130 +	/**
   1.131 +	 * @brief Returns the handle of a plugin (OS dependent meaning)
   1.132 +	 * 
   1.133 +	 * @param id		Id of plugin
   1.134 +	 * @param handle	By reference handle of plugin, if any
   1.135 +	 * @return			True if plugin id is valid, false otherwise
   1.136 +	 */
   1.137 +	virtual bool QueryHandle(PluginId id, void *&handle) =0;
   1.138 +};
   1.139 +
   1.140 +#endif //_INCLUDE_PLUGINMANAGER_H