dvander@247: /** ds@475: * vim: set ts=4 : dvander@374: * =============================================================== dvander@374: * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved. dvander@374: * =============================================================== dvander@374: * dvander@374: * This file is part of the SourceMod/SourcePawn SDK. This file may only be used dvander@374: * or modified under the Terms and Conditions of its License Agreement, which is found dvander@374: * in LICENSE.txt. The Terms and Conditions for making SourceMod extensions/plugins dvander@374: * may change at any time. To view the latest information, see: dvander@374: * http://www.sourcemod.net/license.php dvander@374: * dvander@374: * Version: $Id$ dvander@247: */ dvander@247: dvander@247: #if defined _handles_included dvander@247: #endinput dvander@247: #endif dvander@247: #define _handles_included dvander@247: dvander@619: /** dvander@619: * Handle helper macros. dvander@619: */ dvander@247: enum Handle dvander@247: { dvander@247: INVALID_HANDLE = 0, dvander@247: }; dvander@247: dvander@247: /** dvander@247: * @brief Returns if a handle is valid or not. dvander@247: * @note It is not a good idea to call this on every Handle. If you code properly, dvander@247: * all of your Handles will either be valid or will expose important bugs to fix. dvander@247: * This is provided for situations only where testing for handle validity is needed. dvander@247: * dvander@247: * @param hndl Handle to test for validity. ds@475: * @return True if handle is valid, false otherwise. dvander@247: */ dvander@247: native bool:IsValidHandle(Handle:hndl); dvander@247: dvander@247: /** dvander@247: * @brief Closes a Handle. If the handle has multiple copies open, dvander@247: * it is not destroyed unless all copies are closed. dvander@247: * dvander@247: * @note Closing a Handle has a different meaning for each Handle type. Make dvander@247: * sure you read the documentation on whatever provided the Handle. dvander@247: * dvander@247: * @param hndl Handle to close. ds@475: * @return True if successful, false if not closeable. dvander@247: * @error Invalid handles will cause a run time error. dvander@247: */ dvander@247: native bool:CloseHandle(Handle:hndl); dvander@247: dvander@247: /** dvander@247: * @brief Clones a Handle. When passing handles in between plugins, caching handles dvander@247: * can result in accidental invalidation when one plugin releases the Handle, or is its owner dvander@247: * is unloaded from memory. To prevent this, the Handle may be "cloned" with a new owner. dvander@247: * dvander@247: * @note Usually, you will be cloning Handles for other plugins. This means that if you clone dvander@247: * the Handle without specifying the new owner, it will assume the identity of your original calling dvander@247: * plugin, which is not very useful. You should either specify that the receiving plugin should dvander@247: * clone the handle on its own, or you should explicitly clone the Handle using the receiving plugin's dvander@247: * identity Handle. dvander@247: * dvander@247: * @param hndl Handle to clone/duplicate. dvander@247: * @param plugin Optional Handle to another plugin to mark as the new owner. ds@475: * If no owner is passed, the owner becomes the calling plugin. ds@475: * @return Handle on success, INVALID_HANDLE if not cloneable. dvander@247: * @error Invalid handles will cause a run time error. dvander@247: */ dvander@247: native Handle:CloneHandle(Handle:hndl, Handle:plugin=INVALID_HANDLE);