13#ifndef RTCTK_COMPONENTFRAMEWORK_PATTERNVALIDATION_HPP
14#define RTCTK_COMPONENTFRAMEWORK_PATTERNVALIDATION_HPP
36template <
typename InputIter,
typename T,
typename U>
37constexpr bool ValidRamp(InputIter begin, InputIter end, T offset, U slope) {
38 typename std::iterator_traits<InputIter>::value_type counter = offset;
39 typename std::iterator_traits<InputIter>::value_type delta = slope;
40 for (
auto value = begin; value != end; ++value) {
41 if (*value != counter) {
63template <
typename InputIter,
typename T>
66 using C =
typename std::iterator_traits<InputIter>::value_type;
67 if constexpr (IS_COMPLEX_TYPE<C>) {
68 typename C::value_type cast_offset = offset;
69 if (sample_id % 2 == 0) {
70 return ValidRamp(begin, end, C(cast_offset, cast_offset + 1), C(+2, +2));
72 return ValidRamp(begin, end, C(-cast_offset, -cast_offset - 1), C(-2, -2));
74 }
else if constexpr (std::is_signed_v<C>) {
75 C cast_offset = offset;
76 if (sample_id % 2 == 0) {
77 return ValidRamp(begin, end, cast_offset, +1);
79 return ValidRamp(begin, end, -cast_offset, -1);
82 C cast_offset = offset;
83 if (sample_id % 2 == 0) {
84 return ValidRamp(begin, end, cast_offset, +1);
86 return ValidRamp(begin, end, std::numeric_limits<C>::max() - cast_offset, -1);
Definition: commandReplier.cpp:22
constexpr bool ValidRamp(InputIter begin, InputIter end, T offset, U slope)
Checks to see if the buffer contains a ramp of values.
Definition: patternValidation.hpp:37
constexpr bool ValidAlternatingRamp(InputIter begin, InputIter end, std::uint32_t sample_id, T offset)
Checks to see if the buffer contains an alternating ramp of values.
Definition: patternValidation.hpp:65
Provides useful mechanisms to test various type traits.