Newer
Older
Peterson, Peter
committed
#ifndef MANTID_API_ALGORITHMPROXY_H_
#define MANTID_API_ALGORITHMPROXY_H_
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
Gigg, Martyn Anthony
committed
#include "MantidAPI/DllConfig.h"
Peterson, Peter
committed
#include "MantidAPI/IAlgorithm.h"
#include "MantidKernel/PropertyManagerOwner.h"
Gigg, Martyn Anthony
committed
#ifdef _MSC_VER
#pragma warning(disable : 4250) // Disable warning regarding inheritance via
// dominance, we have no way around it with the
// design
Gigg, Martyn Anthony
committed
#endif
//----------------------------------------------------------------------
// Forward Declaration
//----------------------------------------------------------------------
namespace Poco {
template <class R, class A, class O, class S> class ActiveMethod;
template <class O> class ActiveStarter;
class Void;
Russell Taylor
committed
}
Peterson, Peter
committed
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
namespace Mantid {
namespace API {
class Algorithm;
typedef boost::shared_ptr<Algorithm> Algorithm_sptr;
/**
A proxy class that stands between the user and the actual algorithm.
AlgorithmDataService stores algoruithm proxies. Actual algorithms are
created by the proxy and destroyed after execution to free memory.
Algorithm and its proxy share all properties.
@author Russell Taylor, Tessella Support Services plc
@author Based on the Gaudi class of the same name (see
http://proj-gaudi.web.cern.ch/proj-gaudi/)
@date 12/09/2007
@author Roman Tolchenov, Tessella plc
@date 03/03/2009
Copyright © 2007-2010 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge
National Laboratory & European Spallation Source
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://github.com/mantidproject/mantid>.
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class MANTID_API_DLL AlgorithmProxy : public IAlgorithm,
public Kernel::PropertyManagerOwner {
public:
AlgorithmProxy(Algorithm_sptr alg);
virtual ~AlgorithmProxy();
/// The name of the algorithm
const std::string name() const { return m_name; }
/// The version of the algorithm
int version() const { return m_version; }
/// The category of the algorithm
const std::string category() const { return m_category; }
/// Function to return all of the categories that contain this algorithm
const std::vector<std::string> categories() const;
/// Function to return the sperator token for the category string. A default
/// implementation ',' is provided
const std::string categorySeparator() const { return m_categorySeparator; }
/// Aliases to the algorithm
const std::string alias() const { return m_alias; }
/// function returns a summary message that will be displayed in the default
/// GUI, and in the help.
const std::string summary() const { return m_summary; }
/// The algorithmID
AlgorithmID getAlgorithmID() const;
void initialize();
std::map<std::string, std::string> validateInputs();
bool execute();
void executeAsChildAlg() { throw std::runtime_error("Not implemented."); }
Poco::ActiveResult<bool> executeAsync();
bool isInitialized() const;
bool isExecuted() const;
/// To query whether algorithm is a child. A proxy is always at top level,
/// returns false
bool isChild() const { return m_isChild; }
void setAlwaysStoreInADS(const bool) {}
void setChild(const bool val) { m_isChild = val; }
/// Proxies only manage parent algorithms
void enableHistoryRecordingForChild(const bool){};
void setRethrows(const bool rethrow);
const std::string workspaceMethodName() const;
const std::vector<std::string> workspaceMethodOn() const;
const std::string workspaceMethodInputProperty() const;
/** @name PropertyManager methods */
//@{
/// Set the property value
void setPropertyValue(const std::string &name, const std::string &value);
/// Do something after a property was set
void afterPropertySet(const std::string &);
/// Make m_properties point to the same PropertyManager as po.
void copyPropertiesFrom(const PropertyManagerOwner &po);
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
//@}
void cancel();
bool isRunning() const;
void addObserver(const Poco::AbstractObserver &observer) const;
void removeObserver(const Poco::AbstractObserver &observer) const;
/// Set logging on or off
///@param value :: true = logging enabled
void setLogging(const bool value) { m_isLoggingEnabled = value; }
/// Is the algorithm have logging enabled
bool isLogging() const { return m_isLoggingEnabled; }
/// returns the logging priority offset
void setLoggingOffset(const int value) { m_loggingOffset = value; }
/// returns the logging priority offset
int getLoggingOffset() const { return m_loggingOffset; }
/// disable Logging of start and end messages
void setAlgStartupLogging(const bool enabled);
/// get the state of Logging of start and end messages
bool getAlgStartupLogging() const;
/// setting the child start progress
void setChildStartProgress(const double startProgress) const;
/// setting the child end progress
void setChildEndProgress(const double endProgress) const;
/** @name String serialization */
//@{
/// Serialize an object to a string
virtual std::string toString() const;
//@}
private:
/// Private Copy constructor: NO COPY ALLOWED
AlgorithmProxy(const AlgorithmProxy &);
/// Private assignment operator: NO ASSIGNMENT ALLOWED
AlgorithmProxy &operator=(const AlgorithmProxy &);
void createConcreteAlg(bool initOnly = false);
void stopped();
void addObservers();
void dropWorkspaceReferences();
/// Poco::ActiveMethod used to implement asynchronous execution.
Poco::ActiveMethod<bool, Poco::Void, AlgorithmProxy,
Poco::ActiveStarter<AlgorithmProxy>> *m_executeAsync;
/// Execute asynchronous implementation
bool executeAsyncImpl(const Poco::Void &dummy);
const std::string m_name; ///< name of the real algorithm
const std::string m_category; ///< category of the real algorithm
const std::string
m_categorySeparator; ///< category seperator of the real algorithm
const std::string m_alias; ///< alias to the algorithm
const std::string m_summary; ///<Message to display in GUI and help.
const int m_version; ///< version of the real algorithm
mutable boost::shared_ptr<Algorithm>
m_alg; ///< Shared pointer to a real algorithm. Created on demand
bool m_isExecuted; ///< Executed flag
bool m_isLoggingEnabled; ///< is the logging of the underlying algorithm
/// enabled
int m_loggingOffset; ///< the logging priority offset
bool m_isAlgStartupLoggingEnabled; /// Whether to log alg startup and
/// closedown messages from the base class
/// (default = true)
bool m_rethrow; ///< Whether or not to rethrow exceptions.
bool m_isChild; ///< Is this a child algo
/// Temporary holder of external observers wishing to subscribe
mutable std::vector<const Poco::AbstractObserver *> m_externalObservers;
};
} // namespace API
Peterson, Peter
committed
} // namespace Mantid
#endif /*MANTID_API_ALGORITHMPROXY_H_*/