sourcemm/IPluginManager.h
author David Anderson <dvander@alliedmods.net>
Sat Sep 29 15:01:32 2007 +0000 (2007-09-29)
branchsourcemm-1.6.0
changeset 365 afdf36dee1a6
parent 347 e82968c21606
child 367 fc76472b980f
permissions -rw-r--r--
- fixed shutdown crash
- fixed makefile for linux
     1 /* ======== SourceMM ========
     2 * Copyright (C) 2004-2007 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 typedef int PluginId;
    20 
    21 #include "ISmmPlugin.h"
    22 
    23 /**
    24  * @brief Load sources
    25  */
    26 enum
    27 {
    28 	Pl_BadLoad=0,
    29 	Pl_Console=-1,
    30 	Pl_File=-2,
    31 	Pl_MinId=1,
    32 };
    33 
    34 /**
    35  * @brief Status of a plugin at runtime
    36  */
    37 enum Pl_Status
    38 {
    39 	Pl_NotFound=-4,
    40 	Pl_Error=-3,
    41 	Pl_Refused=-2,
    42 	Pl_Paused=-1,
    43 	Pl_Running=0,
    44 };
    45 
    46 typedef int PluginId;
    47 struct factories;
    48 
    49 class ISmmPluginManager
    50 {
    51 public:
    52 	/**
    53 	 * @brief Loads a plugin and returns its id.  If this is called before DLLInit(),
    54 	 *  then the plugin is considered to be "hot" - it might refuse its own load later!
    55 	 *  Also, a hot plugin might not have an error message.
    56 	 *
    57 	 * @param file String containing file name
    58 	 * @param source Specifies who loaded the plugin
    59 	 * @param status Status of the plugin 
    60 	 * @param ismm Pointer to Smm API
    61 	 * @param error String buffer for error messages
    62 	 * @param maxlen Maximum length of buffer
    63 	 * @return Id of plugin
    64 	 */
    65 	virtual PluginId Load(const char *file, PluginId source, bool &already, char *error, size_t maxlen) =0;
    66 
    67 	/**
    68 	 * @brief Unloads a plugin
    69 	 *
    70 	 * @param id Id of plugin
    71 	 * @param error String buffer for error messages
    72 	 * @param maxlen Maximum length of buffer
    73 	 * @return True on success, false otherwise
    74 	 */
    75 	virtual bool Unload(PluginId id, bool force, char *error, size_t maxlen) =0;
    76 
    77 	/**
    78 	 * @brief Pauses a plugin
    79 	 *
    80 	 * @param id Id of plugin
    81 	 * @param error String buffer for error messages
    82 	 * @param maxlen Maximum length of buffer
    83 	 * @return True on success, false otherwise
    84 	 */
    85 	virtual bool Pause(PluginId id, char *error, size_t maxlen) =0;
    86 
    87 	/**
    88 	 * @brief Unpauses a plugin
    89 	 *
    90 	 * @param id Id of plugin
    91 	 * @param force If true, forces the plugin to unload
    92 	 * @param error String buffer for error messages
    93 	 * @param maxlen Maximum length of buffer
    94 	 * @return True on success, false otherwise
    95 	 */
    96 	virtual bool Unpause(PluginId id, char *error, size_t maxlen) =0;
    97 
    98 	/**
    99 	 * @brief Unloads all plugins forcefully
   100 	 * 
   101 	 * @return True on success, false otherwise
   102 	 */
   103 	virtual bool UnloadAll() =0;
   104 
   105 	/**
   106 	 * @brief Returns information about a plugin
   107 	 *
   108 	 * @param id Id of plugin
   109 	 * @param file Pointer to file string by reference
   110 	 * @param list Pointer to factories by reference
   111 	 * @param status By reference status of plugin
   112 	 * @param source By reference source of plugin
   113 	 * @return True on success, false if not found
   114 	 */
   115 	virtual bool Query(PluginId id, const char *&file, Pl_Status &status, PluginId &source) =0;
   116 
   117 	/** 
   118 	 * @brief Checks another plugin's QueryRunning() status.
   119 	 *
   120 	 * @param id		Id of plugin
   121 	 * @param error		Message buffer
   122 	 * @param maxlen	Size of error buffer
   123 	 * @return			Status value
   124 	 */
   125 	virtual bool QueryRunning(PluginId id, char *error, size_t maxlength) =0;
   126 
   127 	/**
   128 	 * @brief Returns the handle of a plugin (OS dependent meaning)
   129 	 * 
   130 	 * @param id		Id of plugin
   131 	 * @param handle	By reference handle of plugin, if any
   132 	 * @return			True if plugin id is valid, false otherwise
   133 	 */
   134 	virtual bool QueryHandle(PluginId id, void *&handle) =0;
   135 };
   136 
   137 #endif //_INCLUDE_PLUGINMANAGER_H