|
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@619
|
21 |
/** |
|
dvander@619
|
22 |
* Handle helper macros. |
|
dvander@619
|
23 |
*/ |
|
dvander@247
|
24 |
enum Handle |
|
dvander@247
|
25 |
{ |
|
dvander@247
|
26 |
INVALID_HANDLE = 0, |
|
dvander@247
|
27 |
}; |
|
dvander@247
|
28 |
|
|
dvander@247
|
29 |
/** |
|
dvander@812
|
30 |
* Returns if a handle is valid or not. |
|
dvander@247
|
31 |
* @note It is not a good idea to call this on every Handle. If you code properly, |
|
dvander@247
|
32 |
* all of your Handles will either be valid or will expose important bugs to fix. |
|
dvander@247
|
33 |
* This is provided for situations only where testing for handle validity is needed. |
|
dvander@247
|
34 |
* |
|
dvander@247
|
35 |
* @param hndl Handle to test for validity. |
|
ds@475
|
36 |
* @return True if handle is valid, false otherwise. |
|
dvander@247
|
37 |
*/ |
|
dvander@247
|
38 |
native bool:IsValidHandle(Handle:hndl); |
|
dvander@247
|
39 |
|
|
dvander@247
|
40 |
/** |
|
dvander@812
|
41 |
* Closes a Handle. If the handle has multiple copies open, |
|
dvander@247
|
42 |
* it is not destroyed unless all copies are closed. |
|
dvander@247
|
43 |
* |
|
dvander@247
|
44 |
* @note Closing a Handle has a different meaning for each Handle type. Make |
|
dvander@247
|
45 |
* sure you read the documentation on whatever provided the Handle. |
|
dvander@247
|
46 |
* |
|
dvander@247
|
47 |
* @param hndl Handle to close. |
|
ds@475
|
48 |
* @return True if successful, false if not closeable. |
|
dvander@247
|
49 |
* @error Invalid handles will cause a run time error. |
|
dvander@247
|
50 |
*/ |
|
dvander@247
|
51 |
native bool:CloseHandle(Handle:hndl); |
|
dvander@247
|
52 |
|
|
dvander@247
|
53 |
/** |
|
dvander@812
|
54 |
* Clones a Handle. When passing handles in between plugins, caching handles |
|
dvander@247
|
55 |
* can result in accidental invalidation when one plugin releases the Handle, or is its owner |
|
dvander@247
|
56 |
* is unloaded from memory. To prevent this, the Handle may be "cloned" with a new owner. |
|
dvander@247
|
57 |
* |
|
dvander@247
|
58 |
* @note Usually, you will be cloning Handles for other plugins. This means that if you clone |
|
dvander@247
|
59 |
* the Handle without specifying the new owner, it will assume the identity of your original calling |
|
dvander@247
|
60 |
* plugin, which is not very useful. You should either specify that the receiving plugin should |
|
dvander@247
|
61 |
* clone the handle on its own, or you should explicitly clone the Handle using the receiving plugin's |
|
dvander@247
|
62 |
* identity Handle. |
|
dvander@247
|
63 |
* |
|
dvander@247
|
64 |
* @param hndl Handle to clone/duplicate. |
|
dvander@247
|
65 |
* @param plugin Optional Handle to another plugin to mark as the new owner. |
|
ds@475
|
66 |
* If no owner is passed, the owner becomes the calling plugin. |
|
ds@475
|
67 |
* @return Handle on success, INVALID_HANDLE if not cloneable. |
|
dvander@247
|
68 |
* @error Invalid handles will cause a run time error. |
|
dvander@247
|
69 |
*/ |
|
dvander@247
|
70 |
native Handle:CloneHandle(Handle:hndl, Handle:plugin=INVALID_HANDLE); |