sourcehook/sourcehook_impl_cproto.h
author Pavol Marko <pavolmarko@gmail.com>
Sun Oct 07 22:45:22 2007 +0000 (2007-10-07)
changeset 384 264cab8ff2cc
parent 381 8eded451c936
child 412 43098e572d24
permissions -rw-r--r--
correct version now... i guess i'm just tired :)
     1 /* ======== SourceHook ========
     2 * Copyright (C) 2004-2007 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_CPROTO_H__
    12 #define __SOURCEHOOK_IMPL_CPROTO_H__
    13 
    14 namespace SourceHook
    15 {
    16 	namespace Impl
    17 	{
    18 
    19 		class CProto
    20 		{
    21 			ProtoInfo *m_Proto;
    22 
    23 			static bool Equal(const ProtoInfo *p1, const ProtoInfo *p2);
    24 			static ProtoInfo *DupProto(const ProtoInfo *src);
    25 			static void FreeProto(ProtoInfo *prot);
    26 		public:
    27 			CProto() : m_Proto(NULL)
    28 			{
    29 			}
    30 
    31 			CProto(const ProtoInfo *pProto) : m_Proto(DupProto(pProto))
    32 			{
    33 			}
    34 
    35 			CProto(const CProto &other) : m_Proto(DupProto(other.m_Proto))
    36 			{
    37 			}
    38 
    39 			~CProto()
    40 			{
    41 				FreeProto(m_Proto);
    42 				m_Proto = NULL;
    43 			}
    44 
    45 			void operator = (const ProtoInfo *pProto)
    46 			{
    47 				if (m_Proto)
    48 					FreeProto(m_Proto);
    49 				m_Proto = DupProto(pProto);
    50 			}
    51 
    52 			void operator = (const CProto &other)
    53 			{
    54 				if (m_Proto)
    55 					FreeProto(m_Proto);
    56 				m_Proto = DupProto(other.m_Proto);
    57 			}
    58 
    59 			bool operator == (const ProtoInfo *pProto) const
    60 			{
    61 				return Equal(pProto, m_Proto);
    62 			}
    63 			bool operator == (const CProto &other) const
    64 			{
    65 				return Equal(other.m_Proto, m_Proto);
    66 			}
    67 
    68 			const ProtoInfo *GetProto() const
    69 			{
    70 				return m_Proto;
    71 			}
    72 		};
    73 	}
    74 }
    75 
    76 #endif
    77