7.0.3.rc: jf sync: stopping master gives idle (#822)

* jf sync mode master could return idle when stopped and so not all modules return the same value and must check for 'stopped or idle', Also must throw if any of the module gives an error ( not jungfrau, but eiger could)

* added contains_only to sls::Result (#827)

* added variadic template for checking if a result contains only specified values

* fix for gcc4.8

* renamed to Result::contains_only

* stop on only the positions

---------

Co-authored-by: Erik Fröjdh <erik.frojdh@gmail.com>
This commit is contained in:
2023-10-13 12:27:43 +02:00
committed by GitHub
parent 1484d038de
commit 37ce3d6f59
4 changed files with 68 additions and 10 deletions

View File

@ -16,6 +16,7 @@
#include <vector>
#include "sls/ToString.h"
#include "sls/TypeTraits.h"
#include "sls/container_utils.h"
namespace sls {
@ -128,6 +129,25 @@ template <class T, class Allocator = std::allocator<T>> class Result {
/** Test whether all elements of the result are equal */
bool equal() const noexcept { return allEqual(vec); }
/** Test whether any element of the result are equal to a value */
bool any(const T &value) const noexcept { return anyEqualTo(vec, value); }
template <typename V, typename... Args, typename = AllSame<V, Args...>>
typename std::enable_if<std::is_same<V, T>::value, bool>::type
contains_only(const V &a, const Args &...args) const noexcept {
auto values = {a, args...};
for (const auto &element : vec) {
int found = 0;
for (const auto &value : values) {
if (value == element)
found++;
}
if (!found)
return false;
}
return true;
}
/** Convert Result<T> to std::vector<T> */
operator std::vector<T>() { return vec; }
};