Newer
Older
Dickon Champion
committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#ifndef ALGORITHMMANAGER_H_
#define ALGORITHMMANAGER_H_
/* Used to register classes into the factory. creates a global object in an
* anonymous namespace. The object itself does nothing, but the comma operator
* is used in the call to its constructor to effect a call to the factory's
* subscribe method.
*/
#define DECLARE_ALGORITHM(classname) \
namespace { \
Mantid::RegistrationHelper register_alg_##classname( \
((Mantid::AlgorithmManager::Instance()->subscribe<Mantid::classname>(#classname)) \
, 0)); \
}
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "AlgorithmFactory.h"
#include <vector>
namespace Mantid
{
//----------------------------------------------------------------------
// Forward declarations
//----------------------------------------------------------------------
/** @class AlgorithmManager AlgorithmManager.h Kernel/AlgorithmManager.h
The Algorithm Manager class is responsible for controlling algorithm
instances. It provides a facade for the factory, it initializes and
finalizes algorithms.
@author Dickon Champion, ISIS, RAL
@date 30/10/2007
Copyright © 2007 ???RAL???
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid>
*/
class DLLExport AlgorithmManager : public AlgorithmFactory
{
public:
/** A static method which retrieves the single instance of the Algorithm Manager
*
* @returns A pointer to the Algorithm Manager instance
*/
static AlgorithmManager* Instance();
/** Creates an instance of an algorithm
*
* @param algName The name of the algorithm required
* @return A pointer to the created algorithm
*
* @throw runtime_error Thrown if algorithm requested is not registered
*/
IAlgorithm* createAlgorithm(const std::string& algName);
/// finalizes and deletes all registered algorithms
void clear();
private:
/// Private Constructor for singleton class
AlgorithmManager();
/** Private destructor
* Prevents client from calling 'delete' on the pointer handed
* out by Instance
*/
virtual ~AlgorithmManager();
///static reference to the logger class
static Logger& g_log;
/// internal counter of registered algorithms
static int m_no_of_alg;
/// vector containing pointers to registered algorithms
std::vector<IAlgorithm*> list;
/// Pointer to the Algorithm Manager instance
static AlgorithmManager* m_instance;
};
} //Namespace Mantid
#endif /* ALGORITHMMANAGER_H_ */