Mantid
Loading...
Searching...
No Matches
DeleteLog.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 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 +
9#include "MantidAPI/Run.h"
11
12namespace Mantid::Algorithms {
13using namespace API;
14using namespace Kernel;
15
16// Register the algorithm into the AlgorithmFactory
17DECLARE_ALGORITHM(DeleteLog)
18
19
20const std::string DeleteLog::name() const { return "DeleteLog"; }
21
23int DeleteLog::version() const { return 1; }
24
26const std::string DeleteLog::category() const { return "DataHandling\\Logs"; }
27
31 declareProperty(std::make_unique<WorkspaceProperty<>>("Workspace", "", Direction::InOut),
32 "In/out workspace containing the logs. The workspace is "
33 "modified in place");
34 declareProperty("Name", "", std::make_shared<MandatoryValidator<std::string>>(), "", Direction::Input);
35}
36
40 MatrixWorkspace_sptr logWS = getProperty("Workspace");
41 std::string logName = getProperty("Name");
42 auto &run = logWS->mutableRun();
43 if (run.hasProperty(logName)) {
44 run.removeLogData(logName);
45 } else {
46 g_log.warning() << "Unable to delete log '" << logName << "' from the given workspace as it does not exist.\n";
47 }
48}
49
50} // namespace Mantid::Algorithms
#define DECLARE_ALGORITHM(classname)
Definition: Algorithm.h:576
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
Definition: Algorithm.cpp:1913
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
Definition: Algorithm.cpp:2076
Kernel::Logger & g_log
Definition: Algorithm.h:451
A property class for workspaces.
void exec() override
Execute the algorithm.
Definition: DeleteLog.cpp:39
const std::string category() const override
function to return a category of the algorithm.
Definition: DeleteLog.cpp:26
int version() const override
function to return a version of the algorithm, must be overridden in all algorithms
Definition: DeleteLog.cpp:23
void init() override
Initialize the algorithm's properties.
Definition: DeleteLog.cpp:30
void warning(const std::string &msg)
Logs at warning level.
Definition: Logger.cpp:86
Validator to check that a property is not left empty.
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
STL namespace.
@ InOut
Both an input & output workspace.
Definition: Property.h:55
@ Input
An input workspace.
Definition: Property.h:53