17using namespace Kernel;
31void createOrUpdateValue(API::Run &run,
const std::string &name,
const std::string &time,
const T
value) {
32 TimeSeriesProperty<T> *timeSeries(
nullptr);
33 if (run.hasProperty(name)) {
34 timeSeries =
dynamic_cast<TimeSeriesProperty<T> *
>(run.getLogData(name));
36 throw std::invalid_argument(
"Log '" + name +
"' already exists but the values are a different type.");
38 timeSeries =
new TimeSeriesProperty<T>(name);
39 run.addProperty(timeSeries);
41 timeSeries->addValue(time,
value);
66 "In/out workspace that will store the new log information");
69 "A string name for either a new time series log to be created "
70 "or an existing name to update",
73 "An ISO formatted date/time string specifying the timestamp for "
74 "the given log value, e.g 2010-09-14T04:20:12",
76 auto nonEmtpyDbl = std::make_shared<MandatoryValidator<double>>();
79 auto optionsValidator = std::make_shared<ListValidator<std::string>>();
80 optionsValidator->addAllowedValue(
"double");
81 optionsValidator->addAllowedValue(
"int");
83 "An optional type for the given value. A double value with a "
85 "the fractional part chopped off.",
87 declareProperty(
"DeleteExisting",
false,
"If true and the named log exists then the whole log is removed first.",
99 const bool deleteExisting =
getProperty(
"DeleteExisting");
100 auto &run = logWS->mutableRun();
101 if (deleteExisting && run.hasProperty(
name))
113 deleter->setProperty(
"Workspace", logWS);
114 deleter->setProperty(
"Name",
name);
115 deleter->executeAsChildAlg();
126 bool asInt = (type ==
"int");
129 createOrUpdateValue<int>(run,
name, time,
static_cast<int>(valueAsDouble));
131 createOrUpdateValue<double>(run,
name, time, valueAsDouble);
#define DECLARE_ALGORITHM(classname)
double value
The value of the point.
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
virtual std::shared_ptr< Algorithm > createChildAlgorithm(const std::string &name, const double startProgress=-1., const double endProgress=-1., const bool enableLogging=true, const int &version=-1)
Create a Child Algorithm.
This class stores information regarding an experimental run as a series of log entries.
A property class for workspaces.
void exec() override
Execute the algorithm.
int version() const override
Algorithm's version for identification.
void init() override
Initialize the algorithm's properties.
const std::string category() const override
Algorithm's category for identification.
void createOrUpdate(API::Run &run, const std::string &name)
Create or update the named log entry.
void removeExisting(API::MatrixWorkspace_sptr &logWS, const std::string &name)
Remove an existing log of the given name.
const std::string name() const override
Algorithm's name for identification.
Validator to check that a property is not left empty.
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
constexpr double EMPTY_DBL() noexcept
Returns what we consider an "empty" double within a property.
@ InOut
Both an input & output workspace.
@ Input
An input workspace.