Initial commit
This commit is contained in:
95
Torque/SDK/engine/console/simDictionary.h
Normal file
95
Torque/SDK/engine/console/simDictionary.h
Normal file
@@ -0,0 +1,95 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Torque Game Engine
|
||||
// Copyright (C) GarageGames.com, Inc.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef _SIMDICTIONARY_H_
|
||||
#define _SIMDICTIONARY_H_
|
||||
#ifndef _PLATFORM_H_
|
||||
#include "platform/platform.h"
|
||||
#endif
|
||||
#ifndef _STRINGTABLE_H_
|
||||
#include "core/stringTable.h"
|
||||
#endif
|
||||
|
||||
#ifndef _PLATFORMMUTEX_H_
|
||||
#include "platform/platformMutex.h"
|
||||
#endif
|
||||
|
||||
class SimObject;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
/// Map of names to SimObjects
|
||||
///
|
||||
/// Provides fast lookup for name->object and
|
||||
/// for fast removal of an object given object*
|
||||
class SimNameDictionary
|
||||
{
|
||||
enum
|
||||
{
|
||||
DefaultTableSize = 29
|
||||
};
|
||||
|
||||
SimObject **hashTable; // hash the pointers of the names...
|
||||
S32 hashTableSize;
|
||||
S32 hashEntryCount;
|
||||
|
||||
void *mutex;
|
||||
|
||||
public:
|
||||
void insert(SimObject* obj);
|
||||
void remove(SimObject* obj);
|
||||
SimObject* find(StringTableEntry name);
|
||||
|
||||
SimNameDictionary();
|
||||
~SimNameDictionary();
|
||||
};
|
||||
|
||||
class SimManagerNameDictionary
|
||||
{
|
||||
enum
|
||||
{
|
||||
DefaultTableSize = 29
|
||||
};
|
||||
|
||||
SimObject **hashTable; // hash the pointers of the names...
|
||||
S32 hashTableSize;
|
||||
S32 hashEntryCount;
|
||||
|
||||
void *mutex;
|
||||
|
||||
public:
|
||||
void insert(SimObject* obj);
|
||||
void remove(SimObject* obj);
|
||||
SimObject* find(StringTableEntry name);
|
||||
|
||||
SimManagerNameDictionary();
|
||||
~SimManagerNameDictionary();
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
/// Map of ID's to SimObjects.
|
||||
///
|
||||
/// Provides fast lookup for ID->object and
|
||||
/// for fast removal of an object given object*
|
||||
class SimIdDictionary
|
||||
{
|
||||
enum
|
||||
{
|
||||
DefaultTableSize = 4096,
|
||||
TableBitMask = 4095
|
||||
};
|
||||
SimObject *table[DefaultTableSize];
|
||||
|
||||
void *mutex;
|
||||
|
||||
public:
|
||||
void insert(SimObject* obj);
|
||||
void remove(SimObject* obj);
|
||||
SimObject* find(S32 id);
|
||||
|
||||
SimIdDictionary();
|
||||
~SimIdDictionary();
|
||||
};
|
||||
|
||||
#endif //_SIMDICTIONARY_H_
|
||||
Reference in New Issue
Block a user