...
This commit is contained in:
parent
a70339c55e
commit
a30729fb37
106
mcc/mcc_coord.h
Normal file
106
mcc/mcc_coord.h
Normal file
@ -0,0 +1,106 @@
|
||||
#include "mcc_angle.h"
|
||||
#include "mcc_defaults.h"
|
||||
#include "mcc_generics.h"
|
||||
|
||||
|
||||
namespace mcc
|
||||
{
|
||||
|
||||
|
||||
template <mcc_angle_c CO_LON_T, mcc_angle_c CO_LAT_T>
|
||||
class MccCoordPair
|
||||
{
|
||||
public:
|
||||
typedef CO_LON_T x_t;
|
||||
typedef CO_LAT_T y_t;
|
||||
|
||||
MccCoordPair(CO_LON_T const& x, CO_LAT_T const& y) : _x(x), _y(y) {}
|
||||
|
||||
virtual ~MccCoordPair() = default;
|
||||
|
||||
CO_LON_T x() const
|
||||
{
|
||||
return _x;
|
||||
}
|
||||
|
||||
CO_LAT_T y() const
|
||||
{
|
||||
return _y;
|
||||
}
|
||||
|
||||
operator std::tuple<CO_LON_T, CO_LAT_T>() const
|
||||
{
|
||||
return {_x, _y};
|
||||
}
|
||||
|
||||
void setX(const CO_LON_T& x)
|
||||
{
|
||||
_x = x;
|
||||
}
|
||||
|
||||
void setY(const CO_LAT_T& y)
|
||||
{
|
||||
_y = y;
|
||||
}
|
||||
|
||||
protected:
|
||||
CO_LON_T _x;
|
||||
CO_LAT_T _y;
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
concept mcc_coord_pair_c = requires {
|
||||
typename T::x_t;
|
||||
typename T::y_t;
|
||||
|
||||
requires std::derived_from<T, MccCoordPair<typename T::x_t, typename T::y_t>>;
|
||||
};
|
||||
|
||||
|
||||
struct mcc_skycoord_interface_t {
|
||||
template <std::derived_from<mcc_skycoord_interface_t> SelfT, mcc_angle_c XT, mcc_angle_c YT>
|
||||
SelfT& from(this SelfT&& self, XT&& x, YT&& y)
|
||||
{
|
||||
return std::forward<SelfT>(self).from(std::forward<XT>(x), std::forward<YT>(y));
|
||||
}
|
||||
|
||||
template <std::derived_from<mcc_skycoord_interface_t> SelfT, mcc_coord_pair_c PT>
|
||||
SelfT& from(this SelfT&& self, PT&& cpair)
|
||||
{
|
||||
return std::forward<SelfT>(self).from(std::forward<PT>(cpair));
|
||||
}
|
||||
|
||||
template <std::derived_from<mcc_skycoord_interface_t> SelfT, mcc_coord_pair_c PT>
|
||||
SelfT& operator=(this SelfT&& self, PT&& cpair)
|
||||
{
|
||||
return std::forward<SelfT>(self).operator=(std::forward<PT>(cpair));
|
||||
}
|
||||
|
||||
|
||||
template <std::derived_from<mcc_skycoord_interface_t> SelfT, mcc_coord_pair_c PT, mcc_coord_pair_c... PTs>
|
||||
SelfT& to(this SelfT&& self, PT& cpair, PTs&... cpairs)
|
||||
{
|
||||
return std::forward<SelfT>(self).to(cpair, cpairs);
|
||||
}
|
||||
|
||||
template <std::derived_from<mcc_skycoord_interface_t> SelfT, mcc_coord_pair_c PT>
|
||||
operator PT(this SelfT&& self)
|
||||
{
|
||||
return std::forward<SelfT>(self).operator PT();
|
||||
}
|
||||
|
||||
template <std::derived_from<mcc_skycoord_interface_t> SelfT, mcc_coord_pair_c PT, mcc_coord_pair_c... PTs>
|
||||
operator std::tuple<PT, PTs...>(this SelfT&& self)
|
||||
{
|
||||
return std::forward<SelfT>(self).operator std::tuple<PT, PTs...>();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
concept mcc_skycoord_c = std::derived_from<T, mcc_skycoord_interface_t> && requires(T t) {
|
||||
typename T::meteo_t;
|
||||
{ T::meteo(std::declval<typename T::meteo_t const&>()) };
|
||||
};
|
||||
|
||||
} // end namespace mcc
|
||||
Loading…
x
Reference in New Issue
Block a user