1 /* ======== SourceMM ========
2 * Copyright (C) 2004-2005 Metamod:Source Development Team
3 * No warranties of any kind
7 * Author(s): David "BAILOPAN" Anderson
8 * ============================
11 #ifndef _INCLUDE_CPLUGIN_H
12 #define _INCLUDE_CPLUGIN_H
15 * @brief Implementation of Plugin API and Management routines
19 #include <interface.h>
22 #include "IPluginManager.h"
25 #include "smm_string.h"
28 * History of plugin versions: (M=min, C=current)
29 * 1: Initial interface
30 * 2: Added GetLogTag()
31 * 3: Moved GetApiVersion() to top (2005-04-16)
32 * 4: Added AllPluginsLoaded() callback (2005-04-18)
33 * 5: Bumped version for SourceHook V4 (2005-05-01)
34 * 6: Added functions for console printing (2005-05-26)
35 * MC 7: Changed template libraries (2005-08-11)
38 #define PLAPI_MIN_VERSION 6
43 * @brief Implements Plugin Manager API
45 class CPluginManager : public ISmmPluginManager
49 * @brief Internal structure for holding plugin data
63 List<ConCommandBase *> m_Cvars;
64 List<ConCommandBase *> m_Cmds;
71 PluginId Load(const char *file, PluginId source, bool &already, char *error, size_t maxlen);
72 bool Unload(PluginId id, bool force, char *error, size_t maxlen);
73 bool Pause(PluginId id, char *error, size_t maxlen);
74 bool Unpause(PluginId id, char *error, size_t maxlen);
77 bool Query(PluginId id, const char *&file, factories *&list, Pl_Status &status, PluginId &source);
79 void AddPluginCvar(ISmmPlugin *api, ConCommandBase *pCvar);
80 void AddPluginCmd(ISmmPlugin *api, ConCommandBase *pCmd);
81 void RemovePluginCvar(ISmmPlugin *api, ConCommandBase *pCvar);
82 void RemovePluginCmd(ISmmPlugin *api, ConCommandBase *pCmd);
85 * @brief Finds a plugin by Id
87 * @param id Id of plugin
88 * @return CPlugin on success, NULL otherwise
90 CPlugin *FindById(PluginId id);
92 CPlugin *FindByAPI(ISmmPlugin *api);
95 * @brief Attempts to reload a failed plugin
97 * @param id Id of plugin
98 * @param error Error message buffer
99 * @param len Maximum length of buffer
100 * @return True on success, false otherwise
102 bool Retry(PluginId id, char *error, size_t len);
105 List<SourceMM::CPluginManager::CPlugin *>::iterator _begin();
106 List<SourceMM::CPluginManager::CPlugin *>::iterator _end();
108 //These are identical internal functions for the wrappers above.
109 CPlugin *_Load(const char *file, PluginId source, char *error, size_t maxlen);
110 bool _Unload(CPlugin *pl, bool force, char *error, size_t maxlen);
111 bool _Pause(CPlugin *pl, char *error, size_t maxlen);
112 bool _Unpause(CPlugin *pl, char *error, size_t maxlen);
113 void UnregAllConCmds(CPlugin *pl);
116 List<CPlugin *> m_Plugins;
121 typedef List<SourceMM::CPluginManager::CPlugin *>::iterator PluginIter;
123 /** @brief Singleton for plugin manager */
124 extern SourceMM::CPluginManager g_PluginMngr;
126 #endif //_INCLUDE_CPLUGIN_H