Commit d34ba77e authored by Tom Perkins's avatar Tom Perkins
Browse files

Change declareProperty calls in DataHandling to use unique_ptrs

re #15289
parent 24fad3f8
......@@ -59,14 +59,15 @@ void AppendGeometryToSNSNexus::init() {
// Declare potential extensions for input NeXus file
std::vector<std::string> extensions{".nxs", ".h5"};
declareProperty(new API::FileProperty("Filename", "", API::FileProperty::Load,
extensions),
declareProperty(Kernel::make_unique<API::FileProperty>(
"Filename", "", API::FileProperty::Load, extensions),
"The name of the NeXus file to append geometry to.");
// TODO: change MakeCopy default to False when comfortable. Otherwise need to
// remove the extra copy once in production.
declareProperty(
new PropertyWithValue<bool>("MakeCopy", true, Direction::Input),
Kernel::make_unique<PropertyWithValue<bool>>("MakeCopy", true,
Direction::Input),
"Copy the NeXus file first before appending (optional, default True).");
}
......
......@@ -25,10 +25,11 @@ using namespace API;
/// Initialisation method.
void AsciiPointBase::init() {
declareProperty(
new WorkspaceProperty<>("InputWorkspace", "", Direction::Input),
make_unique<WorkspaceProperty<>>("InputWorkspace", "", Direction::Input),
"The name of the workspace containing the data you want to save.");
declareProperty(new FileProperty("Filename", "", FileProperty::Save, {ext()}),
declareProperty(Kernel::make_unique<FileProperty>("Filename", "",
FileProperty::Save, ext()),
"The filename of the output file.");
extraProps();
}
......
......@@ -27,20 +27,20 @@ CompressEvents::~CompressEvents() {}
void CompressEvents::init() {
declareProperty(
new WorkspaceProperty<EventWorkspace>("InputWorkspace", "",
Direction::Input),
make_unique<WorkspaceProperty<EventWorkspace>>("InputWorkspace", "",
Direction::Input),
"The name of the EventWorkspace on which to perform the algorithm");
declareProperty(new WorkspaceProperty<EventWorkspace>("OutputWorkspace", "",
Direction::Output),
declareProperty(make_unique<WorkspaceProperty<EventWorkspace>>(
"OutputWorkspace", "", Direction::Output),
"The name of the output EventWorkspace.");
// Tolerance must be >= 0.0
auto mustBePositive = boost::make_shared<BoundedValidator<double>>();
mustBePositive->setLower(0.0);
declareProperty(
new PropertyWithValue<double>("Tolerance", 1e-5, mustBePositive,
Direction::Input),
make_unique<PropertyWithValue<double>>("Tolerance", 1e-5, mustBePositive,
Direction::Input),
"The tolerance on each event's X value (normally TOF, but may be a "
"different unit if you have used ConvertUnits).\n"
"Any events within Tolerance will be summed into a single event.");
......
......@@ -38,7 +38,8 @@ const std::string CreateChopperModel::category() const {
/** Initialize the algorithm's properties.
*/
void CreateChopperModel::init() {
declareProperty(new WorkspaceProperty<>("Workspace", "", Direction::InOut),
declareProperty(Kernel::make_unique<WorkspaceProperty<>>("Workspace", "",
Direction::InOut),
"An workspace to attach the model");
std::vector<std::string> keys(1, "FermiChopperModel");
......
......@@ -83,24 +83,27 @@ void CreateChunkingFromInstrument::init() {
// instrument selection
string grp1Name("Specify the Instrument");
std::vector<std::string> extensions{"_event.nxs", ".nxs.h5", ".nxs"};
this->declareProperty(
new FileProperty(PARAM_IN_FILE, "", FileProperty::OptionalLoad,
{"_event.nxs", ".nxs.h5", ".nxs"}),
Kernel::make_unique<FileProperty>(PARAM_IN_FILE, "",
FileProperty::OptionalLoad, extensions),
"The name of the event nexus file to read, including its full or "
"relative path.");
this->declareProperty(
new WorkspaceProperty<>(PARAM_IN_WKSP, "", Direction::Input,
PropertyMode::Optional),
Kernel::make_unique<WorkspaceProperty<>>(
PARAM_IN_WKSP, "", Direction::Input, PropertyMode::Optional),
"Optional: An input workspace with the instrument we want to use.");
this->declareProperty(
new PropertyWithValue<string>(PARAM_INST_NAME, "", Direction::Input),
Kernel::make_unique<PropertyWithValue<string>>(PARAM_INST_NAME, "",
Direction::Input),
"Optional: Name of the instrument to base the ChunkingWorkpace on which "
"to base the GroupingWorkspace.");
this->declareProperty(
new FileProperty(PARAM_INST_FILE, "", FileProperty::OptionalLoad, ".xml"),
Kernel::make_unique<FileProperty>(PARAM_INST_FILE, "",
FileProperty::OptionalLoad, ".xml"),
"Optional: Path to the instrument definition file on which to base the "
"ChunkingWorkpace.");
......@@ -132,7 +135,7 @@ void CreateChunkingFromInstrument::init() {
declareProperty(PARAM_MAX_BANK_NUM, 300,
"Maximum bank number to search for in the instrument");
declareProperty(new WorkspaceProperty<API::ITableWorkspace>(
declareProperty(Kernel::make_unique<WorkspaceProperty<API::ITableWorkspace>>(
PARAM_OUT_WKSP, "", Direction::Output),
"An output workspace describing the cunking.");
}
......
......@@ -36,7 +36,8 @@ const std::string CreateModeratorModel::category() const {
/** Initialize the algorithm's properties.
*/
void CreateModeratorModel::init() {
declareProperty(new WorkspaceProperty<>("Workspace", "", Direction::InOut),
declareProperty(Kernel::make_unique<WorkspaceProperty<>>("Workspace", "",
Direction::InOut),
"An input workspace.");
std::vector<std::string> keys(1, "IkedaCarpenterModerator");
......
......@@ -20,8 +20,8 @@ using namespace Mantid::API;
*/
void CreateSampleShape::init() {
using namespace Mantid::Kernel;
declareProperty(new WorkspaceProperty<MatrixWorkspace>("InputWorkspace", "",
Direction::Input),
declareProperty(make_unique<WorkspaceProperty<MatrixWorkspace>>(
"InputWorkspace", "", Direction::Input),
"The workspace with which to associate the sample ");
declareProperty("ShapeXML", "",
boost::make_shared<MandatoryValidator<std::string>>(),
......
......@@ -54,24 +54,24 @@ void CreateSimulationWorkspace::init() {
"containing an xml extension).",
Direction::Input);
declareProperty(new ArrayProperty<double>(
declareProperty(make_unique<ArrayProperty<double>>(
"BinParams", boost::make_shared<RebinParamsValidator>(),
Direction::Input),
"A comma separated list of first bin boundary, width, last "
"bin boundary. See Rebin for more details");
declareProperty(
new WorkspaceProperty<>("OutputWorkspace", "", Direction::Output),
"The new workspace");
declareProperty(make_unique<WorkspaceProperty<>>("OutputWorkspace", "",
Direction::Output),
"The new workspace");
auto knownUnits = UnitFactory::Instance().getKeys();
declareProperty("UnitX", "DeltaE",
boost::make_shared<ListValidator<std::string>>(knownUnits),
"The unit to assign to the X axis", Direction::Input);
declareProperty(new FileProperty("DetectorTableFilename", "",
FileProperty::OptionalLoad, "",
Direction::Input),
declareProperty(make_unique<FileProperty>("DetectorTableFilename", "",
FileProperty::OptionalLoad, "",
Direction::Input),
"An optional filename (currently RAW or ISIS NeXus) that "
"contains UDET & SPEC tables to access hardware grouping");
}
......
......@@ -19,7 +19,8 @@ DECLARE_ALGORITHM(DefineGaugeVolume)
*/
void DefineGaugeVolume::init() {
declareProperty(
new WorkspaceProperty<>("Workspace", "", Kernel::Direction::InOut),
Kernel::make_unique<WorkspaceProperty<>>("Workspace", "",
Kernel::Direction::InOut),
"The workspace with which to associate the defined gauge volume");
declareProperty("ShapeXML", "",
boost::make_shared<Kernel::MandatoryValidator<std::string>>(),
......
......@@ -20,11 +20,11 @@ using namespace API;
/// Initialisation method.
void DeleteTableRows::init() {
declareProperty(new WorkspaceProperty<API::ITableWorkspace>(
declareProperty(make_unique<WorkspaceProperty<API::ITableWorkspace>>(
"TableWorkspace", "", Direction::InOut),
"The name of the workspace that will be modified.");
declareProperty(
new ArrayProperty<size_t>("Rows"),
make_unique<ArrayProperty<size_t>>("Rows"),
"A comma-separated list of row numbers. Row numbering starts with 0.");
}
......
......@@ -92,7 +92,8 @@ void DetermineChunking::init() {
exts_set.insert(RAW_EXT, RAW_EXT + NUM_EXT_RAW);
std::vector<std::string> exts(exts_set.begin(), exts_set.end());
this->declareProperty(
new FileProperty("Filename", "", FileProperty::Load, exts),
Kernel::make_unique<FileProperty>("Filename", "", FileProperty::Load,
exts),
"The name of the event nexus, runinfo.xml, raw, or histo nexus file to "
"read, including its full or relative path. The Event NeXus file name is "
"typically of the form INST_####_event.nxs (N.B. case sensitive if "
......@@ -104,7 +105,7 @@ void DetermineChunking::init() {
"Get chunking strategy for chunks with this number of "
"Gbytes. File will not be loaded if this option is set.");
declareProperty(new WorkspaceProperty<API::ITableWorkspace>(
declareProperty(make_unique<WorkspaceProperty<API::ITableWorkspace>>(
"OutputWorkspace", "", Direction::Output),
"An output workspace.");
}
......
......@@ -57,8 +57,9 @@ void DownloadFile::init() {
declareProperty(
"Address", "", boost::make_shared<MandatoryValidator<std::string>>(),
"The address of the network resource to download.", Direction::InOut);
declareProperty(new FileProperty("Filename", "", FileProperty::Save),
"The filename to save the download to.");
declareProperty(
Kernel::make_unique<FileProperty>("Filename", "", FileProperty::Save),
"The filename to save the download to.");
}
//----------------------------------------------------------------------------------------------
......
......@@ -36,10 +36,11 @@ const std::string ExtractMonitorWorkspace::summary() const {
*/
void ExtractMonitorWorkspace::init() {
declareProperty(
new WorkspaceProperty<>("InputWorkspace", "", Direction::Input),
make_unique<WorkspaceProperty<>>("InputWorkspace", "", Direction::Input),
"A data workspace that holds a monitor workspace within.");
declareProperty(
new WorkspaceProperty<>("MonitorWorkspace", "", Direction::Output),
make_unique<WorkspaceProperty<>>("MonitorWorkspace", "",
Direction::Output),
"The workspace containing only monitor data relating to the main data in "
"the InputWorkspace.");
declareProperty(
......
......@@ -255,23 +255,25 @@ void FilterEventsByLogValuePreNexus::init() {
// File files to use
vector<string> eventExts(EVENT_EXTS, EVENT_EXTS + NUM_EXT);
declareProperty(
new FileProperty(EVENT_PARAM, "", FileProperty::Load, eventExts),
Kernel::make_unique<FileProperty>(EVENT_PARAM, "", FileProperty::Load,
eventExts),
"The name of the neutron event file to read, including its full or "
"relative path. In most cases, the file typically ends in "
"neutron_event.dat (N.B. case sensitive if running on Linux).");
vector<string> pulseExts(PULSE_EXTS, PULSE_EXTS + NUM_EXT);
declareProperty(new FileProperty(PULSEID_PARAM, "",
FileProperty::OptionalLoad, pulseExts),
declareProperty(Kernel::make_unique<FileProperty>(
PULSEID_PARAM, "", FileProperty::OptionalLoad, pulseExts),
"File containing the accelerator pulse information; the "
"filename will be found automatically if not specified.");
declareProperty(
new FileProperty(MAP_PARAM, "", FileProperty::OptionalLoad, ".dat"),
Kernel::make_unique<FileProperty>(MAP_PARAM, "",
FileProperty::OptionalLoad, ".dat"),
"File containing the pixel mapping (DAS pixels to pixel IDs) file "
"(typically INSTRUMENT_TS_YYYY_MM_DD.dat). The filename will be found "
"automatically if not specified.");
// Pixels to load
declareProperty(new ArrayProperty<int64_t>(PID_PARAM),
declareProperty(Kernel::make_unique<ArrayProperty<int64_t>>(PID_PARAM),
"A list of individual spectra (pixel IDs) to read, specified "
"as e.g. 10:20. Only used if set.");
......@@ -301,12 +303,13 @@ void FilterEventsByLogValuePreNexus::init() {
// the output workspace name
declareProperty(
new WorkspaceProperty<IEventWorkspace>(OUT_PARAM, "", Direction::Output),
Kernel::make_unique<WorkspaceProperty<IEventWorkspace>>(
OUT_PARAM, "", Direction::Output),
"The name of the workspace that will be created, filled with the read-in "
"data and stored in the [[Analysis Data Service]].");
// Optional output table workspace
declareProperty(new WorkspaceProperty<ITableWorkspace>(
declareProperty(Kernel::make_unique<WorkspaceProperty<ITableWorkspace>>(
"EventLogTableWorkspace", "", PropertyMode::Optional),
"Optional output table workspace containing the event log "
"(pixel) information. ");
......@@ -323,11 +326,11 @@ void FilterEventsByLogValuePreNexus::init() {
declareProperty("NumberOfEventsToExamine", EMPTY_INT(),
"Number of events on the pixel ID to get examined. ");
declareProperty(new ArrayProperty<int>("LogPixelIDs"),
declareProperty(Kernel::make_unique<ArrayProperty<int>>("LogPixelIDs"),
"Pixel IDs for event log. Must have 2 (or more) entries. ");
declareProperty(
new ArrayProperty<std::string>("LogPIxelTags"),
Kernel::make_unique<ArrayProperty<std::string>>("LogPIxelTags"),
"Pixel ID tags for event log. Must have same items as 'LogPixelIDs'. ");
declareProperty("AcceleratorFrequency", 60, "Freuqency of the accelerator at "
......@@ -410,7 +413,7 @@ void FilterEventsByLogValuePreNexus::exec() {
// Save output
setProperty<IEventWorkspace_sptr>(OUT_PARAM, m_localWorkspace);
if (m_functionMode == "Filter") {
declareProperty(new WorkspaceProperty<IEventWorkspace>(
declareProperty(Kernel::make_unique<WorkspaceProperty<IEventWorkspace>>(
"OutputFilteredWorkspace", "WS_A", Direction::Output),
"");
setProperty<IEventWorkspace_sptr>("OutputFilteredWorkspace",
......
......@@ -31,9 +31,9 @@ FindDetectorsInShape::FindDetectorsInShape() {}
FindDetectorsInShape::~FindDetectorsInShape() {}
void FindDetectorsInShape::init() {
declareProperty(
new WorkspaceProperty<MatrixWorkspace>("Workspace", "", Direction::Input),
"Name of the input workspace");
declareProperty(make_unique<WorkspaceProperty<MatrixWorkspace>>(
"Workspace", "", Direction::Input),
"Name of the input workspace");
declareProperty("ShapeXML", "",
boost::make_shared<MandatoryValidator<std::string>>(),
"The XML definition of the shape");
......
......@@ -38,8 +38,8 @@ void FindDetectorsPar::init() {
wsValidator->add<API::CommonBinsValidator>();
// input workspace
declareProperty(
new WorkspaceProperty<>("InputWorkspace", "", Direction::Input,
wsValidator),
make_unique<WorkspaceProperty<>>("InputWorkspace", "", Direction::Input,
wsValidator),
"The name of the workspace that will be used as input for the algorithm");
//
declareProperty("ReturnLinearRanges", false,
......@@ -47,12 +47,11 @@ void FindDetectorsPar::init() {
"detector's ranges (dx,dy) rather then angular ranges "
"(dAzimuthal,dPolar)");
// optional par or phx file
std::vector<std::string> fileExts(2);
fileExts[0] = ".par";
fileExts[1] = ".phx";
const std::vector<std::string> fileExts{".par", ".phx"};
declareProperty(new FileProperty("ParFile", "not_used.par",
FileProperty::OptionalLoad, fileExts),
declareProperty(Kernel::make_unique<FileProperty>("ParFile", "not_used.par",
FileProperty::OptionalLoad,
fileExts),
"An optional file that contains of the list of angular "
"parameters for the detectors and detectors groups;\n"
"If specified, will use data from file instead of the data, "
......@@ -157,7 +156,7 @@ void FindDetectorsPar::setOutputTable() {
return;
// Store the result in a table workspace
try {
declareProperty(new WorkspaceProperty<API::ITableWorkspace>(
declareProperty(make_unique<WorkspaceProperty<API::ITableWorkspace>>(
"OutputParTableWS", "", Direction::Output));
} catch (std::exception &err) {
g_log.information() << " findDetecotorsPar: unsuccessfully declaring "
......
......@@ -69,14 +69,15 @@ const std::string GenerateGroupingPowder::category() const {
*/
void GenerateGroupingPowder::init() {
declareProperty(
new WorkspaceProperty<>("InputWorkspace", "", Direction::Input),
make_unique<WorkspaceProperty<>>("InputWorkspace", "", Direction::Input),
"An input workspace.");
auto positiveDouble = boost::make_shared<BoundedValidator<double>>();
positiveDouble->setLower(0.0);
declareProperty("AngleStep", -1.0, positiveDouble,
"The angle step for grouping");
declareProperty(
new FileProperty("GroupingFilename", "", FileProperty::Save, ".xml"),
make_unique<FileProperty>("GroupingFilename", "", FileProperty::Save,
".xml"),
"A grouping file that will be created. The corresponding .par file will "
"be created as well.");
}
......
......@@ -24,21 +24,22 @@ GroupDetectors::~GroupDetectors() {}
void GroupDetectors::init() {
declareProperty(
new WorkspaceProperty<>("Workspace", "", Direction::InOut,
boost::make_shared<CommonBinsValidator>()),
make_unique<WorkspaceProperty<>>(
"Workspace", "", Direction::InOut,
boost::make_shared<CommonBinsValidator>()),
"The name of the workspace2D on which to perform the algorithm");
declareProperty(
new ArrayProperty<specid_t>("SpectraList"),
make_unique<ArrayProperty<specid_t>>("SpectraList"),
"An array containing a list of the indexes of the spectra to combine\n"
"(DetectorList and WorkspaceIndexList are ignored if this is set)");
declareProperty(
new ArrayProperty<detid_t>("DetectorList"),
make_unique<ArrayProperty<detid_t>>("DetectorList"),
"An array of detector ID's (WorkspaceIndexList is ignored if this is\n"
"set)");
declareProperty(new ArrayProperty<size_t>("WorkspaceIndexList"),
declareProperty(make_unique<ArrayProperty<size_t>>("WorkspaceIndexList"),
"An array of workspace indices to combine");
declareProperty("ResultIndex", -1,
......
......@@ -39,17 +39,18 @@ const double GroupDetectors2::OPENINGFILE = 0.03;
const double GroupDetectors2::READFILE = 0.15;
void GroupDetectors2::init() {
declareProperty(new WorkspaceProperty<MatrixWorkspace>(
declareProperty(make_unique<WorkspaceProperty<MatrixWorkspace>>(
"InputWorkspace", "", Direction::Input,
boost::make_shared<CommonBinsValidator>()),
"The name of the input 2D workspace");
declareProperty(new WorkspaceProperty<MatrixWorkspace>("OutputWorkspace", "",
Direction::Output),
declareProperty(make_unique<WorkspaceProperty<MatrixWorkspace>>(
"OutputWorkspace", "", Direction::Output),
"The name of the output workspace");
const std::vector<std::string> exts{".map", ".xml"};
declareProperty(
new FileProperty("MapFile", "", FileProperty::OptionalLoad,
{".map", ".xml"}),
Kernel::make_unique<FileProperty>("MapFile", "",
FileProperty::OptionalLoad, exts),
"A file that consists of lists of spectra numbers to group. See the "
"help\n"
"for the file format");
......@@ -58,19 +59,19 @@ void GroupDetectors2::init() {
"This option is only relevant if you're using MapFile.\n"
"If true the spectra will numbered sequentially, starting from one.\n"
"Otherwise, the group number will be used for the spectrum numbers.");
declareProperty(new PropertyWithValue<std::string>("GroupingPattern", "",
Direction::Input),
declareProperty(make_unique<PropertyWithValue<std::string>>(
"GroupingPattern", "", Direction::Input),
"Describes how this algorithm should group the detectors. "
"See full instruction list.");
declareProperty(
new ArrayProperty<specid_t>("SpectraList"),
make_unique<ArrayProperty<specid_t>>("SpectraList"),
"An array containing a list of the spectrum numbers to combine\n"
"(DetectorList and WorkspaceIndexList are ignored if this is set)");
declareProperty(new ArrayProperty<detid_t>("DetectorList"),
declareProperty(make_unique<ArrayProperty<detid_t>>("DetectorList"),
"An array of detector IDs to combine (WorkspaceIndexList is "
"ignored if this is\n"
"set)");
declareProperty(new ArrayProperty<size_t>("WorkspaceIndexList"),
declareProperty(make_unique<ArrayProperty<size_t>>("WorkspaceIndexList"),
"An array of workspace indices to combine");
declareProperty(
"KeepUngroupedSpectra", false,
......@@ -89,9 +90,9 @@ void GroupDetectors2::init() {
"EventWorkspace, if the input has "
"events.");
declareProperty(
new WorkspaceProperty<MatrixWorkspace>("CopyGroupingFromWorkspace", "",
Direction::Input,
PropertyMode::Optional),
make_unique<WorkspaceProperty<MatrixWorkspace>>(
"CopyGroupingFromWorkspace", "", Direction::Input,
PropertyMode::Optional),
"The name of a workspace to copy the grouping from.\n "
"This can be either a normal workspace or a grouping workspace, but they "
"must be from the same instrument.\n"
......
......@@ -259,10 +259,10 @@ void Load::declareLoaderProperties(const API::IAlgorithm_sptr &loader) {
if (loadProp->name() == m_filenamePropName)
continue;
try {
Property *propClone = loadProp->clone();
auto propClone = std::unique_ptr<Property>(loadProp->clone());
propClone->deleteSettings(); // Get rid of special settings because it
// does not work in custom GUI.
declareProperty(propClone, loadProp->documentation());
declareProperty(std::move(propClone), loadProp->documentation());
} catch (Exception::ExistsError &) {
// Already exists as a static property
continue;
......@@ -290,13 +290,13 @@ void Load::init() {
exts.emplace_back(".fits");
declareProperty(
new MultipleFileProperty("Filename", exts),
Kernel::make_unique<MultipleFileProperty>("Filename", exts),
"The name of the file(s) to read, including the full or relative "
"path. (N.B. case sensitive if running on Linux). Multiple runs "
"can be loaded and added together, e.g. INST10,11+12,13.ext");
declareProperty(
new WorkspaceProperty<Workspace>("OutputWorkspace", "",
Direction::Output),
Kernel::make_unique<WorkspaceProperty<Workspace>>("OutputWorkspace", "",
Direction::Output),
"The name of the workspace that will be created, filled with the "
"read-in data and stored in the Analysis Data Service. Some algorithms "
"can created additional OutputWorkspace properties on the fly, e.g. "
......@@ -457,7 +457,7 @@ void Load::loadMultipleFiles() {
std::string outWsPropName =
"OutputWorkspace_" + boost::lexical_cast<std::string>(count);
++count;
declareProperty(new WorkspaceProperty<Workspace>(
declareProperty(Kernel::make_unique<WorkspaceProperty<Workspace>>(
outWsPropName, childWsName, Direction::Output));
setProperty(outWsPropName, childWs);
}
......@@ -545,7 +545,7 @@ void Load::setOutputWorkspace(const API::IAlgorithm_sptr &loader) {
prop->direction() == Direction::Output) {
const std::string &name = prop->name();
if (!this->existsProperty(name)) {
declareProperty(new WorkspaceProperty<Workspace>(
declareProperty(Kernel::make_unique<WorkspaceProperty<Workspace>>(
name, loader->getPropertyValue(name), Direction::Output));
}
Workspace_sptr wkspace = getOutputWorkspace(name, loader);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment