00001 //=================================================================================================// 00002 // filename: RmStringToPtr.h // 00003 // // 00004 // ATI Research, Inc. // 00005 // 3D Application Research Group // 00006 // // 00007 // Description: String to Pointer map Class for RenderMonkey. // 00008 // // 00009 //=================================================================================================// 00010 // (C) 2004 ATI Research, Inc. All rights reserved. // 00011 //=================================================================================================// 00012 00013 #ifndef _RM_CORE_STRING_TO_PTR_H_ 00014 #define _RM_CORE_STRING_TO_PTR_H_ 00015 00016 #include <Core/RmTypes.h> 00017 #include <Core/RmString.h> 00018 00019 #include <functional> 00020 00021 //..............................................................................................................// 00022 //..............................................................................................................// 00023 //..............................................................................................................// 00024 // RmStringToPtrMap class 00025 // 00026 // - Hash map for string -> ptr 00027 //..............................................................................................................// 00028 //..............................................................................................................// 00029 //..............................................................................................................// 00030 00031 00032 class RM_API RmStringToPtrMap 00033 { 00034 public : 00035 struct StringToPtrData 00036 { 00037 StringToPtrData( const RM_TCHAR *szStr, void* pPtr ) : 00038 str(szStr), 00039 ptr(pPtr) 00040 { 00041 }; // End of Constructor 00042 00043 RmStringT str; 00044 void* ptr; 00045 }; // End of StringToPtrData 00046 00047 // For now we use linked list, we may want to switch to hash table later 00048 typedef RmLinkedList<StringToPtrData> StringToPtrMap; 00049 typedef StringToPtrMap::iterator StringToPtrMapIterator; 00050 typedef StringToPtrMap::const_iterator StringToPtrMapConstIterator; 00051 00052 public : 00053 RmStringToPtrMap(); 00054 virtual ~RmStringToPtrMap(); 00055 00056 // Insert generic pointer and given name is the key for retrieval 00057 void SetAt( const RM_TCHAR* keyStr, void *ptr ); 00058 00059 // Remove entry with given string key 00060 void Remove( const RM_TCHAR *keyStr ); 00061 void RemoveAll(); 00062 00063 // Find element registered with given key string 00064 bool Lookup( const RM_TCHAR *keyStr, void* &ptr ) const; 00065 00066 // Iterator 00067 StringToPtrMapIterator Begin() { return m_strToPtrMap.begin(); }; 00068 StringToPtrMapIterator End() { return m_strToPtrMap.end(); }; 00069 00070 StringToPtrMapConstIterator Begin() const { return m_strToPtrMap.begin(); }; 00071 StringToPtrMapConstIterator End() const { return m_strToPtrMap.end(); }; 00072 00073 private : 00074 StringToPtrMap m_strToPtrMap; 00075 }; // End of RmStringToPtrMap 00076 00077 #endif
1.3.6