SourceMod SDK  1.7
IHandleSys.h File Reference

Defines the interface for creating, reading, and removing Handles. More...

#include <IShareSys.h>
#include <sp_vm_types.h>

Go to the source code of this file.


struct  SourceMod::TypeAccess
 This is used to define per-type access rights. More...
struct  SourceMod::HandleAccess
 This is used to define per-Handle access rights. More...
struct  SourceMod::HandleSecurity
 This pair of tokens is used for identification. More...
class  SourceMod::IHandleTypeDispatch
 Hooks type-specific Handle operations. More...
class  SourceMod::IHandleSys
 Provides functions for managing Handles. More...


#define NO_HANDLE_TYPE   0
#define BAD_HANDLE   0
#define HANDLE_RESTRICT_OWNER   (1<<1)


typedef unsigned int SourceMod::HandleType_t
 Represents a Handle Type ID. More...
typedef unsigned int SourceMod::Handle_t
 Represents a Handle ID.


enum  HandleError {
  SourceMod::HandleError_None = 0, SourceMod::HandleError_Changed, SourceMod::HandleError_Type, SourceMod::HandleError_Freed,
  SourceMod::HandleError_Index, SourceMod::HandleError_Access, SourceMod::HandleError_Limit, SourceMod::HandleError_Identity,
  SourceMod::HandleError_Owner, SourceMod::HandleError_Version, SourceMod::HandleError_Parameter, SourceMod::HandleError_NoInherit
 Lists the possible handle error codes.
enum  HTypeAccessRight { SourceMod::HTypeAccess_Create = 0, SourceMod::HTypeAccess_Inherit, SourceMod::HTypeAccess_TOTAL }
 Lists access rights specific to a type.
enum  HandleAccessRight { SourceMod::HandleAccess_Read, SourceMod::HandleAccess_Delete, SourceMod::HandleAccess_Clone, SourceMod::HandleAccess_TOTAL }
 Lists access rights specific to a Handle. More...

Detailed Description

Defines the interface for creating, reading, and removing Handles.

vim: set ts=4 :


Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 3.0, as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see

As a special exception, AlliedModders LLC gives you permission to link the code of this program (as well as its derivative works) to "Half-Life 2," the "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software by the Valve Corporation. You must obey the GNU General Public License in all respects for all other code used. Additionally, AlliedModders LLC grants this exception to all derivative works. AlliedModders LLC defines further exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), or

Version: $Id$

The Handle system abstracts generic pointers into typed objects represented by 32bit codes. This is extremely useful for verifying data integrity and cross-platform support in SourcePawn scripts. When a Plugin unloads, all its Handles are freed, ensuring that no memory leaks are present, They have reference counts and thus can be duplicated, or cloned, and are safe to pass between Plugins even if one is unloaded.

Handles are created with a given type (custom types may be created). They can have per-Identity permissions for deletion, reading, and cloning. They also support generic operations. For example, deleting a Handle will call that type's destructor on the generic pointer, making cleanup easier for users and eliminating memory leaks.

Macro Definition Documentation

#define BAD_HANDLE   0

Specifies an invalid/NULL Handle


Specifies no Identity


Access is restricted to the identity

#define HANDLE_RESTRICT_OWNER   (1<<1)

Access is restricted to the owner

#define NO_HANDLE_TYPE   0

Specifies no Type. This is invalid for everything but reading a Handle.