STIR  6.2.0
FactoryRegistry.h
Go to the documentation of this file.
1 //
2 //
12 /*
13  Copyright (C) 2001- 2009, Hammersmith Imanet Ltd
14  This file is part of STIR.
15 
16  SPDX-License-Identifier: Apache-2.0
17 
18  See STIR/LICENSE.txt for details
19 */
20 
21 #ifndef __stir_FactoryRegistry_H__
22 #define __stir_FactoryRegistry_H__
23 
24 #include "stir/common.h"
25 #include <iostream>
26 #include <map>
27 #include <functional>
28 
29 START_NAMESPACE_STIR
30 
51 template <typename Key, typename Factory, typename Compare = std::less<Key>>
53 {
54 
55 public:
56  // sadly, all of these have to be inline to prevent problems
57  // with instantiation
58 
60  inline FactoryRegistry();
65  inline FactoryRegistry(const Key& default_key, const Factory& default_factory);
66 
67  inline ~FactoryRegistry();
68 
74  inline void add_to_registry(const Key& key, Factory const& factory);
75 
77  inline void remove_from_registry(const Key& key);
78 
80  inline void list_keys(std::ostream& s) const;
81 
83 
89  inline Factory const& find_factory(const Key& key) const;
90 
91 private:
92  typedef std::map<Key, Factory, Compare> FactoryMap;
93  FactoryMap m;
94  const bool has_defaults;
95  const Key default_key;
96  const Factory default_factory;
97 };
98 
99 END_NAMESPACE_STIR
100 
101 #include "stir/FactoryRegistry.inl"
102 
103 #endif
Inline implementations for stir::FactoryRegistry.
This class can be used to store &#39;factories&#39; and their corresponding keys. It is essentially a map...
Definition: FactoryRegistry.h:52
basic configuration include file