ContextFactory.cpp revision 5460a1f25d9ddecb5c70667267d66d51af177a99
1//===- ContextFactory.cpp -------------------------------------------------===// 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#include <mcld/LD/LDContext.h> 10#include <mcld/MC/ContextFactory.h> 11 12using namespace mcld; 13 14//===---------------------------------------------------------------------===// 15// LDContextFactory 16ContextFactory::ContextFactory(size_t pNum) 17 : UniqueGCFactoryBase<sys::fs::Path, LDContext, 0>(pNum) 18{ 19} 20 21ContextFactory::~ContextFactory() 22{ 23} 24 25LDContext* ContextFactory::produce(const sys::fs::Path& pPath) 26{ 27 LDContext* result = find(pPath); 28 if (0 == result) { 29 result = UniqueGCFactoryBase<sys::fs::Path, LDContext, 0>::allocate(); 30 new (result) LDContext(); 31 f_KeyMap.insert(std::make_pair(pPath, result)); 32 } 33 return result; 34} 35 36