sourcehook/sourcehook_impl_ciface.h
author Scott Ehlert <ds@alliedmods.net>
Tue Sep 16 04:41:32 2008 -0500 (2008-09-16)
changeset 533 591b88a78e35
parent 523 6f1630519b81
permissions -rw-r--r--
Fixed tags for mmsource-central

mmsource-1.00-RC1 - Not tagged originally, but eventually done by Scott Ehlert <[email protected]> on Wed Jul 19 08:41:34 2006 UTC
mmsource-1.00-RC2 - Not tagged originally, but eventually done by Scott Ehlert <[email protected]> on Wed Jul 19 08:35:20 2006 UTC
mmsource-1.00 - Not tagged originally, but eventually done by Scott Ehlert <[email protected]> on Wed Jul 19 08:30:40 2006 UTC
mmsource-1.1 - Not tagged originally, but eventually done by Scott Ehlert <[email protected]> on Wed Jul 19 08:25:09 2006 UTC
mmsource-1.1.1 - Not tagged originally, but eventually done by Scott Ehlert <[email protected]> on Wed Jul 19 08:22:23 2006 UTC
mmsource-1.1.2 - Not tagged originally, but eventually done by Scott Ehlert <[email protected]> on Wed Jul 19 08:14:00 2006 UTC
mmsource-1.2 - Not tagged originally, but eventually done by Scott Ehlert <[email protected]> on Wed Jul 19 08:10:47 2006 UTC
mmsource-1.2.1 - Not tagged originally, but eventually done by Scott Ehlert <[email protected]> on Wed Jul 19 08:01:35 2006 UTC
mmsource-1.2.2 - Not tagged originally, but eventually done by Scott Ehlert <[email protected]> on Wed Jul 19 07:57:26 2006 UTC
mmsource-1.2.3 - Not tagged originally, but eventually done by David Anderson <[email protected]> on Wed Jul 12 17:33:59 2006 UTC
mmsource-1.3 - Originally tagged by Scott Ehlert <[email protected]> on Thu Aug 17 03:19:55 2006 UTC
mmsource-1.3a - Originally tagged by Scott Ehlert <[email protected]> on Wed Sep 6 07:17:37 2006 UTC
mmsource-1.3d - Originally tagged by Scott Ehlert <[email protected]> on Fri Feb 2 05:30:56 2007 UTC
mmsource-1.4 - Originally tagged by Scott Ehlert <[email protected]> on Sat Apr 7 05:00:28 2007 UTC
mmsource-1.6.0 - Originally tagged by David Anderson <[email protected]> on Mon Feb 18 23:31:29 2008 UTC
mmsource-1.6.1 - Originally tagged by David Anderson <[email protected]> on Mon Feb 25 17:15:44 2008 UTC
mmsource-1.6.2 - Originally tagged by David Anderson <[email protected]> on Sat Jul 26 05:04:35 2008 UTC
     1 /* ======== SourceHook ========
     2 * Copyright (C) 2004-2008 Metamod:Source Development Team
     3 * No warranties of any kind
     4 *
     5 * License: zlib/libpng
     6 *
     7 * Author(s): Pavol "PM OnoTo" Marko
     8 * ============================
     9 */
    10 
    11 #ifndef __SOURCEHOOK_IMPL_CIFACE_H__
    12 #define __SOURCEHOOK_IMPL_CIFACE_H__
    13 
    14 #include "sh_list.h"
    15 
    16 namespace SourceHook
    17 {
    18 	namespace Impl
    19 	{
    20 		class CIface
    21 		{
    22 			// *** Data ***
    23 			void *m_Ptr;
    24 
    25 			List<CHook> m_PreHooks;
    26 			List<CHook> m_PostHooks;
    27 		public:
    28 
    29 			// *** Descriptor ***
    30 			typedef void* Descriptor;
    31 
    32 			// *** Interface ***
    33 			inline CIface(void *ptr);
    34 			inline ~CIface();
    35 			inline bool operator==(const Descriptor &other);
    36 			inline void *GetPtr() const;
    37 			inline List<CHook> &GetPreHookList();
    38 			inline List<CHook> &GetPostHookList();
    39 			inline const List<CHook> &GetPreHookList() const;
    40 			inline const List<CHook> &GetPostHookList() const;
    41 		};
    42 
    43 		// *** Implementation ***
    44 		inline CIface::CIface(void *ptr)
    45 			: m_Ptr(ptr)
    46 		{
    47 		}
    48 
    49 		inline CIface::~CIface()
    50 		{
    51 			// Before getting deleted, delete all remaining hook handlers
    52 			for (List<CHook>::iterator iter = m_PreHooks.begin(); iter != m_PreHooks.end(); ++iter)
    53 			{
    54 				iter->GetHandler()->DeleteThis();
    55 			}
    56 
    57 			for (List<CHook>::iterator iter = m_PostHooks.begin(); iter != m_PostHooks.end(); ++iter)
    58 			{
    59 				iter->GetHandler()->DeleteThis();
    60 			}
    61 		}
    62 
    63 		inline bool CIface::operator==(const Descriptor &other)
    64 		{
    65 			return m_Ptr == other;
    66 		}
    67 
    68 		inline void *CIface::GetPtr() const
    69 		{
    70 			return m_Ptr;
    71 		}
    72 
    73 		inline List<CHook> &CIface::GetPreHookList()
    74 		{
    75 			return m_PreHooks;
    76 		}
    77 
    78 		inline List<CHook> &CIface::GetPostHookList()
    79 		{
    80 			return m_PostHooks;
    81 		}
    82 
    83 		inline const List<CHook> &CIface::GetPreHookList() const
    84 		{
    85 			return m_PreHooks;
    86 		}
    87 
    88 		inline const List<CHook> &CIface::GetPostHookList() const
    89 		{
    90 			return m_PostHooks;
    91 		}
    92 	}
    93 }
    94 
    95 #endif
    96