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