Mantid
Loading...
Searching...
No Matches
SpinStateValidator.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2024 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#pragma once
9
10#include "MantidKernel/DllConfig.h"
13#include <unordered_set>
14
15namespace Mantid::Kernel {
16
17/*
18Will check that a string matches the form 01,00 or 00,10,11,01, for example. This is used for
19specifying the order of input workspaces relative to spin states. There is also a method to
20extract the relevant workspace for a given spin state from a group workspace, given a
21particular ordering.
22*/
23class MANTID_KERNEL_DLL SpinStateValidator : public Kernel::TypedValidator<std::string> {
24public:
25 SpinStateValidator(std::unordered_set<int> allowedNumbersOfSpins, const bool acceptSingleStates = false,
26 const std::string &paraIndicator = "0", const std::string &antiIndicator = "1",
27 const bool optional = false, const std::string &extraIndicator = "");
28 Kernel::IValidator_sptr clone() const override;
29
30 static bool anyOfIsInSet(const std::vector<std::string> &anyOf, const std::unordered_set<std::string> &set);
31 static bool setContains(const std::unordered_set<std::string> &set, const std::string &s) {
32 return set.find(s) != set.cend();
33 }
34
35private:
36 std::string checkValidity(const std::string &input) const override;
37 std::unordered_set<int> m_allowedNumbersOfSpins = {1, 2, 3, 4};
38 const std::unordered_set<std::string> getAllowedPairStates() const;
39 const std::unordered_set<std::string> getAllowedSingleStates() const;
40 bool m_acceptSingleStates = false;
41 const std::string m_para;
42 const std::string m_anti;
43 bool m_optional = false;
44 // Extra value to indicate a third spin state (for example 0)
45 const std::string m_extra;
46};
47} // namespace Mantid::Kernel
static bool setContains(const std::unordered_set< std::string > &set, const std::string &s)
std::shared_ptr< IValidator > IValidator_sptr
A shared_ptr to an IValidator.
Definition IValidator.h:26