Home | History | Annotate | Download | only in MC
      1 //===- MCLDInput.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 //
     10 //  Input class inherits MCLDFile, which is used to represent a input file
     11 //
     12 //===----------------------------------------------------------------------===//
     13 
     14 #ifndef MCLD_INPUT_H
     15 #define MCLD_INPUT_H
     16 #ifdef ENABLE_UNITTEST
     17 #include <gtest.h>
     18 #endif
     19 
     20 #include "mcld/MC/MCLDFile.h"
     21 
     22 namespace mcld
     23 {
     24 
     25 class AttributeProxy;
     26 class Attribute;
     27 class InputFactory;
     28 
     29 /** \class Input
     30  *  \brief Input provides the information of a input file.
     31  *
     32  *  @see MCLDFile
     33  */
     34 class Input : public MCLDFile
     35 {
     36 friend class InputFactory;
     37 public:
     38   enum Type {
     39     Unknown = MCLDFile::Unknown,
     40     Object = MCLDFile::Object,
     41     DynObj = MCLDFile::DynObj,
     42     Archive = MCLDFile::Archive,
     43     Script = MCLDFile::Script
     44   };
     45 
     46 private:
     47   explicit Input(llvm::StringRef pName,
     48                  const AttributeProxy& pAttr);
     49 
     50   Input(llvm::StringRef pName,
     51         const sys::fs::Path& pPath,
     52         const AttributeProxy& pAttr,
     53         unsigned int pType = Unknown,
     54         off_t pFileOffset = 0);
     55 
     56 public:
     57   ~Input();
     58 
     59   bool isRecognized() const
     60   { return (m_Type != Unknown); }
     61 
     62   const Attribute* attribute() const
     63   { return m_pAttr; }
     64 
     65   bool isNeeded() const
     66   { return m_bNeeded; }
     67 
     68   void setNeeded()
     69   { m_bNeeded = true; }
     70 
     71   off_t fileOffset() const
     72   { return m_fileOffset; }
     73 
     74   void setFileOffset(off_t pFileOffset)
     75   { m_fileOffset = pFileOffset; }
     76 
     77 private:
     78   Attribute *m_pAttr;
     79   bool m_bNeeded;
     80   off_t m_fileOffset;
     81 };
     82 
     83 } // namespace of mcld
     84 
     85 #endif
     86 
     87