pred@2224: /** pred@2224: * vim: set ts=4 : pred@2224: * ============================================================================= pred@2224: * SourceMod Sample Extension pred@2224: * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. pred@2224: * ============================================================================= pred@2224: * pred@2224: * This program is free software; you can redistribute it and/or modify it under pred@2224: * the terms of the GNU General Public License, version 3.0, as published by the pred@2224: * Free Software Foundation. pred@2224: * pred@2224: * This program is distributed in the hope that it will be useful, but WITHOUT pred@2224: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS pred@2224: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more pred@2224: * details. pred@2224: * pred@2224: * You should have received a copy of the GNU General Public License along with pred@2224: * this program. If not, see . pred@2224: * pred@2224: * As a special exception, AlliedModders LLC gives you permission to link the pred@2224: * code of this program (as well as its derivative works) to "Half-Life 2," the pred@2224: * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software pred@2224: * by the Valve Corporation. You must obey the GNU General Public License in pred@2224: * all respects for all other code used. Additionally, AlliedModders LLC grants pred@2224: * this exception to all derivative works. AlliedModders LLC defines further pred@2224: * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), pred@2224: * or . pred@2224: * pred@2224: * Version: $Id$ pred@2224: */ pred@2224: pred@2224: #include "StructManager.h" pred@2224: #include "extension.h" pred@2224: pred@2224: StructManager g_StructManager; pred@2224: pred@2224: void StructManager::AddStruct( const char *name, StructInfo *str ) pred@2224: { pred@2224: structs.insert(name, str); pred@2224: structsList.push_back(str); pred@2224: } pred@2224: pred@2224: StructManager::~StructManager() pred@2224: { pred@2224: SourceHook::List::iterator iter; pred@2224: pred@2224: iter = structsList.begin(); pred@2224: pred@2224: while (iter != structsList.end()) pred@2224: { pred@2224: delete (MemberInfo *)*iter; pred@2224: iter = structsList.erase(iter); pred@2224: } pred@2224: pred@2224: structs.clear(); pred@2224: } pred@2224: pred@2224: Handle_t StructManager::CreateStructHandle( const char *type, void *str ) pred@2224: { pred@2224: StructInfo **pInfo = structs.retrieve(type); pred@2224: pred@2224: if (pInfo == NULL) pred@2224: { pred@2224: return BAD_HANDLE; pred@2224: } pred@2224: pred@2224: StructHandle *pHandle = new StructHandle; pred@2224: pred@2224: pHandle->canDelete = false; pred@2224: pHandle->data = str; pred@2224: pHandle->info = *pInfo; pred@2224: pred@2224: return handlesys->CreateHandle(g_StructHandle, pred@2224: pHandle, pred@2224: NULL, pred@2224: myself->GetIdentity(), pred@2224: NULL); pred@2224: }