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     External = MCLDFile::External
     45   };
     46 
     47 private:
     48   explicit Input(llvm::StringRef pName,
     49                  const AttributeProxy& pAttr);
     50 
     51   Input(llvm::StringRef pName,
     52         const sys::fs::Path& pPath,
     53         const AttributeProxy& pAttr,
     54         unsigned int pType = Unknown,
     55         off_t pFileOffset = 0);
     56 
     57 public:
     58   ~Input();
     59 
     60   bool isRecognized() const
     61   { return (m_Type != Unknown); }
     62 
     63   const Attribute* attribute() const
     64   { return m_pAttr; }
     65 
     66   bool isNeeded() const
     67   { return m_bNeeded; }
     68 
     69   void setNeeded()
     70   { m_bNeeded = true; }
     71 
     72   off_t fileOffset() const
     73   { return m_fileOffset; }
     74 
     75   void setFileOffset(off_t pFileOffset)
     76   { m_fileOffset = pFileOffset; }
     77 
     78 private:
     79   Attribute *m_pAttr;
     80   bool m_bNeeded;
     81   off_t m_fileOffset;
     82 };
     83 
     84 } // namespace of mcld
     85 
     86 #endif
     87 
     88