InputFactory.h revision 37b74a387bb3993387029859c2d9d051c41c724e
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/MC/Input.h"
12#include "mcld/Support/GCFactory.h"
13
14namespace mcld {
15
16class AttributeProxy;
17class AttributeSet;
18class LinkerConfig;
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 */
29class InputFactory : public GCFactory<Input, 0> {
30 public:
31  typedef GCFactory<Input, 0> Alloc;
32
33 public:
34  InputFactory(size_t pNum, const LinkerConfig& pConfig);
35
36  ~InputFactory();
37
38  // -----  input  ----- //
39  Input* produce(llvm::StringRef pName,
40                 const sys::fs::Path& pPath,
41                 unsigned int pType = Input::Unknown,
42                 off_t pFileOffset = 0);
43
44  Input* produce(llvm::StringRef pName,
45                 const char* pPath,
46                 unsigned int pType = Input::Unknown,
47                 off_t pFileOffset = 0);
48
49  // -----  attributes  ----- //
50  /// attr - the last touched attribute.
51  const AttributeProxy& attr() const { return *m_pLast; }
52  AttributeProxy& attr() { return *m_pLast; }
53
54 private:
55  AttributeProxy* m_pLast;
56  AttributeSet* m_pAttrSet;
57};
58
59}  // namespace mcld
60
61#endif  // MCLD_MC_INPUTFACTORY_H_
62