sourcemm/IPluginManager.h
author David Anderson <dvander@alliedmods.net>
Thu Oct 06 00:59:01 2005 +0000 (2005-10-06)
changeset 122 7c36121e2dfe
parent 29 10e6dc40505e
child 138 dfa3b31cc042
permissions -rw-r--r--
Initial import of new GameDLL loading code
     1 /* ======== SourceMM ========
     2 * Copyright (C) 2004-2005 Metamod:Source Development Team
     3 * No warranties of any kind
     4 *
     5 * License: zlib/libpng
     6 *
     7 * Author(s): David "BAILOPAN" Anderson
     8 * ============================
     9 */
    10 
    11 #ifndef _INCLUDE_PLUGINMANAGER_H
    12 #define _INCLUDE_PLUGINMANAGER_H
    13 
    14 /**
    15  * @brief Plugin Manager interface
    16  * @file IPluginManager.h
    17  */
    18 
    19 #include "ISmmPlugin.h"
    20 
    21 /**
    22  * @brief Load sources
    23  */
    24 enum
    25 {
    26 	Pl_BadLoad=0,
    27 	Pl_Console=-1,
    28 	Pl_File=-2,
    29 	Pl_MinId=1,
    30 };
    31 
    32 /**
    33  * @brief Status of a plugin at runtime
    34  */
    35 enum Pl_Status
    36 {
    37 	Pl_NotFound=-4,
    38 	Pl_Error=-3,
    39 	Pl_Refused=-2,
    40 	Pl_Paused=-1,
    41 	Pl_Running=0,
    42 };
    43 
    44 typedef int PluginId;
    45 struct factories;
    46 
    47 class ISmmPluginManager
    48 {
    49 public:
    50 	/**
    51 	 * @brief Loads a plugin and returns its id.  If this is called before DLLInit(),
    52 	 *  then the plugin is considered to be "hot" - it might refuse its own load later!
    53 	 *  Also, a hot plugin might not have an error message.
    54 	 *
    55 	 * @param file String containing file name
    56 	 * @param source Specifies who loaded the plugin
    57 	 * @param status Status of the plugin 
    58 	 * @param ismm Pointer to Smm API
    59 	 * @param error String buffer for error messages
    60 	 * @param maxlen Maximum length of buffer
    61 	 * @return Id of plugin
    62 	 */
    63 	virtual PluginId Load(const char *file, PluginId source, bool &already, char *error, size_t maxlen) =0;
    64 
    65 	/**
    66 	 * @brief Unloads a plugin
    67 	 *
    68 	 * @param id Id of plugin
    69 	 * @param error String buffer for error messages
    70 	 * @param maxlen Maximum length of buffer
    71 	 * @return True on success, false otherwise
    72 	 */
    73 	virtual bool Unload(PluginId id, bool force, char *error, size_t maxlen) =0;
    74 
    75 	/**
    76 	 * @brief Pauses a plugin
    77 	 *
    78 	 * @param id Id of plugin
    79 	 * @param error String buffer for error messages
    80 	 * @param maxlen Maximum length of buffer
    81 	 * @return True on success, false otherwise
    82 	 */
    83 	virtual bool Pause(PluginId id, char *error, size_t maxlen) =0;
    84 
    85 	/**
    86 	 * @brief Unpauses a plugin
    87 	 *
    88 	 * @param id Id of plugin
    89 	 * @param force If true, forces the plugin to unload
    90 	 * @param error String buffer for error messages
    91 	 * @param maxlen Maximum length of buffer
    92 	 * @return True on success, false otherwise
    93 	 */
    94 	virtual bool Unpause(PluginId id, char *error, size_t maxlen) =0;
    95 
    96 	/**
    97 	 * @brief Unloads all plugins forcefully
    98 	 * 
    99 	 * @return True on success, false otherwise
   100 	 */
   101 	virtual bool UnloadAll() =0;
   102 
   103 	/**
   104 	 * @brief Returns information about a plugin
   105 	 *
   106 	 * @param id Id of plugin
   107 	 * @param file Pointer to file string by reference
   108 	 * @param list Pointer to factories by reference
   109 	 * @param status By reference status of plugin
   110 	 * @param source By reference source of plugin
   111 	 * @return True on success, false if not found
   112 	 */
   113 	virtual bool Query(PluginId id, const char *&file, factories *&list, Pl_Status &status, PluginId &source) =0;
   114 
   115 	/** 
   116 	 * @brief Checks another plugin's QueryRunning() status.
   117 	 *
   118 	 * @param id		Id of plugin
   119 	 * @param error		Message buffer
   120 	 * @param maxlen	Size of error buffer
   121 	 * @return			Status value
   122 	 */
   123 	virtual bool QueryRunning(PluginId id, char *error, size_t maxlength) =0;
   124 };
   125 
   126 #endif //_INCLUDE_PLUGINMANAGER_H