summaryrefslogtreecommitdiff
path: root/include/mcld/MC/InputFactory.h
blob: 8c73d0b3aa08b64388f3a3b2e51d7262895f05c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//===- InputFactory.h -----------------------------------------------------===//
//
//                     The MCLinker Project
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef MCLD_MC_INPUTFACTORY_H
#define MCLD_MC_INPUTFACTORY_H
#ifdef ENABLE_UNITTEST
#include <gtest.h>
#endif
#include <mcld/Support/GCFactory.h>
#include <mcld/MC/Input.h>

namespace mcld {

class LinkerConfig;
class AttributeProxy;
class AttributeSet;

/** \class InputFactory
 *  \brief InputFactory controls the production and destruction of
 *  MCLDInput.
 *
 *  All MCLDFiles created by MCLDFileFactory are guaranteed to be destructed
 *  while MCLDFileFactory is destructed.
 *
 *  \see llvm::sys::Path
 */
class InputFactory : public GCFactory<Input,0>
{
public:
  typedef GCFactory<Input, 0> Alloc;

public:
  InputFactory(size_t pNum, const LinkerConfig& pConfig);

  ~InputFactory();

  // -----  input  ----- //
  Input* produce(llvm::StringRef pName,
                 const sys::fs::Path& pPath,
                 unsigned int pType = Input::Unknown,
                 off_t pFileOffset = 0);

  // -----  attributes  ----- //
  /// attr - the last touched attribute.
  const AttributeProxy& attr() const { return *m_pLast; }
  AttributeProxy&       attr()       { return *m_pLast; }

private:
  AttributeProxy* m_pLast;
  AttributeSet* m_pAttrSet;
};

} // namespace of mcld

#endif