Home | History | Annotate | Download | only in LD
      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_GROUPREADER_H
     10 #define MCLD_GROUPREADER_H
     11 #ifdef ENABLE_UNITTEST
     12 #include <gtest.h>
     13 #endif
     14 
     15 #include <mcld/Module.h>
     16 
     17 namespace mcld
     18 {
     19 class Archive;
     20 class ArchiveReader;
     21 class DynObjReader;
     22 class LinkerConfig;
     23 class ObjectReader;
     24 
     25 /** \class GroupReader
     26  *  \brief GroupReader handles the Group Node in InputTree
     27  *
     28  *  Group Node is the root of sub-tree in InputTree which includes the iputs in
     29  *  the command line options --start-group and --end-group options
     30  */
     31 class GroupReader
     32 {
     33 public:
     34   GroupReader(Module& pModule,
     35               ObjectReader& pObjectReader,
     36               DynObjReader& pDynObjReader,
     37               ArchiveReader& pArchiveReader);
     38 
     39   ~GroupReader();
     40 
     41   /// readGroup - handle the input sub-tree wich its root is pRoot
     42   /// @param pRoot - the root Group node of the sub-tree
     43   bool readGroup(Module::input_iterator pRoot,
     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 {
     51     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 };
     64 
     65 } // namespace of mcld
     66 
     67 #endif
     68 
     69