1 //===- GroupReader.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_LD_GROUPREADER_H
10 #define MCLD_LD_GROUPREADER_H
11 
12 #include <mcld/Module.h>
13 
14 namespace mcld
15 {
16 class Archive;
17 class ArchiveReader;
18 class DynObjReader;
19 class LinkerConfig;
20 class ObjectReader;
21 class BinaryReader;
22 
23 /** \class GroupReader
24  *  \brief GroupReader handles the Group Node in InputTree
25  *
26  *  Group Node is the root of sub-tree in InputTree which includes the iputs in
27  *  the command line options --start-group and --end-group options
28  */
29 class GroupReader
30 {
31 public:
32   GroupReader(Module& pModule,
33               ObjectReader& pObjectReader,
34               DynObjReader& pDynObjReader,
35               ArchiveReader& pArchiveReader,
36               BinaryReader& pBinaryReader);
37 
38   ~GroupReader();
39 
40   /// readGroup - handle the input sub-tree wich its root is pRoot
41   /// @param pRoot - the root Group node of the sub-tree
42   bool readGroup(Module::input_iterator pRoot,
43                  Module::input_iterator pEnd,
44                  InputBuilder& pBuilder,
45                  const LinkerConfig& pConfig);
46 
47 private:
48   /// ArchiveListEntry - record the Archive and the corresponding input iterator
49   /// of the archive node
50   struct ArchiveListEntry {
ArchiveListEntryArchiveListEntry51     ArchiveListEntry(Archive& pArchive, Module::input_iterator pIterator)
52       : archive(pArchive), input(pIterator) {
53     }
54     Archive& archive;
55     Module::input_iterator input;
56   };
57 
58 private:
59   Module& m_Module;
60   ObjectReader& m_ObjectReader;
61   DynObjReader& m_DynObjReader;
62   ArchiveReader& m_ArchiveReader;
63   BinaryReader& m_BinaryReader;
64 };
65 
66 } // namespace of mcld
67 
68 #endif
69 
70