32 lines
1.0 KiB
C++
32 lines
1.0 KiB
C++
#pragma once
|
|
#include <type_traits>
|
|
|
|
namespace gridfire::policy {
|
|
struct ReactionChainPolicy {};
|
|
struct NetworkPolicy {};
|
|
}
|
|
namespace py {
|
|
template<class T, class BaseT> struct class_ {
|
|
template<class F> class_& def(const char*, F) { return *this; }
|
|
};
|
|
}
|
|
namespace bindings::detail {
|
|
template<typename T>
|
|
concept IsReactionChainPolicy = std::is_base_of_v<gridfire::policy::ReactionChainPolicy, T>;
|
|
template<typename T>
|
|
concept IsNetworkPolicy = std::is_base_of_v<gridfire::policy::NetworkPolicy, T>;
|
|
|
|
template<IsReactionChainPolicy T, IsReactionChainPolicy BaseT>
|
|
void registerReactionChainPolicyDefs(py::class_<T, BaseT>& pyClass) {
|
|
pyClass.def("name", &T::name)
|
|
.def("hash", [](const T& self) { return self.hash(0); });
|
|
}
|
|
|
|
template<IsNetworkPolicy T, IsNetworkPolicy BaseT>
|
|
void registerNetworkPolicyDefs(py::class_<T, BaseT> pyClass) {
|
|
pyClass.def("name", &T::name)
|
|
.def("construct", [](const T& self) { return self.construct(); });
|
|
}
|
|
static_assert(IsNetworkPolicy<gridfire::policy::NetworkPolicy>);
|
|
}
|