Added 1.3d to changelog...
1 /* ======== SourceMM ========
2 * Copyright (C) 2004-2006 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>
21 #include "convar_smm.h"
22 #include "IPluginManager.h"
25 #include "sh_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 * M 7: Changed template libraries (2005-08-11)
36 * New loading structure mechanism
37 * New SourceHook version
38 * 8: New SourceHook version (2005-12-23)
39 * New ISmmAPI additions
40 * C 9: New ISmmPluginManager additions
43 #define PLAPI_MIN_VERSION 7
49 SourceHook::String alias;
50 SourceHook::String value;
53 * @brief Implements Plugin Manager API
55 class CPluginManager : public ISmmPluginManager
59 * @brief Internal structure for holding plugin data
67 SourceHook::String m_File;
72 SourceHook::List<ConCommandBase *> m_Cvars;
73 SourceHook::List<ConCommandBase *> m_Cmds;
74 SourceHook::List<IMetamodListener *> m_Events;
81 PluginId Load(const char *file, PluginId source, bool &already, char *error, size_t maxlen);
82 bool Unload(PluginId id, bool force, char *error, size_t maxlen);
83 bool Pause(PluginId id, char *error, size_t maxlen);
84 bool Unpause(PluginId id, char *error, size_t maxlen);
86 void SetAlias(const char *alias, const char *value);
88 bool Query(PluginId id, const char *&file, Pl_Status &status, PluginId &source);
89 bool QueryRunning(PluginId id, char *error, size_t maxlength);
90 bool QueryHandle(PluginId id, void *&handle);
92 void AddPluginCvar(ISmmPlugin *api, ConCommandBase *pCvar);
93 void AddPluginCmd(ISmmPlugin *api, ConCommandBase *pCmd);
94 void RemovePluginCvar(ISmmPlugin *api, ConCommandBase *pCvar);
95 void RemovePluginCmd(ISmmPlugin *api, ConCommandBase *pCmd);
98 * @brief Finds a plugin by Id
100 * @param id Id of plugin
101 * @return CPlugin on success, NULL otherwise
103 CPlugin *FindById(PluginId id);
105 CPlugin *FindByAPI(ISmmPlugin *api);
108 * @brief Attempts to reload a failed plugin
110 * @param id Id of plugin
111 * @param error Error message buffer
112 * @param len Maximum length of buffer
113 * @return True on success, false otherwise
115 bool Retry(PluginId id, char *error, size_t len);
118 const char *LookupAlias(const char *alias);
119 SourceHook::List<SourceMM::CNameAlias *>::iterator _alias_begin();
120 SourceHook::List<SourceMM::CNameAlias *>::iterator _alias_end();
123 SourceHook::List<SourceMM::CPluginManager::CPlugin *>::iterator _begin();
124 SourceHook::List<SourceMM::CPluginManager::CPlugin *>::iterator _end();
126 //These are identical internal functions for the wrappers above.
127 CPlugin *_Load(const char *file, PluginId source, char *error, size_t maxlen);
128 bool _Unload(CPlugin *pl, bool force, char *error, size_t maxlen);
129 bool _Pause(CPlugin *pl, char *error, size_t maxlen);
130 bool _Unpause(CPlugin *pl, char *error, size_t maxlen);
131 void UnregAllConCmds(CPlugin *pl);
134 SourceHook::List<CPlugin *> m_Plugins;
135 SourceHook::List<CNameAlias *> m_Aliases;
140 typedef SourceHook::List<SourceMM::CPluginManager::CPlugin *>::iterator PluginIter;
142 /** @brief Singleton for plugin manager */
143 extern SourceMM::CPluginManager g_PluginMngr;
145 #endif //_INCLUDE_CPLUGIN_H