InputFactory.h revision 5460a1f25d9ddecb5c70667267d66d51af177a99
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 17namespace mcld 18{ 19 20class AttributeFactory; 21 22/** \class InputFactory 23 * \brief InputFactory controls the production and destruction of 24 * MCLDInput. 25 * 26 * All MCLDFiles created by MCLDFileFactory are guaranteed to be destructed 27 * while MCLDFileFactory is destructed. 28 * 29 * FIXME: the number of the Inputs should be passed in by Target or any 30 * target specific class. 31 * 32 * \see llvm::sys::Path 33 */ 34class InputFactory : public GCFactory<Input,0> 35{ 36public: 37 typedef GCFactory<Input, 0> Alloc; 38 39public: 40 InputFactory(size_t pNum, AttributeFactory& pAttrFactory); 41 ~InputFactory(); 42 43 // ----- production ----- // 44 Input* produce(llvm::StringRef pName, 45 const sys::fs::Path& pPath, 46 unsigned int pType = Input::Unknown, 47 off_t pFileOffset = 0); 48 49private: 50 AttributeFactory &m_AttrFactory; 51}; 52 53} // namespace of mcld 54 55#endif 56 57