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