core/logic/NativeOwner.h
author Nicholas Hastings <skamonkey@gmail.com>
Wed Aug 14 14:20:57 2013 -0400 (2013-08-14)
changeset 4008 490b01aa0683
parent 3872 4c93f74cae51
child 4106 a39557bde4ac
permissions -rw-r--r--
Updated some CS:GO gamedata.
     1 #ifndef _INCLUDE_SOURCEMOD_NATIVE_OWNER_H_
     2 #define _INCLUDE_SOURCEMOD_NATIVE_OWNER_H_
     3 
     4 #include <sp_vm_types.h>
     5 #include <sh_list.h>
     6 #include "common_logic.h"
     7 
     8 struct NativeEntry;
     9 class CPlugin;
    10 
    11 using namespace SourceMod;
    12 
    13 struct WeakNative
    14 {
    15 	WeakNative(IPlugin *plugin, uint32_t index) : 
    16 		pl(plugin), idx(index), entry(NULL)
    17 	{
    18 		pl = plugin;
    19 		idx = index;
    20 	}
    21 	WeakNative(IPlugin *plugin, uint32_t index, NativeEntry *pEntry) : 
    22 		pl(plugin), idx(index), entry(pEntry)
    23 	{
    24 		pl = plugin;
    25 		idx = index;
    26 	}
    27 	IPlugin *pl;
    28 	uint32_t idx;
    29 	NativeEntry *entry;
    30 };
    31 
    32 using namespace SourceHook;
    33 
    34 class CNativeOwner
    35 {
    36 public:
    37 	CNativeOwner();
    38 public:
    39 	virtual void DropEverything();
    40 public:
    41 	void AddNatives(const sp_nativeinfo_t *info);
    42 public:
    43 	void SetMarkSerial(unsigned int serial);
    44 	unsigned int GetMarkSerial();
    45 	void PropagateMarkSerial(unsigned int serial);
    46 public:
    47 	void AddDependent(CPlugin *pPlugin);
    48 	void AddWeakRef(const WeakNative & ref);
    49 	void DropRefsTo(CPlugin *pPlugin);
    50 	void AddReplacedNative(NativeEntry *pEntry);
    51 private:
    52 	void DropWeakRefsTo(CPlugin *pPlugin);
    53 	void UnbindWeakRef(const WeakNative & ref);
    54 protected:
    55 	List<CPlugin *> m_Dependents;
    56 	unsigned int m_nMarkSerial;
    57 	List<WeakNative> m_WeakRefs;
    58 	List<NativeEntry *> m_Natives;
    59 	List<NativeEntry *> m_ReplacedNatives;
    60 };
    61 
    62 extern CNativeOwner g_CoreNatives;
    63 
    64 #endif //_INCLUDE_SOURCEMOD_NATIVE_OWNER_H_