1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/core/IPluginManager.h Fri Nov 14 04:04:02 2008 -0600
1.3 @@ -0,0 +1,158 @@
1.4 +/*
1.5 + * vim: set ts=4 :
1.6 + * ======================================================
1.7 + * Metamod:Source
1.8 + * Copyright (C) 2004-2008 AlliedModders LLC and authors.
1.9 + * All rights reserved.
1.10 + * ======================================================
1.11 + *
1.12 + * This software is provided 'as-is', without any express or implied warranty.
1.13 + * In no event will the authors be held liable for any damages arising from
1.14 + * the use of this software.
1.15 + *
1.16 + * Permission is granted to anyone to use this software for any purpose,
1.17 + * including commercial applications, and to alter it and redistribute it
1.18 + * freely, subject to the following restrictions:
1.19 + *
1.20 + * 1. The origin of this software must not be misrepresented; you must not
1.21 + * claim that you wrote the original software. If you use this software in a
1.22 + * product, an acknowledgment in the product documentation would be
1.23 + * appreciated but is not required.
1.24 + * 2. Altered source versions must be plainly marked as such, and must not be
1.25 + * misrepresented as being the original software.
1.26 + * 3. This notice may not be removed or altered from any source distribution.
1.27 + *
1.28 + * Version: $Id$
1.29 + */
1.30 +
1.31 +#ifndef _INCLUDE_METAMOD_IPLUGINMANAGER_H
1.32 +#define _INCLUDE_METAMOD_IPLUGINMANAGER_H
1.33 +
1.34 +/**
1.35 + * @brief Plugin Manager interface
1.36 + * @file IPluginManager.h
1.37 + */
1.38 +
1.39 +#include <ISmmPluginExt.h>
1.40 +
1.41 +namespace SourceMM
1.42 +{
1.43 + /**
1.44 + * @brief Load sources
1.45 + */
1.46 + enum
1.47 + {
1.48 + Pl_BadLoad=0,
1.49 + Pl_Console=-1,
1.50 + Pl_File=-2,
1.51 + Pl_MinId=1,
1.52 + };
1.53 +
1.54 + /**
1.55 + * @brief Status of a plugin at runtime
1.56 + */
1.57 + enum Pl_Status
1.58 + {
1.59 + Pl_NotFound=-4,
1.60 + Pl_Error=-3,
1.61 + Pl_Refused=-2,
1.62 + Pl_Paused=-1,
1.63 + Pl_Running=0,
1.64 + };
1.65 +
1.66 + /**
1.67 + * @brief Programmatic management of the "loaded plugin" list.
1.68 + */
1.69 + class ISmmPluginManager
1.70 + {
1.71 + public:
1.72 + /**
1.73 + * @brief Loads a plugin and returns its id. If this is called before DLLInit(),
1.74 + * then the plugin is considered to be "hot" - it might refuse its own load later!
1.75 + * Also, a hot plugin might not have an error message.
1.76 + *
1.77 + * @param file String containing file name.
1.78 + * @param source Specifies who loaded the plugin.
1.79 + * @param already Whether or not the plugin was already loaded.
1.80 + * @param error String buffer for error messages.
1.81 + * @param maxlen Maximum length of buffer.
1.82 + * @return Id of plugin.
1.83 + */
1.84 + virtual PluginId Load(const char *file, PluginId source, bool &already, char *error, size_t maxlen) =0;
1.85 +
1.86 + /**
1.87 + * @brief Unloads a plugin.
1.88 + *
1.89 + * @param id Id of plugin
1.90 + * @param force True to forcefully unload, false to let plugin opt-out.
1.91 + * @param error String buffer for error messages
1.92 + * @param maxlen Maximum length of buffer
1.93 + * @return True on success, false otherwise
1.94 + */
1.95 + virtual bool Unload(PluginId id, bool force, char *error, size_t maxlen) =0;
1.96 +
1.97 + /**
1.98 + * @brief Pauses a plugin
1.99 + *
1.100 + * @param id Id of plugin
1.101 + * @param error String buffer for error messages
1.102 + * @param maxlen Maximum length of buffer
1.103 + * @return True on success, false otherwise
1.104 + */
1.105 + virtual bool Pause(PluginId id, char *error, size_t maxlen) =0;
1.106 +
1.107 + /**
1.108 + * @brief Unpauses a plugin
1.109 + *
1.110 + * @param id Id of plugin
1.111 + * @param error String buffer for error messages
1.112 + * @param maxlen Maximum length of buffer
1.113 + * @return True on success, false otherwise
1.114 + */
1.115 + virtual bool Unpause(PluginId id, char *error, size_t maxlen) =0;
1.116 +
1.117 + /**
1.118 + * @brief Unloads all plugins forcefully
1.119 + *
1.120 + * @return True on success, false otherwise
1.121 + */
1.122 + virtual bool UnloadAll() =0;
1.123 +
1.124 + /**
1.125 + * @brief Returns information about a plugin
1.126 + *
1.127 + * @param id Id of plugin
1.128 + * @param file Pointer to store filename pointer, or NULL to ignore.
1.129 + * @param status Pointer to store status, or NULL to ignore.
1.130 + * @param source Pointer to store source, or NULL to ignore.
1.131 + * @return True on success, false if not found
1.132 + */
1.133 + virtual bool Query(PluginId id, const char **file, Pl_Status *status, PluginId *source) =0;
1.134 +
1.135 + /**
1.136 + * @brief Checks another plugin's QueryRunning() status.
1.137 + *
1.138 + * @param id Id of plugin
1.139 + * @param error Message buffer
1.140 + * @param maxlength Size of error buffer
1.141 + * @return Status value
1.142 + */
1.143 + virtual bool QueryRunning(PluginId id, char *error, size_t maxlength) =0;
1.144 +
1.145 + /**
1.146 + * @brief Returns the handle of a plugin (OS dependent meaning)
1.147 + *
1.148 + * @param id Id of plugin
1.149 + * @param handle Pointer to store handle pointer, or NULL to ignore.
1.150 + * @return True if plugin id is valid, false otherwise
1.151 + */
1.152 + virtual bool QueryHandle(PluginId id, void **handle) =0;
1.153 + };
1.154 +}
1.155 +
1.156 +#if !defined METAMOD_NO_AUTO_NAMESPACE
1.157 +using namespace SourceMM;
1.158 +#endif
1.159 +
1.160 +#endif //_INCLUDE_PLUGINMANAGER_H
1.161 +