Mantid
Loading...
Searching...
No Matches
MDTransfFactory.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
8
9namespace Mantid::MDAlgorithms {
10
18std::shared_ptr<MDTransfInterface> MDTransfFactoryImpl::create(const std::string &className) const {
19 std::map<std::string, std::shared_ptr<MDTransfInterface>>::const_iterator it = m_createdTransf.find(className);
20 if (it != m_createdTransf.end()) {
21 // If an instance has previously been created, just return a pointer to it
22 return it->second;
23 } else {
24 // Otherwise create & return a new instance and store the pointer in the
25 // internal map for next time
27 }
28}
29
30} // namespace Mantid::MDAlgorithms
virtual std::shared_ptr< Base > create(const std::string &className) const
Creates a new instance of the class with the given name.
std::map< std::string, std::shared_ptr< MDTransfInterface > > m_createdTransf
Stores pointers to already created unit instances, with their name as the key.
std::shared_ptr< MDTransfInterface > create(const std::string &className) const override
Returns an instance of the class with the given name.