#pragma once #include "ParseArgs.h" #include class BaseParameters; using michlib::real; template concept InfoSupported = requires(T t) { { t.Info() } -> std::convertible_to; }; template concept HasDefVars = requires(T t) { { t.DefaultVars() } -> std::convertible_to; }; template concept ParametersRequiredRegion = requires(T t, michlib_internal::ParameterListEx& pars, const CLArgs& args, const struct Region& r) { { t.Parameters(pars, args, r).first } -> std::convertible_to; }; template concept ParametersNotRequiredRegion = requires(T t, michlib_internal::ParameterListEx& pars, const CLArgs& args) { { t.Parameters(pars, args).first } -> std::convertible_to; }; template concept ParametersSupported = ParametersRequiredRegion || ParametersNotRequiredRegion; template concept ReadPSupported = requires(T t, const MString& vname, std::map& cache, const BaseParameters* ip, size_t i) { { t.Read(vname, cache, ip, i) } -> std::same_as; }; template concept ReadSupported = requires(T t, const MString& vname, std::map& cache, size_t i) { { t.Read(vname, cache, i) } -> std::same_as; }; template concept IsUVData = requires(T t) { { t.U(0) } -> std::convertible_to; { t.V(0) } -> std::convertible_to; { t.U2(0) } -> std::convertible_to; }; namespace internal { template concept HaveXYStep = requires(T t) { { t.XStep() } -> std::convertible_to; { t.YStep() } -> std::convertible_to; }; template using void_ = void; template struct GetReadType_; template struct GetReadType_ { using type = typename D::Data; }; template struct GetReadType_ { using type = std::decay_t; }; template concept HaveDisable = requires(T t) { { T::disabledactions } -> std::convertible_to; }; consteval bool cmpspace(const char* s1, const char* s2) { size_t i = 0; while(true) { if(s1[i] != s2[i]) return false; i++; if(s1[i] == 0 && (s2[i] == 0 || s2[i] == ' ')) return true; if(s1[i] == 0 || s2[i] == 0 || s2[i] == ' ') return false; } return false; } } // namespace internal template consteval bool IsDisabled() { if constexpr(!internal::HaveDisable) return false; else { bool prsp = true; size_t i = 0; do { if(prsp && internal::cmpspace(Act::name, S::disabledactions + i)) return true; prsp = S::disabledactions[i] == ' '; } while(S::disabledactions[++i] != 0); return false; } } template using ReadType = internal::GetReadType_ || ReadSupported>::type; template concept ReadIsGrid = requires { { std::declval>().XStep() } -> std::convertible_to; { std::declval>().YStep() } -> std::convertible_to; }; template concept ReadIs2DGeoRectArray = requires { { std::declval>().Ix2Lon(0) } -> std::convertible_to; { std::declval>().Iy2Lat(0) } -> std::convertible_to; }; template concept ReadIs2DGeoArray = requires { { std::declval>().Lon(0, 0) } -> std::convertible_to; { std::declval>().Lat(0, 0) } -> std::convertible_to; }; template concept ReadIs1DGeoArray = requires { { std::declval>().Lon(0) } -> std::convertible_to; { std::declval>().Lat(0) } -> std::convertible_to; }; template concept CanInterpolate2D = requires { { std::declval>().GridPoint(0.0, 0.0) } -> std::convertible_to; };