More Windows build fix.
3 * =============================================================================
5 * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
6 * =============================================================================
8 * This program is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License, version 3.0, as published by the
10 * Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * You should have received a copy of the GNU General Public License along with
18 * this program. If not, see <http://www.gnu.org/licenses/>.
20 * As a special exception, AlliedModders LLC gives you permission to link the
21 * code of this program (as well as its derivative works) to "Half-Life 2," the
22 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
23 * by the Valve Corporation. You must obey the GNU General Public License in
24 * all respects for all other code used. Additionally, AlliedModders LLC grants
25 * this exception to all derivative works. AlliedModders LLC defines further
26 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
27 * or <http://www.sourcemod.net/license.php>.
32 #ifndef _INCLUDE_SOURCEMOD_EXTENSION_SYSTEM_H_
33 #define _INCLUDE_SOURCEMOD_EXTENSION_SYSTEM_H_
35 #include <IExtensionSys.h>
36 #include <ILibrarySys.h>
38 #include <sh_string.h>
39 #include <sm_trie_tpl.h>
40 #include "common_logic.h"
41 #include <IPluginSys.h>
42 #include <IRootConsoleMenu.h>
43 #include "NativeOwner.h"
48 using namespace SourceMod;
49 using namespace SourceHook;
56 const sp_nativeinfo_t *info;
63 friend class CExtensionManager;
65 virtual ~CExtension();
67 IExtensionInterface *GetAPI();
68 const char *GetFilename();
69 const char *GetPath() const;
70 IdentityToken_t *GetIdentity();
71 ITERATOR *FindFirstDependency(IExtension **pOwner, SMInterface **pInterface);
72 bool FindNextDependency(ITERATOR *iter, IExtension **pOwner, SMInterface **pInterface);
73 void FreeDependencyIterator(ITERATOR *iter);
74 bool IsRunning(char *error, size_t maxlength);
76 void SetError(const char *error);
77 void AddDependency(const IfaceInfo *pInfo);
78 void AddChildDependent(CExtension *pOther, SMInterface *iface);
79 void AddInterface(SMInterface *pInterface);
80 void AddPlugin(CPlugin *pPlugin);
82 void AddLibrary(const char *library);
84 virtual bool Load(char *error, size_t maxlength);
85 virtual bool IsLoaded() =0;
86 virtual void Unload() =0;
87 virtual bool Reload(char *error, size_t maxlength) =0;
88 virtual bool IsSameFile(const char* file) =0;
90 void Initialize(const char *filename, const char *path);
91 bool PerformAPICheck(char *error, size_t maxlength);
92 void CreateIdentity();
93 void DestroyIdentity();
95 IdentityToken_t *m_pIdentToken;
96 IExtensionInterface *m_pAPI;
101 List<IfaceInfo> m_Deps; /** Dependencies */
102 List<IfaceInfo> m_ChildDeps; /** Children who might depend on us */
103 List<SMInterface *> m_Interfaces;
104 List<String> m_Libraries;
105 unsigned int unload_code;
109 class CLocalExtension : public CExtension
112 CLocalExtension(const char *filename);
114 bool Load(char *error, size_t maxlength);
117 bool Reload(char *error, size_t maxlength);
119 bool IsSameFile(const char *file);
125 class CRemoteExtension : public CExtension
128 CRemoteExtension(IExtensionInterface *pAPI, const char *filename, const char *path);
130 bool Load(char *error, size_t maxlength);
133 bool Reload(char *error, size_t maxlength);
135 bool IsSameFile(const char *file);
138 class CExtensionManager :
139 public IExtensionSys,
140 public SMGlobalClass,
141 public IPluginsListener,
142 public IRootConsoleCommand
146 ~CExtensionManager();
147 public: //SMGlobalClass
148 void OnSourceModAllInitialized();
149 void OnSourceModShutdown();
150 public: //IExtensionManager
151 IExtension *LoadExtension(const char *path,
154 bool UnloadExtension(IExtension *pExt);
155 IExtension *FindExtensionByFile(const char *file);
156 IExtension *FindExtensionByName(const char *ext);
157 IExtension *LoadExternal(IExtensionInterface *pInterface,
158 const char *filepath,
159 const char *filename,
162 public: //IPluginsListener
163 void OnPluginDestroyed(IPlugin *plugin);
164 public: //IRootConsoleCommand
165 void OnRootConsoleCommand(const char *cmdname, const CCommand &command);
167 IExtension *LoadAutoExtension(const char *path);
168 void BindDependency(IExtension *pOwner, IfaceInfo *pInfo);
169 void AddInterface(IExtension *pOwner, SMInterface *pInterface);
170 void BindChildPlugin(IExtension *pParent, SMPlugin *pPlugin);
171 void MarkAllLoaded();
172 void AddDependency(IExtension *pSource, const char *file, bool required, bool autoload);
174 void AddLibrary(IExtension *pSource, const char *library);
175 bool LibraryExists(const char *library);
176 void CallOnCoreMapStart(edict_t *pEdictList, int edictCount, int clientMax);
177 void AddRawDependency(IExtension *ext, IdentityToken_t *other, void *iface);
178 const CVector<IExtension *> *ListExtensions();
179 void FreeExtensionList(const CVector<IExtension *> *list);
181 CExtension *GetExtensionFromIdent(IdentityToken_t *ptr);
183 CNativeOwner *GetNativeOwner(IExtension *pExt)
185 CExtension *p = (CExtension *)pExt;
189 CExtension *FindByOrder(unsigned int num);
191 List<CExtension *> m_Libs;
194 extern CExtensionManager g_Extensions;
196 #endif //_INCLUDE_SOURCEMOD_EXTENSION_SYSTEM_H_