plugins/include/handles.inc
author Scott Ehlert <ds@alliedmods.net>
Wed Aug 15 06:19:30 2007 +0000 (2007-08-15)
changeset 1330 ab94316bb52b
parent 812 c8acd5c38374
child 1398 f297d5752bef
permissions -rw-r--r--
Updated license headers on virtually all files with extremely minor changes in the name of some sort of strange consistency.
All plugin and include file headers also have been changed to say about GPL3 instead of GPL2.

(This day shall henceforth be known as the Eighty Column Massacre of '07)
dvander@247
     1
/**
ds@475
     2
 * vim: set ts=4 :
ds@1330
     3
 * =============================================================================
dvander@374
     4
 * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
ds@1330
     5
 * =============================================================================
ds@1330
     6
 *
ds@1330
     7
 * This file is part of the SourceMod/SourcePawn SDK.
dvander@374
     8
 *
ds@1330
     9
 * This program is free software; you can redistribute it and/or modify it under
ds@1330
    10
 * the terms of the GNU General Public License, version 3.0, as published by the
ds@1330
    11
 * Free Software Foundation.
ds@1330
    12
 * 
ds@1330
    13
 * This program is distributed in the hope that it will be useful, but WITHOUT
ds@1330
    14
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
ds@1330
    15
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
ds@1330
    16
 * details.
ds@1330
    17
 *
ds@1330
    18
 * You should have received a copy of the GNU General Public License along with
ds@1330
    19
 * this program.  If not, see <http://www.gnu.org/licenses/>.
ds@1330
    20
 *
ds@1330
    21
 * As a special exception, AlliedModders LLC gives you permission to link the
ds@1330
    22
 * code of this program (as well as its derivative works) to "Half-Life 2," the
ds@1330
    23
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
ds@1330
    24
 * by the Valve Corporation.  You must obey the GNU General Public License in
ds@1330
    25
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
ds@1330
    26
 * this exception to all derivative works.  AlliedModders LLC defines further
ds@1330
    27
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
ds@1330
    28
 * or <http://www.sourcemod.net/license.php>.
dvander@374
    29
 *
dvander@374
    30
 * Version: $Id$
dvander@247
    31
 */
dvander@247
    32
dvander@247
    33
#if defined _handles_included
dvander@247
    34
 #endinput
dvander@247
    35
#endif
dvander@247
    36
#define _handles_included
dvander@247
    37
dvander@619
    38
/**
dvander@619
    39
 * Handle helper macros.
dvander@619
    40
 */
dvander@247
    41
enum Handle
dvander@247
    42
{
dvander@247
    43
	INVALID_HANDLE = 0,
dvander@247
    44
};
dvander@247
    45
dvander@247
    46
/**
dvander@812
    47
 * Returns if a handle is valid or not.
dvander@247
    48
 * @note It is not a good idea to call this on every Handle.  If you code properly,
dvander@247
    49
 *       all of your Handles will either be valid or will expose important bugs to fix.
dvander@247
    50
 *       This is provided for situations only where testing for handle validity is needed.
dvander@247
    51
 *
dvander@247
    52
 * @param hndl		Handle to test for validity.
ds@475
    53
 * @return			True if handle is valid, false otherwise.
dvander@247
    54
 */
dvander@247
    55
native bool:IsValidHandle(Handle:hndl);
dvander@247
    56
dvander@247
    57
/**
dvander@812
    58
 * Closes a Handle.  If the handle has multiple copies open, 
dvander@247
    59
 * it is not destroyed unless all copies are closed.
dvander@247
    60
 * 
dvander@247
    61
 * @note Closing a Handle has a different meaning for each Handle type.  Make
dvander@247
    62
 *       sure you read the documentation on whatever provided the Handle.
dvander@247
    63
 *
dvander@247
    64
 * @param hndl		Handle to close.
ds@475
    65
 * @return			True if successful, false if not closeable.
dvander@247
    66
 * @error			Invalid handles will cause a run time error.
dvander@247
    67
 */
dvander@247
    68
native bool:CloseHandle(Handle:hndl);
dvander@247
    69
dvander@247
    70
/**
dvander@812
    71
 * Clones a Handle.  When passing handles in between plugins, caching handles
dvander@247
    72
 * can result in accidental invalidation when one plugin releases the Handle, or is its owner
dvander@247
    73
 * is unloaded from memory.  To prevent this, the Handle may be "cloned" with a new owner.
dvander@247
    74
 * 
dvander@247
    75
 * @note Usually, you will be cloning Handles for other plugins.  This means that if you clone
dvander@247
    76
 * the Handle without specifying the new owner, it will assume the identity of your original calling
dvander@247
    77
 * plugin, which is not very useful.  You should either specify that the receiving plugin should
dvander@247
    78
 * clone the handle on its own, or you should explicitly clone the Handle using the receiving plugin's
dvander@247
    79
 * identity Handle.
dvander@247
    80
 *
dvander@247
    81
 * @param hndl		Handle to clone/duplicate.
dvander@247
    82
 * @param plugin	Optional Handle to another plugin to mark as the new owner.
ds@475
    83
 *					If no owner is passed, the owner becomes the calling plugin.
ds@475
    84
 * @return			Handle on success, INVALID_HANDLE if not cloneable.
dvander@247
    85
 * @error			Invalid handles will cause a run time error.
dvander@247
    86
 */
dvander@247
    87
native Handle:CloneHandle(Handle:hndl, Handle:plugin=INVALID_HANDLE);