Mantid
Loading...
Searching...
No Matches
FunctionDomainGeneral.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 +
7//----------------------------------------------------------------------
8// Includes
9//----------------------------------------------------------------------
11#include "MantidAPI/Column.h"
12
13namespace Mantid::API {
14
16size_t FunctionDomainGeneral::size() const { return m_columns.empty() ? 0 : m_columns.front()->size(); }
17
19size_t FunctionDomainGeneral::columnCount() const { return m_columns.size(); }
20
22void FunctionDomainGeneral::addColumn(const std::shared_ptr<Column> &column) {
23 if (!column) {
24 throw std::runtime_error("Cannot add null column to FunctionDomainGeneral.");
25 }
26 if (!m_columns.empty() && size() != column->size()) {
27 throw std::runtime_error("Cannot add a column to FunctionDomainGeneral. "
28 "All columns must have the same size.");
29 }
30
31 m_columns.emplace_back(column);
32}
33
36std::shared_ptr<Column> FunctionDomainGeneral::getColumn(size_t i) const { return m_columns.at(i); }
37
38} // namespace Mantid::API
void addColumn(const std::shared_ptr< Column > &column)
Add a new column. All columns must have the same size.
std::shared_ptr< Column > getColumn(size_t i) const
Get i-th column.
size_t columnCount() const
Get the number of columns.
std::vector< std::shared_ptr< Column > > m_columns
Columns containing function arguments.
size_t size() const override
Return the number of arguments in the domain.