sourcemm/IPluginManager.h
author David Anderson <dvander@alliedmods.net>
Wed May 04 13:59:57 2005 +0000 (2005-05-04)
changeset 57 90056ffa9784
parent 29 10e6dc40505e
child 122 7c36121e2dfe
permissions -rw-r--r--
bugfix
     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 Status of a plugin at runtime
    23  */
    24 enum Pl_Status
    25 {
    26 	Pl_NotFound=-4,
    27 	Pl_Error=-3,
    28 	Pl_Refused=-2,
    29 	Pl_Paused=-1,
    30 	Pl_Running=0,
    31 };
    32 
    33 /**
    34  * @brief Load sources
    35  */
    36 enum
    37 {
    38 	Pl_BadLoad=0,
    39 	Pl_Console=-1,
    40 	Pl_File=-2,
    41 	Pl_MinId=1,
    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
    52 	 *
    53 	 * @param file String containing file name
    54 	 * @param source Specifies who loaded the plugin
    55 	 * @param status Status of the plugin 
    56 	 * @param ismm Pointer to Smm API
    57 	 * @param error String buffer for error messages
    58 	 * @param maxlen Maximum length of buffer
    59 	 * @return Id of plugin
    60 	 */
    61 	virtual PluginId Load(const char *file, PluginId source, bool &already, char *error, size_t maxlen) =0;
    62 
    63 	/**
    64 	 * @brief Unloads a plugin
    65 	 *
    66 	 * @param id Id of plugin
    67 	 * @param error String buffer for error messages
    68 	 * @param maxlen Maximum length of buffer
    69 	 * @return True on success, false otherwise
    70 	 */
    71 	virtual bool Unload(PluginId id, bool force, char *error, size_t maxlen) =0;
    72 
    73 	/**
    74 	 * @brief Pauses a plugin
    75 	 *
    76 	 * @param id Id of plugin
    77 	 * @param error String buffer for error messages
    78 	 * @param maxlen Maximum length of buffer
    79 	 * @return True on success, false otherwise
    80 	 */
    81 	virtual bool Pause(PluginId id, char *error, size_t maxlen) =0;
    82 
    83 	/**
    84 	 * @brief Unpauses a plugin
    85 	 *
    86 	 * @param id Id of plugin
    87 	 * @param force If true, forces the plugin to unload
    88 	 * @param error String buffer for error messages
    89 	 * @param maxlen Maximum length of buffer
    90 	 * @return True on success, false otherwise
    91 	 */
    92 	virtual bool Unpause(PluginId id, char *error, size_t maxlen) =0;
    93 
    94 	/**
    95 	 * @brief Unloads all plugins forcefully
    96 	 * 
    97 	 * @return True on success, false otherwise
    98 	 */
    99 	virtual bool UnloadAll() =0;
   100 
   101 	/**
   102 	 * @brief Returns information about a plugin
   103 	 *
   104 	 * @param id Id of plugin
   105 	 * @param file Pointer to file string by reference
   106 	 * @param list Pointer to factories by reference
   107 	 * @param status By reference status of plugin
   108 	 * @param source By reference source of plugin
   109 	 * @return True on success, false if not found
   110 	 */
   111 	virtual bool Query(PluginId id, const char *&file, factories *&list, Pl_Status &status, PluginId &source) =0;
   112 };
   113 
   114 #endif //_INCLUDE_PLUGINMANAGER_H