1.1 --- a/core/ExtensionSys.h Fri Mar 29 12:28:02 2013 -0400
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,198 +0,0 @@
1.4 -/**
1.5 - * vim: set ts=4 :
1.6 - * =============================================================================
1.7 - * SourceMod
1.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
1.9 - * =============================================================================
1.10 - *
1.11 - * This program is free software; you can redistribute it and/or modify it under
1.12 - * the terms of the GNU General Public License, version 3.0, as published by the
1.13 - * Free Software Foundation.
1.14 - *
1.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
1.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1.18 - * details.
1.19 - *
1.20 - * You should have received a copy of the GNU General Public License along with
1.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
1.22 - *
1.23 - * As a special exception, AlliedModders LLC gives you permission to link the
1.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
1.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
1.26 - * by the Valve Corporation. You must obey the GNU General Public License in
1.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
1.28 - * this exception to all derivative works. AlliedModders LLC defines further
1.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
1.30 - * or <http://www.sourcemod.net/license.php>.
1.31 - *
1.32 - * Version: $Id$
1.33 - */
1.34 -
1.35 -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_SYSTEM_H_
1.36 -#define _INCLUDE_SOURCEMOD_EXTENSION_SYSTEM_H_
1.37 -
1.38 -#include <IExtensionSys.h>
1.39 -#include <ILibrarySys.h>
1.40 -#include <sh_list.h>
1.41 -#include <sh_string.h>
1.42 -#include <sm_trie_tpl.h>
1.43 -#include "sm_globals.h"
1.44 -#include "ShareSys.h"
1.45 -#include <ISmmAPI.h>
1.46 -#include <IPluginSys.h>
1.47 -#include <IRootConsoleMenu.h>
1.48 -#include "PluginSys.h"
1.49 -#include "NativeOwner.h"
1.50 -
1.51 -class CPlayer;
1.52 -
1.53 -using namespace SourceMod;
1.54 -using namespace SourceHook;
1.55 -
1.56 -class CExtension;
1.57 -
1.58 -struct sm_extnative_t
1.59 -{
1.60 - CExtension *owner;
1.61 - const sp_nativeinfo_t *info;
1.62 -};
1.63 -
1.64 -class CExtension :
1.65 - public IExtension,
1.66 - public CNativeOwner
1.67 -{
1.68 - friend class CExtensionManager;
1.69 -public:
1.70 - virtual ~CExtension();
1.71 -public: //IExtension
1.72 - IExtensionInterface *GetAPI();
1.73 - const char *GetFilename();
1.74 - const char *GetPath() const;
1.75 - IdentityToken_t *GetIdentity();
1.76 - ITERATOR *FindFirstDependency(IExtension **pOwner, SMInterface **pInterface);
1.77 - bool FindNextDependency(ITERATOR *iter, IExtension **pOwner, SMInterface **pInterface);
1.78 - void FreeDependencyIterator(ITERATOR *iter);
1.79 - bool IsRunning(char *error, size_t maxlength);
1.80 -public:
1.81 - void SetError(const char *error);
1.82 - void AddDependency(const IfaceInfo *pInfo);
1.83 - void AddChildDependent(CExtension *pOther, SMInterface *iface);
1.84 - void AddInterface(SMInterface *pInterface);
1.85 - void AddPlugin(CPlugin *pPlugin);
1.86 - void MarkAllLoaded();
1.87 - void AddLibrary(const char *library);
1.88 -public:
1.89 - virtual bool Load(char *error, size_t maxlength);
1.90 - virtual bool IsLoaded() =0;
1.91 - virtual void Unload() =0;
1.92 - virtual bool Reload(char *error, size_t maxlength) =0;
1.93 - virtual bool IsSameFile(const char* file) =0;
1.94 -protected:
1.95 - void Initialize(const char *filename, const char *path);
1.96 - bool PerformAPICheck(char *error, size_t maxlength);
1.97 - void CreateIdentity();
1.98 - void DestroyIdentity();
1.99 -protected:
1.100 - IdentityToken_t *m_pIdentToken;
1.101 - IExtensionInterface *m_pAPI;
1.102 - String m_File;
1.103 - String m_RealFile;
1.104 - String m_Path;
1.105 - String m_Error;
1.106 - List<IfaceInfo> m_Deps; /** Dependencies */
1.107 - List<IfaceInfo> m_ChildDeps; /** Children who might depend on us */
1.108 - List<SMInterface *> m_Interfaces;
1.109 - List<String> m_Libraries;
1.110 - unsigned int unload_code;
1.111 - bool m_bFullyLoaded;
1.112 -};
1.113 -
1.114 -class CLocalExtension : public CExtension
1.115 -{
1.116 -public:
1.117 - CLocalExtension(const char *filename);
1.118 -public:
1.119 - bool Load(char *error, size_t maxlength);
1.120 - bool IsLoaded();
1.121 - void Unload();
1.122 - bool Reload(char *error, size_t maxlength);
1.123 - bool IsExternal();
1.124 - bool IsSameFile(const char *file);
1.125 -private:
1.126 - PluginId m_PlId;
1.127 - ILibrary *m_pLib;
1.128 -};
1.129 -
1.130 -class CRemoteExtension : public CExtension
1.131 -{
1.132 -public:
1.133 - CRemoteExtension(IExtensionInterface *pAPI, const char *filename, const char *path);
1.134 -public:
1.135 - bool Load(char *error, size_t maxlength);
1.136 - bool IsLoaded();
1.137 - void Unload();
1.138 - bool Reload(char *error, size_t maxlength);
1.139 - bool IsExternal();
1.140 - bool IsSameFile(const char *file);
1.141 -};
1.142 -
1.143 -class CExtensionManager :
1.144 - public IExtensionManager,
1.145 - public SMGlobalClass,
1.146 - public IPluginsListener,
1.147 - public IRootConsoleCommand
1.148 -{
1.149 -public:
1.150 - CExtensionManager();
1.151 - ~CExtensionManager();
1.152 -public: //SMGlobalClass
1.153 - void OnSourceModAllInitialized();
1.154 - void OnSourceModShutdown();
1.155 -public: //IExtensionManager
1.156 - IExtension *LoadExtension(const char *path,
1.157 - char *error,
1.158 - size_t maxlength);
1.159 - bool UnloadExtension(IExtension *pExt);
1.160 - IExtension *FindExtensionByFile(const char *file);
1.161 - IExtension *FindExtensionByName(const char *ext);
1.162 - IExtension *LoadExternal(IExtensionInterface *pInterface,
1.163 - const char *filepath,
1.164 - const char *filename,
1.165 - char *error,
1.166 - size_t maxlength);
1.167 -public: //IPluginsListener
1.168 - void OnPluginDestroyed(IPlugin *plugin);
1.169 -public: //IRootConsoleCommand
1.170 - void OnRootConsoleCommand(const char *cmdname, const CCommand &command);
1.171 -public:
1.172 - IExtension *LoadAutoExtension(const char *path, bool bErrorOnMissing=true);
1.173 - void BindDependency(IExtension *pOwner, IfaceInfo *pInfo);
1.174 - void AddInterface(IExtension *pOwner, SMInterface *pInterface);
1.175 - void BindChildPlugin(IExtension *pParent, CPlugin *pPlugin);
1.176 - void MarkAllLoaded();
1.177 - void AddDependency(IExtension *pSource, const char *file, bool required, bool autoload);
1.178 - void TryAutoload();
1.179 - void AddLibrary(IExtension *pSource, const char *library);
1.180 - bool LibraryExists(const char *library);
1.181 - void CallOnCoreMapStart(edict_t *pEdictList, int edictCount, int clientMax);
1.182 - void AddRawDependency(IExtension *ext, IdentityToken_t *other, void *iface);
1.183 -public:
1.184 - void ListExtensionsToClient(CPlayer *player, const CCommand &args);
1.185 -public:
1.186 - CExtension *GetExtensionFromIdent(IdentityToken_t *ptr);
1.187 - void Shutdown();
1.188 - CNativeOwner *GetNativeOwner(IExtension *pExt)
1.189 - {
1.190 - CExtension *p = (CExtension *)pExt;
1.191 - return p;
1.192 - }
1.193 -private:
1.194 - CExtension *FindByOrder(unsigned int num);
1.195 -private:
1.196 - List<CExtension *> m_Libs;
1.197 -};
1.198 -
1.199 -extern CExtensionManager g_Extensions;
1.200 -
1.201 -#endif //_INCLUDE_SOURCEMOD_EXTENSION_SYSTEM_H_