core/IPluginManager.h
author Fyren <fyrenmoo@gmail.com>
Wed Apr 28 23:19:40 2010 -0700 (2010-04-28)
changeset 699 dbe0a8a879e2
parent 539 db914129ae01
permissions -rw-r--r--
Updated Makefile for latest OB Valve (bug 4372, r=dvander, a=blocking).
     1 /*
     2  * vim: set ts=4 :
     3  * ======================================================
     4  * Metamod:Source
     5  * Copyright (C) 2004-2008 AlliedModders LLC and authors.
     6  * All rights reserved.
     7  * ======================================================
     8  *
     9  * This software is provided 'as-is', without any express or implied warranty.
    10  * In no event will the authors be held liable for any damages arising from 
    11  * the use of this software.
    12  * 
    13  * Permission is granted to anyone to use this software for any purpose, 
    14  * including commercial applications, and to alter it and redistribute it 
    15  * freely, subject to the following restrictions:
    16  *
    17  * 1. The origin of this software must not be misrepresented; you must not 
    18  * claim that you wrote the original software. If you use this software in a 
    19  * product, an acknowledgment in the product documentation would be 
    20  * appreciated but is not required.
    21  * 2. Altered source versions must be plainly marked as such, and must not be
    22  * misrepresented as being the original software.
    23  * 3. This notice may not be removed or altered from any source distribution.
    24  *
    25  * Version: $Id$
    26  */
    27 
    28 #ifndef _INCLUDE_METAMOD_IPLUGINMANAGER_H
    29 #define _INCLUDE_METAMOD_IPLUGINMANAGER_H
    30 
    31 /**
    32  * @brief Plugin Manager interface
    33  * @file IPluginManager.h
    34  */
    35 
    36 #include <ISmmPluginExt.h>
    37 
    38 namespace SourceMM
    39 {
    40 	/**
    41 	 * @brief Load sources
    42 	 */
    43 	enum
    44 	{
    45 		Pl_BadLoad=0,
    46 		Pl_Console=-1,
    47 		Pl_File=-2,
    48 		Pl_MinId=1,
    49 	};
    50 	
    51 	/**
    52 	 * @brief Status of a plugin at runtime
    53 	 */
    54 	enum Pl_Status
    55 	{
    56 		Pl_NotFound=-4,
    57 		Pl_Error=-3,
    58 		Pl_Refused=-2,
    59 		Pl_Paused=-1,
    60 		Pl_Running=0,
    61 	};
    62 
    63 	/**
    64 	 * @brief Programmatic management of the "loaded plugin" list.
    65 	 */
    66 	class ISmmPluginManager
    67 	{
    68 	public:
    69 		/**
    70 		 * @brief Loads a plugin and returns its id.  If this is called before DLLInit(),
    71 		 *  then the plugin is considered to be "hot" - it might refuse its own load later!
    72 		 *  Also, a hot plugin might not have an error message.
    73 		 *
    74 		 * @param file 		String containing file name.
    75 		 * @param source 	Specifies who loaded the plugin.
    76 		 * @param already 	Whether or not the plugin was already loaded.
    77 		 * @param error 	String buffer for error messages.
    78 		 * @param maxlen 	Maximum length of buffer.
    79 		 * @return 			Id of plugin.
    80 		 */
    81 		virtual PluginId Load(const char *file, PluginId source, bool &already, char *error, size_t maxlen) =0;
    82 
    83 		/**
    84 		 * @brief Unloads a plugin.
    85 		 *
    86 		 * @param id 		Id of plugin
    87 		 * @param force		True to forcefully unload, false to let plugin opt-out.
    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 Unload(PluginId id, bool force, char *error, size_t maxlen) =0;
    93 	
    94 		/**
    95 		 * @brief Pauses a plugin
    96 		 *
    97 		 * @param id 		Id of plugin
    98 		 * @param error 	String buffer for error messages
    99 		 * @param maxlen 	Maximum length of buffer
   100 		 * @return 			True on success, false otherwise
   101 		 */
   102 		virtual bool Pause(PluginId id, char *error, size_t maxlen) =0;
   103 	
   104 		/**
   105 		 * @brief Unpauses a plugin
   106 		 *
   107 		 * @param id 		Id of plugin
   108 		 * @param error 	String buffer for error messages
   109 		 * @param maxlen 	Maximum length of buffer
   110 		 * @return 			True on success, false otherwise
   111 		 */
   112 		virtual bool Unpause(PluginId id, char *error, size_t maxlen) =0;
   113 	
   114 		/**
   115 		 * @brief Unloads all plugins forcefully
   116 		 * 
   117 		 * @return 			True on success, false otherwise
   118 		 */
   119 		virtual bool UnloadAll() =0;
   120 	
   121 		/**
   122 		 * @brief Returns information about a plugin
   123 		 *
   124 		 * @param id 		Id of plugin
   125 		 * @param file 		Pointer to store filename pointer, or NULL to ignore.
   126 		 * @param status 	Pointer to store status, or NULL to ignore.
   127 		 * @param source 	Pointer to store source, or NULL to ignore.
   128 		 * @return 			True on success, false if not found
   129 		 */
   130 		virtual bool Query(PluginId id, const char **file, Pl_Status *status, PluginId *source) =0;
   131 	
   132 		/** 
   133 		 * @brief Checks another plugin's QueryRunning() status.
   134 		 *
   135 		 * @param id		Id of plugin
   136 		 * @param error		Message buffer
   137 		 * @param maxlength	Size of error buffer
   138 		 * @return			Status value
   139 		 */
   140 		virtual bool QueryRunning(PluginId id, char *error, size_t maxlength) =0;
   141 	
   142 		/**
   143 		 * @brief Returns the handle of a plugin (OS dependent meaning)
   144 		 * 
   145 		 * @param id		Id of plugin
   146 		 * @param handle	Pointer to store handle pointer, or NULL to ignore.
   147 		 * @return			True if plugin id is valid, false otherwise
   148 		 */
   149 		virtual bool QueryHandle(PluginId id, void **handle) =0;
   150 	};
   151 }
   152 
   153 #if !defined METAMOD_NO_AUTO_NAMESPACE
   154 using namespace SourceMM;
   155 #endif
   156 
   157 #endif //_INCLUDE_PLUGINMANAGER_H
   158