@@ -8,13 +8,29 @@ namespace py = pybind11;
88
99using namespace util_caching ;
1010
11+ struct SomePolicyWithoutParams {
12+ SomePolicyWithoutParams () = default ;
13+ bool operator ()(const Time& /* lhs*/ , const Time& /* rhs*/ ) const {
14+ return true ;
15+ }
16+ };
17+
1118PYBIND11_MODULE (util_caching_py, mainModule) {
19+ using ApproximateNumberT = policies::ApproximateNumber<double >;
20+ using ApproximateTimeT = policies::ApproximateTime<Time, std::chrono::milliseconds>;
21+ using ApproximateTimeSecondsT = policies::ApproximateTime<Time, std::chrono::seconds>;
22+
23+ py::class_<SomePolicyWithoutParams, std::shared_ptr<SomePolicyWithoutParams>>(mainModule, " SomePolicyWithoutParams" )
24+ .def (py::init<>())
25+ .def (" __call__" , &SomePolicyWithoutParams::operator ());
26+
1227 py::module numberBased = mainModule.def_submodule (" number_based" );
1328 python_api::number_based::bindApproximatePolicy<double >(numberBased);
14- python_api::number_based::bindCache<double , double , policies::ApproximateNumber< double > >(numberBased);
29+ python_api::number_based::bindCache<double , double , ApproximateNumberT >(numberBased);
1530
1631 py::module timeBased = mainModule.def_submodule (" time_based" );
17- python_api::time_based::bindApproximatePolicy<Time, std::chrono::milliseconds>(timeBased);
18- python_api::time_based::bindCache<Time, double , policies::ApproximateTime<Time, std::chrono::milliseconds>>(
32+ python_api::time_based::bindApproximatePolicy<Time, std::chrono::milliseconds>(timeBased, " ApproximateTime" );
33+ python_api::time_based::bindApproximatePolicy<Time, std::chrono::seconds>(timeBased, " ApproximateTimeSeconds" );
34+ python_api::time_based::bindCache<Time, double , ApproximateTimeT, ApproximateTimeSecondsT, SomePolicyWithoutParams>(
1935 timeBased);
2036}
0 commit comments