1 #ifndef _INCLUDE_SOURCEMOD_EXTENSION_SYSTEM_H_
2 #define _INCLUDE_SOURCEMOD_EXTENSION_SYSTEM_H_
4 #include <IExtensionSys.h>
5 #include <ILibrarySys.h>
8 #include "sm_globals.h"
12 using namespace SourceMod;
13 using namespace SourceHook;
15 class CExtension : public IExtension
17 friend class CExtensionManager;
19 CExtension(const char *filename, char *error, size_t maxlen);
22 IExtensionInterface *GetAPI();
23 const char *GetFilename();
24 IdentityToken_t *GetIdentity();
26 ITERATOR *FindFirstDependency(IExtension **pOwner, SMInterface **pInterface);
27 bool FindNextDependency(ITERATOR *iter, IExtension **pOwner, SMInterface **pInterface);
28 void FreeDependencyIterator(ITERATOR *iter);
30 void SetError(const char *error);
31 void AddDependency(IfaceInfo *pInfo);
32 void AddInterface(SMInterface *pInterface);
34 IdentityToken_t *m_pIdentToken;
35 IExtensionInterface *m_pAPI;
39 List<IfaceInfo> m_Deps;
40 List<SMInterface *> m_Interfaces;
44 class CExtensionManager :
45 public IExtensionManager,
48 public: //SMGlobalClass
49 void OnSourceModAllInitialized();
50 void OnSourceModShutdown();
51 public: //IExtensionManager
52 IExtension *LoadExtension(const char *path,
53 ExtensionLifetime lifetime,
56 bool UnloadExtension(IExtension *pExt);
57 IExtension *FindExtensionByFile(const char *file);
58 IExtension *FindExtensionByName(const char *ext);
60 IExtension *LoadAutoExtension(const char *path);
61 void BindDependency(IExtension *pOwner, IfaceInfo *pInfo);
62 void AddInterface(IExtension *pOwner, SMInterface *pInterface);
64 List<CExtension *> m_Libs;
67 extern CExtensionManager g_Extensions;
69 #endif //_INCLUDE_SOURCEMOD_EXTENSION_SYSTEM_H_