aboutsummaryrefslogtreecommitdiffstats
path: root/python/bindings/ranges_python.cc
blob: fce957cfea803a08a59ee8cda3bbf7086d4421c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <pybind11/pybind11.h>

namespace py = pybind11;

#include <osmosdr/ranges.h>

void bind_ranges(py::module& m)
{
    m.attr("ALL_MBOARDS") = ::osmosdr::ALL_MBOARDS;
    m.attr("ALL_CHANS") = ::osmosdr::ALL_CHANS;


    using range_t = ::osmosdr::range_t;

    py::class_<range_t>(m, "range_t")
        .def(py::init<double>(), py::arg("value") = 0)
        .def(py::init<double, double, double>(), py::arg("start"), py::arg("stop"), py::arg("step") = 0)
        .def("start", &range_t::start)
        .def("stop", &range_t::stop)
        .def("step", &range_t::step)
        .def("to_pp_string", &range_t::to_pp_string);


    using meta_range_t = ::osmosdr::meta_range_t;

    py::class_<meta_range_t>(m, "meta_range_t")
        .def(py::init())
        .def(py::init<double, double, double>(), py::arg("start"), py::arg("stop"), py::arg("step") = 0)
        .def("start", &meta_range_t::start)
        .def("stop", &meta_range_t::stop)
        .def("step", &meta_range_t::step)
        .def("clip", &meta_range_t::clip, py::arg("value"), py::arg("clip_step") = false)
        .def("values", &meta_range_t::values)
        .def("to_pp_string", &meta_range_t::to_pp_string);
}