Home | History | Annotate | Download | only in MC
      1 //===- InputFactory.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_INPUT_FACTORY_H
     10 #define MCLD_INPUT_FACTORY_H
     11 #ifdef ENABLE_UNITTEST
     12 #include <gtest.h>
     13 #endif
     14 #include <mcld/Support/GCFactory.h>
     15 #include <mcld/MC/MCLDInput.h>
     16 
     17 namespace mcld {
     18 
     19 class LinkerConfig;
     20 class AttributeProxy;
     21 class AttributeSet;
     22 
     23 /** \class InputFactory
     24  *  \brief InputFactory controls the production and destruction of
     25  *  MCLDInput.
     26  *
     27  *  All MCLDFiles created by MCLDFileFactory are guaranteed to be destructed
     28  *  while MCLDFileFactory is destructed.
     29  *
     30  *  \see llvm::sys::Path
     31  */
     32 class InputFactory : public GCFactory<Input,0>
     33 {
     34 public:
     35   typedef GCFactory<Input, 0> Alloc;
     36 
     37 public:
     38   InputFactory(size_t pNum, const LinkerConfig& pConfig);
     39 
     40   ~InputFactory();
     41 
     42   // -----  input  ----- //
     43   Input* produce(llvm::StringRef pName,
     44                  const sys::fs::Path& pPath,
     45                  unsigned int pType = Input::Unknown,
     46                  off_t pFileOffset = 0);
     47 
     48   // -----  attributes  ----- //
     49   /// attr - the last touched attribute.
     50   const AttributeProxy& attr() const { return *m_pLast; }
     51   AttributeProxy&       attr()       { return *m_pLast; }
     52 
     53 private:
     54   AttributeProxy* m_pLast;
     55   AttributeSet* m_pAttrSet;
     56 };
     57 
     58 } // namespace of mcld
     59 
     60 #endif
     61 
     62