Delay unloading of plugins until it is absolutely safe (
bug 5034, r=ds).
1 /* ======== SourceHook ========
2 * Copyright (C) 2004-2010 Metamod:Source Development Team
3 * No warranties of any kind
7 * Author(s): Pavol "PM OnoTo" Marko
8 * ============================
11 #ifndef __SOURCEHOOK_IMPL_CHOOKMANINFO_H__
12 #define __SOURCEHOOK_IMPL_CHOOKMANINFO_H__
15 #include "sourcehook_impl_cproto.h"
23 class CHookManager : public IHookManagerInfo
27 HookManagerPubFunc m_PubFunc;
33 void *m_HookfuncVfnptr;
35 List<CVfnPtr*> m_VfnPtrs;
41 HookManagerPubFunc m_PubFunc;
42 Descriptor(Plugin ownerPlugin, HookManagerPubFunc pubFunc)
43 : m_OwnerPlugin(ownerPlugin), m_PubFunc(pubFunc)
49 CHookManager(Plugin ownerPlugin, HookManagerPubFunc pubFunc);
51 inline bool operator==(const Descriptor &other) const;
52 inline bool operator==(const CHookManager &other) const;
54 inline operator bool() const;
55 inline Plugin GetOwnerPlugin() const;
56 inline int GetVtblOffs() const;
57 inline int GetVtblIdx() const;
58 inline const CProto &GetProto() const;
59 inline int GetVersion() const;
60 inline void *GetHookFunc() const;
61 inline HookManagerPubFunc GetPubFunc() const;
66 void IncrRef(CVfnPtr *pVfnPtr);
67 void DecrRef(CVfnPtr *pVfnPtr);
69 List<CVfnPtr*> &GetVfnPtrList()
74 // *** IHookManagerInfo interface ***
75 void SetInfo(int hookman_version, int vtbloffs, int vtblidx,
76 ProtoInfo *proto, void *hookfunc_vfnptr);
79 class CHookManList : public List<CHookManager>
82 CHookManager *GetHookMan(Plugin plug, HookManagerPubFunc pubFunc);
83 CHookManager *GetHookMan(CHookManager &hm);
86 // *** Implementation **/
88 inline CHookManager::operator bool() const
90 return m_Version != -1;
93 inline bool CHookManager::operator==(const Descriptor &other) const
95 return m_OwnerPlugin == other.m_OwnerPlugin
96 && m_PubFunc == other.m_PubFunc;
99 inline bool CHookManager::operator==(const CHookManager &other) const
101 return m_OwnerPlugin == other.m_OwnerPlugin
102 && m_PubFunc == other.m_PubFunc;
105 inline Plugin CHookManager::GetOwnerPlugin() const
107 return m_OwnerPlugin;
110 inline int CHookManager::GetVtblOffs() const
115 inline int CHookManager::GetVtblIdx() const
120 inline const CProto &CHookManager::GetProto() const
125 inline int CHookManager::GetVersion() const
130 inline void *CHookManager::GetHookFunc() const
132 return *reinterpret_cast<void**>(m_HookfuncVfnptr);
135 inline HookManagerPubFunc CHookManager::GetPubFunc() const