GroupReader.h revision 37b74a387bb3993387029859c2d9d051c41c724e
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
14namespace mcld {
15class Archive;
16class ArchiveReader;
17class BinaryReader;
18class DynObjReader;
19class InputBuilder;
20class LinkerConfig;
21class ObjectReader;
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 */
29class GroupReader {
30 public:
31  GroupReader(Module& pModule,
32              ObjectReader& pObjectReader,
33              DynObjReader& pDynObjReader,
34              ArchiveReader& pArchiveReader,
35              BinaryReader& pBinaryReader);
36
37  ~GroupReader();
38
39  /// readGroup - handle the input sub-tree wich its root is pRoot
40  /// @param pRoot - the root Group node of the sub-tree
41  bool readGroup(Module::input_iterator pRoot,
42                 Module::input_iterator pEnd,
43                 InputBuilder& pBuilder,
44                 const LinkerConfig& pConfig);
45
46 private:
47  /// ArchiveListEntry - record the Archive and the corresponding input iterator
48  /// of the archive node
49  struct ArchiveListEntry {
50    ArchiveListEntry(Archive& pArchive, Module::input_iterator pIterator)
51        : archive(pArchive), input(pIterator) {}
52    Archive& archive;
53    Module::input_iterator input;
54  };
55
56 private:
57  Module& m_Module;
58  ObjectReader& m_ObjectReader;
59  DynObjReader& m_DynObjReader;
60  ArchiveReader& m_ArchiveReader;
61  BinaryReader& m_BinaryReader;
62};
63
64}  // namespace mcld
65
66#endif  // MCLD_LD_GROUPREADER_H_
67