• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===- SymbolTableFactory.h -----------------------------------------------===//
2 //
3 //                     The MCLinker Project
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 #ifndef MCLD_SYMBOL_TABLE_FACTORY_H
10 #define MCLD_SYMBOL_TABLE_FACTORY_H
11 #ifdef ENABLE_UNITTEST
12 #include <gtest.h>
13 #endif
14 #include "mcld/LD/InputSymbolTable.h"
15 #include "mcld/LD/OutputSymbolTable.h"
16 
17 namespace mcld
18 {
19 
20 class StringTable;
21 class StrSymPool;
22 
23 /** \class SymbolTableFactory
24  *  \brief SymbolTableFactory manages SymbolTableIFs.
25  *
26  *  SymbolTableFactory is responsed for construction and destruction of
27  *  SymbolTableIF. Since different MCLDFiles have different type of
28  *  SymbolTableIF, SymbolTableFactory separates the construction of
29  *  SymbolTableIF into createInputTable() and createOutputTable().
30  *
31  *  @see SymbolTableIF InputSymbolTable OutputSymbolTable
32  */
33 class SymbolTableFactory
34 {
35 public:
36   /// SymbolTableFactory - constructor
37   //  @param pNumOfSymbolTables is the most appropriate number of created
38   //  symbol tables.
39   //  @param pStorage the real storage of created symbols
40   explicit SymbolTableFactory(size_t pNumOfSymbolTables,
41                               StrSymPool& pStrSymPool);
42   /// ~SymbolTableFactory - destructor
43   //  destructor destroys all created symbol tables.
44   ~SymbolTableFactory();
45 
46   /// createInputTable - create a symbol table for an input file
47   //  @param pEntireStringTable the string table of created Symbols.
48   //  @param pDynamicStringTable the string table of created Dynamic Symbols.
49   //  @param pReserve Created symbol table must reserve pReserve number of
50   //  storages of symbol for creating symbols.
51   SymbolTableIF *createInputTable(StringTable &pEntireStringTable,
52                                   StringTable &pDynamicStringTable,
53                                   size_t pReserve=256);
54 
55   /// createOutputTable - create a symbol table for an output file
56   //  @param pEntireStringTable the string table of created Symbols.
57   //  @param pDynamicStringTable the string table of created Dynamic Symbols.
58   //  @param pReserve Created symbol table must reserve pReserve number of
59   //  storages of symbol for creating symbols.
60   SymbolTableIF *createOutputTable(StringTable &pEntireStringTable,
61                                    StringTable &pDynamicStringTable,
62                                    size_t pReserve=256);
63 private:
64   StrSymPool &m_StrSymPool;
65   GCFactory<InputSymbolTable, 0> m_InputFactory;
66   GCFactory<OutputSymbolTable, 0> m_OutputFactory;
67 
68 };
69 
70 } // namespace of mcld
71 
72 #endif
73