15460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//===- InputFactory.h -----------------------------------------------------===//
25460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//
35460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//                     The MCLinker Project
45460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//
55460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao// This file is distributed under the University of Illinois Open Source
65460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao// License. See LICENSE.TXT for details.
75460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//
85460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//===----------------------------------------------------------------------===//
937b74a387bb3993387029859c2d9d051c41c724eStephen Hines#ifndef MCLD_MC_INPUTFACTORY_H_
1037b74a387bb3993387029859c2d9d051c41c724eStephen Hines#define MCLD_MC_INPUTFACTORY_H_
1137b74a387bb3993387029859c2d9d051c41c724eStephen Hines#include "mcld/MC/Input.h"
1237b74a387bb3993387029859c2d9d051c41c724eStephen Hines#include "mcld/Support/GCFactory.h"
135460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1422add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liaonamespace mcld {
155460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1622add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liaoclass AttributeProxy;
1722add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liaoclass AttributeSet;
1837b74a387bb3993387029859c2d9d051c41c724eStephen Hinesclass LinkerConfig;
195460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
205460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao/** \class InputFactory
215460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao *  \brief InputFactory controls the production and destruction of
225460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao *  MCLDInput.
235460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao *
245460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao *  All MCLDFiles created by MCLDFileFactory are guaranteed to be destructed
255460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao *  while MCLDFileFactory is destructed.
265460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao *
275460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao *  \see llvm::sys::Path
285460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao */
2937b74a387bb3993387029859c2d9d051c41c724eStephen Hinesclass InputFactory : public GCFactory<Input, 0> {
3037b74a387bb3993387029859c2d9d051c41c724eStephen Hines public:
315460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  typedef GCFactory<Input, 0> Alloc;
325460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
3337b74a387bb3993387029859c2d9d051c41c724eStephen Hines public:
3422add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  InputFactory(size_t pNum, const LinkerConfig& pConfig);
3522add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao
365460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  ~InputFactory();
375460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
3822add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  // -----  input  ----- //
395460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  Input* produce(llvm::StringRef pName,
405460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao                 const sys::fs::Path& pPath,
415460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao                 unsigned int pType = Input::Unknown,
425460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao                 off_t pFileOffset = 0);
435460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
4437b74a387bb3993387029859c2d9d051c41c724eStephen Hines  Input* produce(llvm::StringRef pName,
4537b74a387bb3993387029859c2d9d051c41c724eStephen Hines                 const char* pPath,
4637b74a387bb3993387029859c2d9d051c41c724eStephen Hines                 unsigned int pType = Input::Unknown,
4737b74a387bb3993387029859c2d9d051c41c724eStephen Hines                 off_t pFileOffset = 0);
4837b74a387bb3993387029859c2d9d051c41c724eStephen Hines
4922add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  // -----  attributes  ----- //
5022add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  /// attr - the last touched attribute.
5122add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  const AttributeProxy& attr() const { return *m_pLast; }
5237b74a387bb3993387029859c2d9d051c41c724eStephen Hines  AttributeProxy& attr() { return *m_pLast; }
5322add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao
5437b74a387bb3993387029859c2d9d051c41c724eStephen Hines private:
5522add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  AttributeProxy* m_pLast;
5622add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  AttributeSet* m_pAttrSet;
575460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao};
585460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
5937b74a387bb3993387029859c2d9d051c41c724eStephen Hines}  // namespace mcld
605460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
6137b74a387bb3993387029859c2d9d051c41c724eStephen Hines#endif  // MCLD_MC_INPUTFACTORY_H_
62