Commit 7d98ff91 authored by Hahn, Steven's avatar Hahn, Steven
Browse files

When possible, use initializer lists instead of emplace.

parent 321a2357
......@@ -163,10 +163,7 @@ NotebookBuilder::buildPropertyString(PropertyHistory_const_sptr propHistory) {
using Mantid::Kernel::Direction;
// Create a vector of all non workspace property type names
std::vector<std::string> nonWorkspaceTypes;
nonWorkspaceTypes.emplace_back("number");
nonWorkspaceTypes.emplace_back("boolean");
nonWorkspaceTypes.emplace_back("string");
std::vector<std::string> nonWorkspaceTypes{"number", "boolean", "string"};
std::string prop = "";
// No need to specify value for default properties
......
......@@ -190,10 +190,7 @@ ScriptBuilder::buildPropertyString(PropertyHistory_const_sptr propHistory) {
using Mantid::Kernel::Direction;
// Create a vector of all non workspace property type names
std::vector<std::string> nonWorkspaceTypes;
nonWorkspaceTypes.emplace_back("number");
nonWorkspaceTypes.emplace_back("boolean");
nonWorkspaceTypes.emplace_back("string");
std::vector<std::string> nonWorkspaceTypes{"number", "boolean", "string"};
std::string prop = "";
// No need to specify value for default properties
......
......@@ -140,9 +140,7 @@ public:
TS_ASSERT_EQUALS(alg->name(), "ToyAlgorithmProxyMultipleCategory");
TS_ASSERT_EQUALS(alg->version(), 1);
TS_ASSERT_EQUALS(alg->category(), "ProxyCat;ProxyLeopard");
std::vector<std::string> result;
result.emplace_back("ProxyCat");
result.emplace_back("ProxyLeopard");
std::vector<std::string> result{"ProxyCat", "ProxyLeopard"};
TS_ASSERT_EQUALS(alg->categories(), result);
TS_ASSERT_EQUALS(alg->alias(), "Dog");
TS_ASSERT(alg->isInitialized());
......
......@@ -190,8 +190,7 @@ public:
}
void testCategories() {
std::vector<std::string> result;
result.emplace_back("Cat");
std::vector<std::string> result{"Cat"};
TS_ASSERT_EQUALS(alg.categories(), result);
result.emplace_back("Leopard");
result.emplace_back("Mink");
......
......@@ -128,11 +128,7 @@ public:
}
void testOperators() {
std::vector<std::string> ops;
ops.emplace_back(",");
ops.emplace_back("=");
Expression expr(ops);
Expression expr({",", "="});
TS_ASSERT_THROWS_NOTHING(expr.parse("x=-1\"(2)\",y=2a+b*(x+y) "));
TS_ASSERT_EQUALS(expr[0][1].name(), "-1\"(2)\"");
......@@ -174,11 +170,8 @@ public:
TS_ASSERT_EQUALS(e4[0].name(), "x");
TS_ASSERT_EQUALS(e4[1].name(), "+");
std::vector<std::string> bin_ops;
bin_ops.emplace_back("=");
std::set<std::string> un_ops;
un_ops.insert("!");
un_ops.insert("%%");
std::vector<std::string> bin_ops{"="};
std::set<std::string> un_ops{"!", "%%"};
Expression e5(bin_ops, un_ops);
TS_ASSERT_THROWS_NOTHING(e5.parse("x=!1"));
......@@ -212,11 +205,8 @@ public:
TS_ASSERT_EQUALS(e8[0].name(), "x");
TS_ASSERT_EQUALS(e8[1].name(), "%%");
std::vector<std::string> bin_ops1;
bin_ops1.emplace_back("==");
std::set<std::string> un_ops1;
un_ops1.insert("!");
un_ops1.insert("%%");
std::vector<std::string> bin_ops1{"=="};
std::set<std::string> un_ops1{"!", "%%"};
Expression e9(bin_ops1, un_ops1);
TS_ASSERT_THROWS_NOTHING(e9.parse("x==!1"));
......@@ -256,12 +246,8 @@ public:
Expression e14(bin_ops1, un_ops1);
TS_ASSERT_THROWS(e14.parse("x==%% "), std::runtime_error);
std::vector<std::string> bin_ops2;
bin_ops2.emplace_back("-");
bin_ops2.emplace_back("--");
std::set<std::string> un_ops2;
un_ops2.insert("-");
un_ops2.insert("--");
std::vector<std::string> bin_ops2{"-", "--"};
std::set<std::string> un_ops2{"-", "--"};
Expression e15(bin_ops2, un_ops2);
TS_ASSERT_THROWS_NOTHING(e15.parse("x--1"));
......
......@@ -244,10 +244,7 @@ public:
}
void testGetExtension() {
std::vector<std::string> exts;
exts.emplace_back("_event.nxs");
exts.emplace_back(".nxs.h5");
exts.emplace_back(".n*");
std::vector<std::string> exts{"_event.nxs", ".nxs.h5", ".n*"};
TS_ASSERT_EQUALS(FileFinder::Instance().getExtension("", exts), "");
TS_ASSERT_EQUALS(FileFinder::Instance().getExtension("PG31234", exts), "");
......
......@@ -95,7 +95,7 @@ public:
MultipleFilePropertyTest()
: m_multiFileLoadingSetting(), m_oldDataSearchDirectories(),
m_oldDefaultFacility(), m_oldDefaultInstrument(), m_dummyFilesDir(),
m_dirWithWhitespace(), m_tempDirs(), m_exts(),
m_dirWithWhitespace(), m_tempDirs(), m_exts{".raw", ".nxs"},
g_config(Mantid::Kernel::ConfigService::Instance()) {
m_dummyFilesDir =
createAbsoluteDirectory("_MultipleFilePropertyTestDummyFiles");
......@@ -105,9 +105,6 @@ public:
m_tempDirs.insert(m_dummyFilesDir);
m_tempDirs.insert(m_dirWithWhitespace);
m_exts.emplace_back(".raw");
m_exts.emplace_back(".nxs");
std::set<std::string> dummyFilenames = boost::assign::list_of
// Standard raw file runs.
("TSC00001.raw")("TSC00002.raw")("TSC00003.raw")("TSC00004.raw")(
......
......@@ -63,19 +63,14 @@ void AbsorptionCorrection::init() {
"The number of wavelength points for which the numerical integral is\n"
"calculated (default: all points)");
std::vector<std::string> exp_options;
exp_options.emplace_back("Normal");
exp_options.emplace_back("FastApprox");
std::vector<std::string> exp_options{"Normal", "FastApprox"};
declareProperty(
"ExpMethod", "Normal",
boost::make_shared<StringListValidator>(exp_options),
"Select the method to use to calculate exponentials, normal or a\n"
"fast approximation (default: Normal)");
std::vector<std::string> propOptions;
propOptions.emplace_back("Elastic");
propOptions.emplace_back("Direct");
propOptions.emplace_back("Indirect");
std::vector<std::string> propOptions{"Elastic", "Direct", "Indirect"};
declareProperty("EMode", "Elastic",
boost::make_shared<StringListValidator>(propOptions),
"The energy mode (default: elastic)");
......
......@@ -28,11 +28,7 @@ BinaryOperateMasks::~BinaryOperateMasks() {
void BinaryOperateMasks::init() {
std::vector<std::string> operators;
operators.emplace_back("AND");
operators.emplace_back("OR");
operators.emplace_back("XOR");
operators.emplace_back("NOT");
std::vector<std::string> operators{"AND", "OR", "XOR", "NOT"};
declareProperty(new WorkspaceProperty<DataObjects::MaskWorkspace>(
"InputWorkspace1", "", Direction::Input),
......
......@@ -46,9 +46,7 @@ void CalculateFlatBackground::init() {
new ArrayProperty<int>("WorkspaceIndexList"),
"Indices of the spectra that will have their background removed\n"
"default: modify all spectra");
std::vector<std::string> modeOptions;
modeOptions.emplace_back("Linear Fit");
modeOptions.emplace_back("Mean");
std::vector<std::string> modeOptions{"Linear Fit", "Mean"};
declareProperty("Mode", "Linear Fit",
boost::make_shared<StringListValidator>(modeOptions),
"The background count rate is estimated either by taking a "
......@@ -56,9 +54,8 @@ void CalculateFlatBackground::init() {
"linear fit (default: Linear Fit)");
// Property to determine whether we subtract the background or just return the
// background.
std::vector<std::string> outputOptions;
outputOptions.emplace_back("Subtract Background");
outputOptions.emplace_back("Return Background");
std::vector<std::string> outputOptions{"Subtract Background",
"Return Background"};
declareProperty("OutputMode", "Subtract Background",
boost::make_shared<StringListValidator>(outputOptions),
"Once the background has been determined it can either be "
......
......@@ -60,10 +60,7 @@ void ConvertUnits::init() {
"The name of the units to convert to (must be one of those "
"registered in\n"
"the Unit Factory)");
std::vector<std::string> propOptions;
propOptions.emplace_back("Elastic");
propOptions.emplace_back("Direct");
propOptions.emplace_back("Indirect");
std::vector<std::string> propOptions{"Elastic", "Direct", "Indirect"};
declareProperty("EMode", "Elastic",
boost::make_shared<StringListValidator>(propOptions),
"The energy mode (default: elastic)");
......
......@@ -45,10 +45,8 @@ void CopyLogs::init() {
"Workspace to copy logs too.");
// options for the type of strategy to take
std::vector<std::string> strategies;
strategies.emplace_back("WipeExisting");
strategies.emplace_back("MergeKeepExisting");
strategies.emplace_back("MergeReplaceExisting");
std::vector<std::string> strategies{"WipeExisting", "MergeKeepExisting",
"MergeReplaceExisting"};
auto strategiesValidator =
boost::make_shared<StringListValidator>(strategies);
......
......@@ -40,9 +40,7 @@ void CorrectKiKf::init() {
Direction::Output),
"Name of the output workspace, can be the same as the input");
std::vector<std::string> propOptions;
propOptions.emplace_back("Direct");
propOptions.emplace_back("Indirect");
std::vector<std::string> propOptions{"Direct", "Indirect"};
this->declareProperty("EMode", "Direct",
boost::make_shared<StringListValidator>(propOptions),
"The energy mode (default: Direct)");
......
......@@ -31,8 +31,7 @@ void CorrectToFile::init() {
"The units of the first column of the correction file "
"(default wavelength)");
std::vector<std::string> operations(1, std::string("Divide"));
operations.emplace_back("Multiply");
std::vector<std::string> operations{"Divide", "Multiply"};
declareProperty("WorkspaceOperation", "Divide",
boost::make_shared<Kernel::StringListValidator>(operations),
"Allowed values: Divide, Multiply (default is divide)");
......
......@@ -80,12 +80,7 @@ void CreateGroupingWorkspace::init() {
"Use / or , to separate multiple groups. "
"If empty, then an empty GroupingWorkspace will be created.");
std::vector<std::string> grouping;
grouping.emplace_back("");
grouping.emplace_back("All");
grouping.emplace_back("Group");
grouping.emplace_back("Column");
grouping.emplace_back("bank");
std::vector<std::string> grouping{"", "All", "Group", "Column", "bank"};
declareProperty(
"GroupDetectorsBy", "", boost::make_shared<StringListValidator>(grouping),
"Only used if GroupNames is empty: All detectors as one group, Groups "
......
......@@ -59,9 +59,7 @@ void CreateSampleWorkspace::init() {
declareProperty(
new WorkspaceProperty<>("OutputWorkspace", "", Direction::Output),
"An output workspace.");
std::vector<std::string> typeOptions;
typeOptions.emplace_back("Histogram");
typeOptions.emplace_back("Event");
std::vector<std::string> typeOptions{"Histogram", "Event"};
declareProperty("WorkspaceType", "Histogram",
boost::make_shared<StringListValidator>(typeOptions),
"The type of workspace to create (default: Histogram)");
......
......@@ -46,9 +46,8 @@ const std::string CreateTransmissionWorkspaceAuto::summary() const {
*/
void CreateTransmissionWorkspaceAuto::init() {
std::vector<std::string> analysis_modes;
analysis_modes.emplace_back("PointDetectorAnalysis");
analysis_modes.emplace_back("MultiDetectorAnalysis");
std::vector<std::string> analysis_modes{"PointDetectorAnalysis",
"MultiDetectorAnalysis"};
declareProperty("AnalysisMode", analysis_modes.at(0),
boost::make_shared<StringListValidator>(analysis_modes),
"Analysis Mode to Choose", Direction::Input);
......
......@@ -51,9 +51,7 @@ void ExportTimeSeriesLog::init() {
declareProperty("LogName", "", "Log's name to filter events.");
std::vector<std::string> units;
units.emplace_back("Seconds");
units.emplace_back("Nano Seconds");
std::vector<std::string> units{"Seconds", "Nano Seconds"};
declareProperty(
"UnitOfTime", "Seconds",
boost::make_shared<Kernel::StringListValidator>(units),
......
......@@ -52,9 +52,7 @@ void FFT::init() {
declareProperty("Imaginary", EMPTY_INT(), mustBePositive,
"Spectrum number to use as imaginary part for transform");
std::vector<std::string> fft_dir;
fft_dir.emplace_back("Forward");
fft_dir.emplace_back("Backward");
std::vector<std::string> fft_dir{"Forward", "Backward"};
declareProperty("Transform", "Forward",
boost::make_shared<StringListValidator>(fft_dir),
"Direction of the transform: forward or backward");
......
......@@ -30,9 +30,7 @@ void FFTSmooth::init() {
declareProperty("WorkspaceIndex", 0, mustBePositive,
"Spectrum index for smoothing");
std::vector<std::string> type;
// type.emplace_back("Truncation");
type.emplace_back("Zeroing");
std::vector<std::string> type{"Zeroing"};
declareProperty("Filter", "Zeroing",
boost::make_shared<StringListValidator>(type),
"The type of the applied filter");
......
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