plugins/include/handles.inc
author David Anderson <dvander@alliedmods.net>
Tue Feb 13 03:19:59 2007 +0000 (2007-02-13)
changeset 481 a6aad457b29c
parent 475 bb11d7eaae0f
child 619 6934bf39171e
permissions -rw-r--r--
changed these numbers for future expandability
dvander@247
     1
/**
ds@475
     2
 * vim: set ts=4 :
dvander@374
     3
 * ===============================================================
dvander@374
     4
 * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
dvander@374
     5
 * ===============================================================
dvander@374
     6
 *
dvander@374
     7
 *  This file is part of the SourceMod/SourcePawn SDK.  This file may only be used 
dvander@374
     8
 * or modified under the Terms and Conditions of its License Agreement, which is found 
dvander@374
     9
 * in LICENSE.txt.  The Terms and Conditions for making SourceMod extensions/plugins 
dvander@374
    10
 * may change at any time.  To view the latest information, see:
dvander@374
    11
 *   http://www.sourcemod.net/license.php
dvander@374
    12
 *
dvander@374
    13
 * Version: $Id$
dvander@247
    14
 */
dvander@247
    15
dvander@247
    16
#if defined _handles_included
dvander@247
    17
 #endinput
dvander@247
    18
#endif
dvander@247
    19
#define _handles_included
dvander@247
    20
dvander@247
    21
enum Handle
dvander@247
    22
{
dvander@247
    23
	INVALID_HANDLE = 0,
dvander@247
    24
};
dvander@247
    25
dvander@247
    26
/**
dvander@247
    27
 * @brief Returns if a handle is valid or not.
dvander@247
    28
 * @note It is not a good idea to call this on every Handle.  If you code properly,
dvander@247
    29
 *       all of your Handles will either be valid or will expose important bugs to fix.
dvander@247
    30
 *       This is provided for situations only where testing for handle validity is needed.
dvander@247
    31
 *
dvander@247
    32
 * @param hndl		Handle to test for validity.
ds@475
    33
 * @return			True if handle is valid, false otherwise.
dvander@247
    34
 */
dvander@247
    35
native bool:IsValidHandle(Handle:hndl);
dvander@247
    36
dvander@247
    37
/**
dvander@247
    38
 * @brief Closes a Handle.  If the handle has multiple copies open, 
dvander@247
    39
 * it is not destroyed unless all copies are closed.
dvander@247
    40
 * 
dvander@247
    41
 * @note Closing a Handle has a different meaning for each Handle type.  Make
dvander@247
    42
 *       sure you read the documentation on whatever provided the Handle.
dvander@247
    43
 *
dvander@247
    44
 * @param hndl		Handle to close.
ds@475
    45
 * @return			True if successful, false if not closeable.
dvander@247
    46
 * @error			Invalid handles will cause a run time error.
dvander@247
    47
 */
dvander@247
    48
native bool:CloseHandle(Handle:hndl);
dvander@247
    49
dvander@247
    50
/**
dvander@247
    51
 * @brief Clones a Handle.  When passing handles in between plugins, caching handles
dvander@247
    52
 * can result in accidental invalidation when one plugin releases the Handle, or is its owner
dvander@247
    53
 * is unloaded from memory.  To prevent this, the Handle may be "cloned" with a new owner.
dvander@247
    54
 * 
dvander@247
    55
 * @note Usually, you will be cloning Handles for other plugins.  This means that if you clone
dvander@247
    56
 * the Handle without specifying the new owner, it will assume the identity of your original calling
dvander@247
    57
 * plugin, which is not very useful.  You should either specify that the receiving plugin should
dvander@247
    58
 * clone the handle on its own, or you should explicitly clone the Handle using the receiving plugin's
dvander@247
    59
 * identity Handle.
dvander@247
    60
 *
dvander@247
    61
 * @param hndl		Handle to clone/duplicate.
dvander@247
    62
 * @param plugin	Optional Handle to another plugin to mark as the new owner.
ds@475
    63
 *					If no owner is passed, the owner becomes the calling plugin.
ds@475
    64
 * @return			Handle on success, INVALID_HANDLE if not cloneable.
dvander@247
    65
 * @error			Invalid handles will cause a run time error.
dvander@247
    66
 */
dvander@247
    67
native Handle:CloneHandle(Handle:hndl, Handle:plugin=INVALID_HANDLE);