plugins/include/handles.inc
author David Anderson <dvander@alliedmods.net>
Fri Jul 11 05:14:32 2008 +0000 (2008-07-11)
branchrefac-jit
changeset 2190 880e81f30b5e
parent 2168 c24a6fa957db
child 2289 44045ead61cd
permissions -rw-r--r--
GetContext() now returns 'this' as a hack (shouldn't+can't be accessed anyway)
dvander@2168
     1
/**
dvander@2168
     2
 * vim: set ts=4 :
dvander@2168
     3
 * =============================================================================
dvander@2168
     4
 * SourceMod (C)2004-2008 AlliedModders LLC.  All rights reserved.
dvander@2168
     5
 * =============================================================================
dvander@2168
     6
 *
dvander@2168
     7
 * This file is part of the SourceMod/SourcePawn SDK.
dvander@2168
     8
 *
dvander@2168
     9
 * This program is free software; you can redistribute it and/or modify it under
dvander@2168
    10
 * the terms of the GNU General Public License, version 3.0, as published by the
dvander@2168
    11
 * Free Software Foundation.
dvander@2168
    12
 * 
dvander@2168
    13
 * This program is distributed in the hope that it will be useful, but WITHOUT
dvander@2168
    14
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
dvander@2168
    15
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
dvander@2168
    16
 * details.
dvander@2168
    17
 *
dvander@2168
    18
 * You should have received a copy of the GNU General Public License along with
dvander@2168
    19
 * this program.  If not, see <http://www.gnu.org/licenses/>.
dvander@2168
    20
 *
dvander@2168
    21
 * As a special exception, AlliedModders LLC gives you permission to link the
dvander@2168
    22
 * code of this program (as well as its derivative works) to "Half-Life 2," the
dvander@2168
    23
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
dvander@2168
    24
 * by the Valve Corporation.  You must obey the GNU General Public License in
dvander@2168
    25
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
dvander@2168
    26
 * this exception to all derivative works.  AlliedModders LLC defines further
dvander@2168
    27
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
dvander@2168
    28
 * or <http://www.sourcemod.net/license.php>.
dvander@2168
    29
 *
dvander@2168
    30
 * Version: $Id$
dvander@2168
    31
 */
dvander@2168
    32
dvander@2168
    33
#if defined _handles_included
dvander@2168
    34
 #endinput
dvander@2168
    35
#endif
dvander@2168
    36
#define _handles_included
dvander@2168
    37
dvander@2168
    38
/**
dvander@2168
    39
 * Handle helper macros.
dvander@2168
    40
 */
dvander@2168
    41
enum Handle
dvander@2168
    42
{
dvander@2168
    43
	INVALID_HANDLE = 0,
dvander@2168
    44
};
dvander@2168
    45
dvander@2168
    46
dvander@2168
    47
/**
dvander@2168
    48
 * Closes a Handle.  If the handle has multiple copies open, 
dvander@2168
    49
 * it is not destroyed unless all copies are closed.
dvander@2168
    50
 * 
dvander@2168
    51
 * @note Closing a Handle has a different meaning for each Handle type.  Make
dvander@2168
    52
 *       sure you read the documentation on whatever provided the Handle.
dvander@2168
    53
 *
dvander@2168
    54
 * @param hndl		Handle to close.
dvander@2168
    55
 * @return			True if successful, false if not closeable.
dvander@2168
    56
 * @error			Invalid handles will cause a run time error.
dvander@2168
    57
 */
dvander@2168
    58
native bool:CloseHandle(Handle:hndl);
dvander@2168
    59
dvander@2168
    60
/**
dvander@2168
    61
 * Clones a Handle.  When passing handles in between plugins, caching handles
dvander@2168
    62
 * can result in accidental invalidation when one plugin releases the Handle, or is its owner
dvander@2168
    63
 * is unloaded from memory.  To prevent this, the Handle may be "cloned" with a new owner.
dvander@2168
    64
 * 
dvander@2168
    65
 * @note Usually, you will be cloning Handles for other plugins.  This means that if you clone
dvander@2168
    66
 * the Handle without specifying the new owner, it will assume the identity of your original calling
dvander@2168
    67
 * plugin, which is not very useful.  You should either specify that the receiving plugin should
dvander@2168
    68
 * clone the handle on its own, or you should explicitly clone the Handle using the receiving plugin's
dvander@2168
    69
 * identity Handle.
dvander@2168
    70
 *
dvander@2168
    71
 * @param hndl		Handle to clone/duplicate.
dvander@2168
    72
 * @param plugin	Optional Handle to another plugin to mark as the new owner.
dvander@2168
    73
 *					If no owner is passed, the owner becomes the calling plugin.
dvander@2168
    74
 * @return			Handle on success, INVALID_HANDLE if not cloneable.
dvander@2168
    75
 * @error			Invalid handles will cause a run time error.
dvander@2168
    76
 */
dvander@2168
    77
native Handle:CloneHandle(Handle:hndl, Handle:plugin=INVALID_HANDLE);
dvander@2168
    78
dvander@2168
    79
/**
dvander@2168
    80
 * Do not use this function.  Returns if a Handle and its contents 
dvander@2168
    81
 * are readable, whereas INVALID_HANDLE only checks for the absence 
dvander@2168
    82
 * of a Handle.
dvander@2168
    83
 *
dvander@2168
    84
 * This function is intended only for tests where the validity of a 
dvander@2168
    85
 * Handle can absolutely not be known. 
dvander@2168
    86
 *
dvander@2168
    87
 * Do not use this to check the return values of functions, or to 
dvander@2168
    88
 * check if timers should be closed (except in very rare cases).  
dvander@2168
    89
 * This function is for very specific usage and using it for general 
dvander@2168
    90
 * purpose routines can and will hide very subtle bugs.
dvander@2168
    91
 *
dvander@2168
    92
 * @param hndl		Handle to test for validity.
dvander@2168
    93
 * @return			True if handle is valid, false otherwise.
dvander@2168
    94
 */
dvander@2168
    95
#pragma deprecated Do not use this function.
dvander@2168
    96
native bool:IsValidHandle(Handle:hndl);