/addons/sourcemod/scripting/include/handles.inc

https://bitbucket.org/kimoto/sushi · Pascal · 96 lines · 89 code · 5 blank · 2 comment · 7 complexity · 8a7baf417b9bca05c9c8e5af46099195 MD5 · raw file

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