Mantid
Loading...
Searching...
No Matches
FunctionModelDataset.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2020 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 +
8
9#include <stdexcept>
10#include <utility>
11
13
15 : m_workspaceName(std::move(workspaceName)), m_spectra(std::move(spectra)) {}
16
23std::vector<std::string> FunctionModelDataset::domainNames() const {
24 const auto numOfSpectra = m_spectra.size().value;
25 if (numOfSpectra == 0u)
26 throw std::runtime_error("There are no spectra in this Dataset.");
27 if (numOfSpectra == 1u)
28 return std::vector<std::string>{m_workspaceName};
29 else {
30 std::vector<std::string> domains;
31 std::transform(m_spectra.begin(), m_spectra.end(), std::back_inserter(domains),
32 [&](auto const &spectrum) { return m_workspaceName + " (" + std::to_string(spectrum.value) + ")"; });
33 return domains;
34 }
35}
36
37} // namespace MantidQt::MantidWidgets
std::vector< WorkspaceIndex >::const_iterator begin() const
std::vector< WorkspaceIndex >::const_iterator end() const
STL namespace.
std::vector< std::string > domainNames() const
Returns the names given to each domain (i.e.
FunctionModelDataset(std::string workspaceName, FunctionModelSpectra spectra)
IntImplementationType value
Definition IndexTypes.h:26