You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
1.6 KiB
75 lines
1.6 KiB
2 years ago
|
#pragma once
|
||
|
#include "ParseArgs.h"
|
||
|
#include <concepts>
|
||
|
|
||
|
class BaseParameters;
|
||
|
using michlib::real;
|
||
|
|
||
|
template<class T>
|
||
|
concept InfoSupported = requires(T t) {
|
||
|
{
|
||
|
t.Info()
|
||
|
} -> std::convertible_to<MString>;
|
||
|
};
|
||
|
|
||
|
template<class T>
|
||
|
concept ParametersSupported = requires(T t, michlib_internal::ParameterListEx& pars, const CLArgs& args) {
|
||
|
{
|
||
|
t.Parameters(pars, args).first
|
||
|
} -> std::convertible_to<const BaseParameters*>;
|
||
|
};
|
||
|
|
||
|
template<class T>
|
||
|
concept ReadPSupported = requires(T t, const MString& vname, const BaseParameters* ip, size_t i) {
|
||
|
{
|
||
|
t.Read(vname, ip, i)(0)
|
||
|
} -> std::convertible_to<real>;
|
||
|
};
|
||
|
template<class T>
|
||
|
concept ReadSupported = requires(T t, const MString& vname, size_t i) {
|
||
|
{
|
||
|
t.Read(vname, i)(0)
|
||
|
} -> std::convertible_to<real>;
|
||
|
};
|
||
|
|
||
|
template<class T>
|
||
|
concept ReadUVPSupported = requires(T t, const BaseParameters* ip, size_t i) {
|
||
|
{
|
||
|
t.ReadUV(ip, i).U(0, 0) + t.template ReadUV(ip, i).V(0, 0)
|
||
|
} -> std::convertible_to<real>;
|
||
|
};
|
||
|
|
||
|
template<class T>
|
||
|
concept IsUVData = requires(T t) {
|
||
|
{
|
||
|
t.U(0)
|
||
|
} -> std::convertible_to<real>;
|
||
|
{
|
||
|
t.V(0)
|
||
|
} -> std::convertible_to<real>;
|
||
|
{
|
||
|
t.U2(0)
|
||
|
} -> std::convertible_to<real>;
|
||
|
};
|
||
|
|
||
|
namespace internal
|
||
|
{
|
||
|
template<typename...> using void_ = void;
|
||
|
|
||
|
template<class D, bool RP, bool R> struct GetReadType_;
|
||
|
|
||
|
template<class D, bool R> struct GetReadType_<D, true, R>
|
||
|
{
|
||
|
using p = BaseParameters*;
|
||
|
using type = decltype(D().Read(MString(), p(), 0));
|
||
|
};
|
||
|
|
||
|
template<class D> struct GetReadType_<D, false, true>
|
||
|
{
|
||
|
using type = decltype(D().Read(MString(), 0));
|
||
|
};
|
||
|
|
||
|
} // namespace internal
|
||
|
|
||
|
template<class D> using ReadType = internal::GetReadType_<D, ReadPSupported<D>, ReadSupported<D>>::type;
|