dvander@4107: /** dvander@4107: * vim: set ts=4 sw=4 tw=99 noet : dvander@4107: * ============================================================================= dvander@4107: * SourcePawn dvander@4107: * Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved. dvander@4107: * ============================================================================= dvander@4107: * dvander@4107: * This program is free software; you can redistribute it and/or modify it under dvander@4107: * the terms of the GNU General Public License, version 3.0, as published by the dvander@4107: * Free Software Foundation. dvander@4107: * dvander@4107: * This program is distributed in the hope that it will be useful, but WITHOUT dvander@4107: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS dvander@4107: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more dvander@4107: * details. dvander@4107: * dvander@4107: * You should have received a copy of the GNU General Public License along with dvander@4107: * this program. If not, see . dvander@4107: * dvander@4107: * As a special exception, AlliedModders LLC gives you permission to link the dvander@4107: * code of this program (as well as its derivative works) to "Half-Life 2," the dvander@4107: * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software dvander@4107: * by the Valve Corporation. You must obey the GNU General Public License in dvander@4107: * all respects for all other code used. Additionally, AlliedModders LLC grants dvander@4107: * this exception to all derivative works. AlliedModders LLC defines further dvander@4107: * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), dvander@4107: * or . dvander@4107: * dvander@4107: * Version: $Id$ dvander@4107: */ dvander@2088: #ifndef _INCLUDE_SOURCEMOD_NATIVE_OWNER_H_ dvander@2088: #define _INCLUDE_SOURCEMOD_NATIVE_OWNER_H_ dvander@2088: dvander@2088: #include dvander@2088: #include dvander@4109: #include dvander@4107: #include dvander@3872: #include "common_logic.h" dvander@4109: #include "Native.h" dvander@2088: dvander@4109: struct Native; dvander@2088: class CPlugin; dvander@3872: dvander@3872: using namespace SourceMod; dvander@2088: dvander@2088: struct WeakNative dvander@2088: { dvander@3872: WeakNative(IPlugin *plugin, uint32_t index) : dvander@4109: pl(plugin), idx(index) dvander@2088: { dvander@2088: pl = plugin; dvander@2088: idx = index; dvander@2088: } dvander@3872: IPlugin *pl; dvander@2088: uint32_t idx; dvander@2088: }; dvander@2088: dvander@2088: using namespace SourceHook; dvander@2088: dvander@2088: class CNativeOwner dvander@2088: { dvander@2088: public: dvander@2226: CNativeOwner(); dvander@2226: public: dvander@2088: virtual void DropEverything(); dvander@2088: public: dvander@2088: void AddNatives(const sp_nativeinfo_t *info); dvander@2088: public: dvander@2088: void SetMarkSerial(unsigned int serial); dvander@2088: unsigned int GetMarkSerial(); dvander@3872: void PropagateMarkSerial(unsigned int serial); dvander@2088: public: dvander@2088: void AddDependent(CPlugin *pPlugin); dvander@2088: void AddWeakRef(const WeakNative & ref); dvander@2088: void DropRefsTo(CPlugin *pPlugin); dvander@2088: private: dvander@2088: void DropWeakRefsTo(CPlugin *pPlugin); dvander@2088: void UnbindWeakRef(const WeakNative & ref); dvander@2088: protected: dvander@2088: List m_Dependents; dvander@2088: unsigned int m_nMarkSerial; dvander@2088: List m_WeakRefs; dvander@4107: ke::Vector m_natives; dvander@4109: ke::Vector > m_fakes; dvander@2088: }; dvander@2088: dvander@3872: extern CNativeOwner g_CoreNatives; dvander@3872: dvander@2088: #endif //_INCLUDE_SOURCEMOD_NATIVE_OWNER_H_