Mantid
Loading...
Searching...
No Matches
CatalogFactory.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2013 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 +
7#pragma once
8
9/* Used to register Catalog classes into the factory. creates a global object in
10 *an
11 * anonymous namespace. The object itself does nothing, but the comma operator
12 * is used in the call to its constructor to effect a call to the factory's
13 * subscribe method.
14 *
15 * The second operation that this macro performs is to provide the definition
16 * of the CatalogID method for the concrete Catalog.
17 */
18#define DECLARE_CATALOG(classname) \
19 namespace { \
20 Mantid::Kernel::RegistrationHelper \
21 register_alg_##classname(((Mantid::API::CatalogFactory::Instance().subscribe<classname>(#classname)), 0)); \
22 }
23
24//----------------------------------------------------------------------
25// Includes
26//----------------------------------------------------------------------
27#include "MantidAPI/DllConfig.h"
30
31namespace Mantid {
32namespace API {
33//----------------------------------------------------------------------
34// Forward declaration
35//----------------------------------------------------------------------
36class ICatalog;
37
45class MANTID_API_DLL CatalogFactoryImpl : public Kernel::DynamicFactory<ICatalog> {
46public:
48 CatalogFactoryImpl &operator=(const CatalogFactoryImpl &) = delete;
49
50private:
53 CatalogFactoryImpl() = default;
55 ~CatalogFactoryImpl() override = default;
58 mutable std::map<std::string, std::shared_ptr<ICatalog>> m_createdCatalogs;
59};
60
64
65} // namespace API
66} // namespace Mantid
67
68namespace Mantid {
69namespace Kernel {
70EXTERN_MANTID_API template class MANTID_API_DLL Mantid::Kernel::SingletonHolder<Mantid::API::CatalogFactoryImpl>;
71}
72} // namespace Mantid
The factory is a singleton that hands out shared pointers to the base Catalog class.
~CatalogFactoryImpl() override=default
Private Destructor.
CatalogFactoryImpl(const CatalogFactoryImpl &)=delete
CatalogFactoryImpl()=default
Private Constructor for singleton class.
std::map< std::string, std::shared_ptr< ICatalog > > m_createdCatalogs
Stores pointers to already created Catalog instances, with their name as the key.
The dynamic factory is a base dynamic factory for serving up objects in response to requests from oth...
Manage the lifetime of a class intended to be a singleton.
Helper class which provides the Collimation Length for SANS instruments.
Policy class controlling creation of the singleton Implementation classes should mark their default c...