1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/plugins/include/handles.h Mon Jan 01 10:33:51 2007 +0000
1.3 @@ -0,0 +1,58 @@
1.4 +/**
1.5 + * :TODO: license info
1.6 + */
1.7 +
1.8 +
1.9 +#if defined _handles_included
1.10 + #endinput
1.11 +#endif
1.12 +#define _handles_included
1.13 +
1.14 +enum Handle
1.15 +{
1.16 + INVALID_HANDLE = 0,
1.17 +};
1.18 +
1.19 +/**
1.20 + * @brief Returns if a handle is valid or not.
1.21 + * @note It is not a good idea to call this on every Handle. If you code properly,
1.22 + * all of your Handles will either be valid or will expose important bugs to fix.
1.23 + * This is provided for situations only where testing for handle validity is needed.
1.24 + *
1.25 + * @param hndl Handle to test for validity.
1.26 + * @return True if handle is valid, false otherwise.
1.27 + */
1.28 +native bool:IsValidHandle(Handle:hndl);
1.29 +
1.30 +/**
1.31 + * @brief Closes a Handle. If the handle has multiple copies open,
1.32 + * it is not destroyed unless all copies are closed.
1.33 + *
1.34 + * @note Closing a Handle has a different meaning for each Handle type. Make
1.35 + * sure you read the documentation on whatever provided the Handle.
1.36 + *
1.37 + * @param hndl Handle to close.
1.38 + * @return True if successful, false if not closeable.
1.39 + * @error Invalid handles will cause a run time error.
1.40 + */
1.41 +native bool:CloseHandle(Handle:hndl);
1.42 +
1.43 +/**
1.44 + * @brief Clones a Handle. When passing handles in between plugins, caching handles
1.45 + * can result in accidental invalidation when one plugin releases the Handle, or is its owner
1.46 + * is unloaded from memory. To prevent this, the Handle may be "cloned" with a new owner.
1.47 + *
1.48 + * @note Usually, you will be cloning Handles for other plugins. This means that if you clone
1.49 + * the Handle without specifying the new owner, it will assume the identity of your original calling
1.50 + * plugin, which is not very useful. You should either specify that the receiving plugin should
1.51 + * clone the handle on its own, or you should explicitly clone the Handle using the receiving plugin's
1.52 + * identity Handle.
1.53 + *
1.54 + * @param hndl Handle to clone/duplicate.
1.55 + * @param plugin Optional Handle to another plugin to mark as the new owner.
1.56 + * If no owner is passed, the owner becomes the calling plugin.
1.57 + * @return Handle on success, INVALID_HANDLE if not cloneable.
1.58 + * @error Invalid handles will cause a run time error.
1.59 + */
1.60 +native Handle:CloneHandle(Handle:hndl, Handle:plugin=INVALID_HANDLE);
1.61 +