Jamoma API  0.6.0.a19
TTSymbolTable.h
1 /*
2  * Jamoma Class that maintains a table of symbols
3  * Copyright © 2008, Timothy Place
4  *
5  * License: This code is licensed under the terms of the "New BSD License"
6  * http://creativecommons.org/licenses/BSD/
7  */
8 
9 #ifndef __TT_SYMBOLTABLE_H__
10 #define __TT_SYMBOLTABLE_H__
11 
12 #include "TTBase.h"
13 #include "TTSymbolBase.h"
14 
15 
16 /****************************************************************************************************/
17 // Class Specifications
18 
19 /**
20  The TTSymbolTable class is hash_map (based on Stroustrup pp 497) that keeps
21  commonly used strings in a table so that we can refer to them simply as a pointers for fast comparison.
22  */
23 
24 class TTFOUNDATION_EXPORT TTSymbolTable {
25 private:
26  TTPtr mSymbolTable; ///< The symbol table, mapping strings to pointers
27 
28 protected:
29  /** Overridable method used internally when constructing a new
30  TTSymbolBase */
31  virtual TTSymbolBase* createEntry(const TTString& aString, TTInt32 newSymbolId);
32 
33 public:
34  TTSymbolTable(TTBoolean createEmptyTable = false);
35  virtual ~TTSymbolTable();
36 
37  /** Look in the symbol table for this string. If it exists then return its id.
38  If it does not exist then it is created, added to the symbol table and this new symbol's id is returned. */
39  TTSymbolBase* lookup(const char* aString);
40 
41  /** Look in the symbol table for this string. If it exists then return its id.
42  If it does not exist then it is created, added to the symbol table and this new symbol's id is returned. */
43  TTSymbolBase* lookup(const TTString& aString);
44 
45  /** Look in the symbol table for a string with this number as its content.
46  If it exists then return its id.
47  If it does not exist then it is created, added to the symbol table and this new symbol's id is returned. */
48  TTSymbolBase* lookup(const int& aNumberToBeConvertedToAString);
49 
50  /** Debugging tool to make it easy to examine everything that is in the symbol table. */
51  void dump(/*TTValue& allSymbols*/);
52 };
53 
54 extern TTFOUNDATION_EXPORT TTSymbolTable gTTSymbolTable;
55 
56 
57 #endif // __TT_SYMBOLTABLE_H__
58 
bool TTBoolean
Boolean flag, same as Boolean on the Mac.
Definition: TTBase.h:167
The TTSymbolBase class is used to represent a string and efficiently pass and compare that string...
Definition: TTSymbolBase.h:28
void * TTPtr
A generic pointer.
Definition: TTBase.h:248
Jamoma's lowest-level base class and related infrastructure.
The TTSymbolTable class is hash_map (based on Stroustrup pp 497) that keeps commonly used strings in ...
Definition: TTSymbolTable.h:24
std::int32_t TTInt32
32 bit signed integer
Definition: TTBase.h:177
The TTString class is used to represent a string.
Definition: TTString.h:34