| author | Borja Ferrer <faluco@alliedmods.net> |
| Fri Jul 04 19:04:33 2008 +0000 (2008-07-04) | |
| changeset 2155 | 3f1fd7ab3d86 |
| parent 2088 | c84cd855ca10 |
| child 2226 | d10b38524be3 |
| permissions | -rw-r--r-- |
| dvander@2088 | 1 |
#ifndef _INCLUDE_SOURCEMOD_NATIVE_OWNER_H_ |
| dvander@2088 | 2 |
#define _INCLUDE_SOURCEMOD_NATIVE_OWNER_H_ |
| dvander@2088 | 3 |
|
| dvander@2088 | 4 |
#include <sp_vm_types.h> |
| dvander@2088 | 5 |
#include <sh_list.h> |
| dvander@2088 | 6 |
|
| dvander@2088 | 7 |
class CPlugin; |
| dvander@2088 | 8 |
struct NativeEntry; |
| dvander@2088 | 9 |
|
| dvander@2088 | 10 |
struct WeakNative |
| dvander@2088 | 11 |
{ |
| dvander@2088 | 12 |
WeakNative(CPlugin *plugin, uint32_t index) : |
| dvander@2088 | 13 |
pl(plugin), idx(index), entry(NULL) |
| dvander@2088 | 14 |
{ |
| dvander@2088 | 15 |
pl = plugin; |
| dvander@2088 | 16 |
idx = index; |
| dvander@2088 | 17 |
} |
| dvander@2088 | 18 |
WeakNative(CPlugin *plugin, uint32_t index, NativeEntry *pEntry) : |
| dvander@2088 | 19 |
pl(plugin), idx(index), entry(pEntry) |
| dvander@2088 | 20 |
{ |
| dvander@2088 | 21 |
pl = plugin; |
| dvander@2088 | 22 |
idx = index; |
| dvander@2088 | 23 |
} |
| dvander@2088 | 24 |
CPlugin *pl; |
| dvander@2088 | 25 |
uint32_t idx; |
| dvander@2088 | 26 |
NativeEntry *entry; |
| dvander@2088 | 27 |
}; |
| dvander@2088 | 28 |
|
| dvander@2088 | 29 |
using namespace SourceHook; |
| dvander@2088 | 30 |
|
| dvander@2088 | 31 |
class CNativeOwner |
| dvander@2088 | 32 |
{ |
| dvander@2088 | 33 |
public: |
| dvander@2088 | 34 |
virtual void DropEverything(); |
| dvander@2088 | 35 |
public: |
| dvander@2088 | 36 |
void AddNatives(const sp_nativeinfo_t *info); |
| dvander@2088 | 37 |
public: |
| dvander@2088 | 38 |
void SetMarkSerial(unsigned int serial); |
| dvander@2088 | 39 |
unsigned int GetMarkSerial(); |
| dvander@2088 | 40 |
void PropogateMarkSerial(unsigned int serial); |
| dvander@2088 | 41 |
public: |
| dvander@2088 | 42 |
void AddDependent(CPlugin *pPlugin); |
| dvander@2088 | 43 |
void AddWeakRef(const WeakNative & ref); |
| dvander@2088 | 44 |
void DropRefsTo(CPlugin *pPlugin); |
| dvander@2088 | 45 |
void AddReplacedNative(NativeEntry *pEntry); |
| dvander@2088 | 46 |
private: |
| dvander@2088 | 47 |
void DropWeakRefsTo(CPlugin *pPlugin); |
| dvander@2088 | 48 |
void UnbindWeakRef(const WeakNative & ref); |
| dvander@2088 | 49 |
protected: |
| dvander@2088 | 50 |
List<CPlugin *> m_Dependents; |
| dvander@2088 | 51 |
unsigned int m_nMarkSerial; |
| dvander@2088 | 52 |
List<WeakNative> m_WeakRefs; |
| dvander@2088 | 53 |
List<NativeEntry *> m_Natives; |
| dvander@2088 | 54 |
List<NativeEntry *> m_ReplacedNatives; |
| dvander@2088 | 55 |
}; |
| dvander@2088 | 56 |
|
| dvander@2088 | 57 |
#endif //_INCLUDE_SOURCEMOD_NATIVE_OWNER_H_ |