core/sourcehook/sourcehook_impl_chook.h
changeset 539 db914129ae01
parent 523 6f1630519b81
child 733 2365240861a2
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/core/sourcehook/sourcehook_impl_chook.h	Fri Nov 14 04:04:02 2008 -0600
     1.3 @@ -0,0 +1,106 @@
     1.4 +/* ======== SourceHook ========
     1.5 +* Copyright (C) 2004-2008 Metamod:Source Development Team
     1.6 +* No warranties of any kind
     1.7 +*
     1.8 +* License: zlib/libpng
     1.9 +*
    1.10 +* Author(s): Pavol "PM OnoTo" Marko
    1.11 +* ============================
    1.12 +*/
    1.13 +
    1.14 +#ifndef __SOURCEHOOK_IMPL_CHOOK_H__
    1.15 +#define __SOURCEHOOK_IMPL_CHOOK_H__
    1.16 +
    1.17 +namespace SourceHook
    1.18 +{
    1.19 +	namespace Impl
    1.20 +	{
    1.21 +		class CHook
    1.22 +		{
    1.23 +			// *** Data ***
    1.24 +			Plugin m_OwnerPlugin;
    1.25 +			int m_ThisPointerOffset;
    1.26 +			ISHDelegate *m_pHandler;
    1.27 +			int m_HookID;
    1.28 +			bool m_Paused;
    1.29 +		public:
    1.30 +
    1.31 +			// *** Descriptor ***
    1.32 +			struct Descriptor
    1.33 +			{
    1.34 +				Plugin m_OwnerPlugin;
    1.35 +				int m_ThisPointerOffset;
    1.36 +				ISHDelegate *m_pHandler;
    1.37 +
    1.38 +				Descriptor(Plugin ownerPlugin, int thisPtrOffset, ISHDelegate *pHandler)
    1.39 +					: m_OwnerPlugin(ownerPlugin), m_ThisPointerOffset(thisPtrOffset),
    1.40 +					m_pHandler(pHandler)
    1.41 +				{
    1.42 +				}
    1.43 +			};
    1.44 +
    1.45 +			// *** Interface ***
    1.46 +			inline CHook(Plugin ownerPlugin, int thisPtrOffset, ISHDelegate *pHandler, int hookid, bool paused=false);
    1.47 +			inline bool operator==(const Descriptor &other) const;
    1.48 +			inline bool operator==(int hookid) const;
    1.49 +			inline Plugin GetOwnerPlugin() const;
    1.50 +			inline int GetThisPointerOffset() const;
    1.51 +			inline ISHDelegate *GetHandler() const;
    1.52 +			inline void SetPaused(bool value);
    1.53 +			inline bool IsPaused() const;
    1.54 +			inline int GetID() const;
    1.55 +		};
    1.56 +
    1.57 +		// *** Implementation ***
    1.58 +		inline CHook::CHook(Plugin ownerPlugin, int thisPtrOffset, ISHDelegate *pHandler, int hookid, bool paused)
    1.59 +			: m_OwnerPlugin(ownerPlugin), m_ThisPointerOffset(thisPtrOffset),
    1.60 +			m_pHandler(pHandler), m_HookID(hookid), m_Paused(paused)
    1.61 +		{
    1.62 +		}
    1.63 +
    1.64 +		inline bool CHook::operator==(const Descriptor &other) const
    1.65 +		{
    1.66 +			return m_OwnerPlugin == other.m_OwnerPlugin
    1.67 +				&& m_ThisPointerOffset == other.m_ThisPointerOffset
    1.68 +				&& m_pHandler == other.m_pHandler;
    1.69 +		}
    1.70 +
    1.71 +		inline bool CHook::operator==(int hookid) const
    1.72 +		{
    1.73 +			return m_HookID == hookid;
    1.74 +		}
    1.75 +
    1.76 +		inline Plugin CHook::GetOwnerPlugin() const
    1.77 +		{
    1.78 +			return m_OwnerPlugin;
    1.79 +		}
    1.80 +
    1.81 +		inline int CHook::GetThisPointerOffset() const
    1.82 +		{
    1.83 +			return m_ThisPointerOffset;
    1.84 +		}
    1.85 +
    1.86 +		inline ISHDelegate *CHook::GetHandler() const
    1.87 +		{
    1.88 +			return m_pHandler;
    1.89 +		}
    1.90 +
    1.91 +		inline void CHook::SetPaused(bool value)
    1.92 +		{
    1.93 +			m_Paused = value;
    1.94 +		}
    1.95 +
    1.96 +		inline bool CHook::IsPaused() const
    1.97 +		{
    1.98 +			return m_Paused;
    1.99 +		}
   1.100 +
   1.101 +		inline int CHook::GetID() const
   1.102 +		{
   1.103 +			return m_HookID;
   1.104 +		}
   1.105 +	}
   1.106 +}
   1.107 +
   1.108 +#endif
   1.109 +