##// END OF EJS Templates
Forwarded constness of value type for SqpIterator + PB11 stuff...
jeandet -
r42:303cd0ae5d46
parent child
Show More
@@ -1,112 +1,112
1 #ifndef SCIQLOP_SQPITERATOR_H
1 #ifndef SCIQLOP_SQPITERATOR_H
2 #define SCIQLOP_SQPITERATOR_H
2 #define SCIQLOP_SQPITERATOR_H
3
3
4 #include "CoreGlobal.h"
4 #include "CoreGlobal.h"
5
5
6 /**
6 /**
7 * @brief The SqpIterator class represents an iterator used in SciQlop. It defines all operators
7 * @brief The SqpIterator class represents an iterator used in SciQlop. It defines all operators
8 * needed for a standard forward iterator
8 * needed for a standard forward iterator
9 * @tparam T the type of object handled in iterator
9 * @tparam T the type of object handled in iterator
10 * @sa http://www.cplusplus.com/reference/iterator/
10 * @sa http://www.cplusplus.com/reference/iterator/
11 */
11 */
12 template <typename T>
12 template <typename T, bool isConst=false>
13 class SCIQLOP_CORE_EXPORT SqpIterator {
13 class SCIQLOP_CORE_EXPORT SqpIterator {
14 public:
14 public:
15 using iterator_category = std::random_access_iterator_tag;
15 using iterator_category = std::random_access_iterator_tag;
16 using value_type = const T;
16 using value_type = typename std::conditional<isConst, const T, T>::type;
17 using difference_type = std::ptrdiff_t;
17 using difference_type = std::ptrdiff_t;
18 using pointer = value_type *;
18 using pointer = value_type *;
19 using reference = value_type &;
19 using reference = value_type &;
20
20
21 explicit SqpIterator(T value) : m_CurrentValue{std::move(value)} {}
21 explicit SqpIterator(T value) : m_CurrentValue{std::move(value)} {}
22
22
23 virtual ~SqpIterator() noexcept = default;
23 virtual ~SqpIterator() noexcept = default;
24 SqpIterator(const SqpIterator &) = default;
24 SqpIterator(const SqpIterator &) = default;
25 SqpIterator &operator=(SqpIterator other)
25 SqpIterator &operator=(SqpIterator other)
26 {
26 {
27 swap(m_CurrentValue, other.m_CurrentValue);
27 swap(m_CurrentValue, other.m_CurrentValue);
28 return *this;
28 return *this;
29 }
29 }
30
30
31 SqpIterator &operator++()
31 SqpIterator &operator++()
32 {
32 {
33 m_CurrentValue.next();
33 m_CurrentValue.next();
34 return *this;
34 return *this;
35 }
35 }
36
36
37 SqpIterator &operator--()
37 SqpIterator &operator--()
38 {
38 {
39 m_CurrentValue.prev();
39 m_CurrentValue.prev();
40 return *this;
40 return *this;
41 }
41 }
42
42
43 SqpIterator operator++(int)const
43 SqpIterator operator++(int)const
44 {
44 {
45 auto result = *this;
45 auto result = *this;
46 this->operator++();
46 this->operator++();
47 return result;
47 return result;
48 }
48 }
49 SqpIterator operator--(int)const
49 SqpIterator operator--(int)const
50 {
50 {
51 auto result = *this;
51 auto result = *this;
52 this->operator--();
52 this->operator--();
53 return result;
53 return result;
54 }
54 }
55
55
56 SqpIterator &operator+=(int offset)
56 SqpIterator &operator+=(int offset)
57 {
57 {
58 if (offset >= 0) {
58 if (offset >= 0) {
59 m_CurrentValue.next(offset);
59 m_CurrentValue.next(offset);
60 }
60 }
61 else {
61 else {
62 while (offset++) {
62 while (offset++) {
63 m_CurrentValue.prev();
63 m_CurrentValue.prev();
64 }
64 }
65 }
65 }
66
66
67 return *this;
67 return *this;
68 }
68 }
69 SqpIterator &operator-=(int offset) { return *this += -offset; }
69 SqpIterator &operator-=(int offset) { return *this += -offset; }
70
70
71 SqpIterator operator+(int offset) const
71 SqpIterator operator+(int offset) const
72 {
72 {
73 auto result = *this;
73 auto result = *this;
74 result += offset;
74 result += offset;
75 return result;
75 return result;
76 }
76 }
77 SqpIterator operator-(int offset) const
77 SqpIterator operator-(int offset) const
78 {
78 {
79 auto result = *this;
79 auto result = *this;
80 result -= offset;
80 result -= offset;
81 return result;
81 return result;
82 }
82 }
83
83
84 int operator-(const SqpIterator &other) const
84 int operator-(const SqpIterator &other) const
85 {
85 {
86 return m_CurrentValue.distance(other.m_CurrentValue);
86 return m_CurrentValue.distance(other.m_CurrentValue);
87 }
87 }
88
88
89 const T *operator->() const { return &m_CurrentValue; }
89 const T *operator->() const { return &m_CurrentValue; }
90 const T &operator*() const { return m_CurrentValue; }
90 const T &operator*() const { return m_CurrentValue; }
91 T *operator->() { return &m_CurrentValue; }
91 T *operator->() { return &m_CurrentValue; }
92 T &operator*() { return m_CurrentValue; }
92 T &operator*() { return m_CurrentValue; }
93 T &operator[](int offset) const { return m_CurrentValue.advance(offset); }
93 T &operator[](int offset) const { return m_CurrentValue.advance(offset); }
94
94
95 bool operator==(const SqpIterator &other) const
95 bool operator==(const SqpIterator &other) const
96 {
96 {
97 return m_CurrentValue.equals(other.m_CurrentValue);
97 return m_CurrentValue.equals(other.m_CurrentValue);
98 }
98 }
99 bool operator!=(const SqpIterator &other) const { return !(*this == other); }
99 bool operator!=(const SqpIterator &other) const { return !(*this == other); }
100 bool operator>(const SqpIterator &other) const { return other.m_CurrentValue.lowerThan(*this); }
100 bool operator>(const SqpIterator &other) const { return other.m_CurrentValue.lowerThan(*this); }
101 bool operator<(const SqpIterator &other) const
101 bool operator<(const SqpIterator &other) const
102 {
102 {
103 return m_CurrentValue.lowerThan(other.m_CurrentValue);
103 return m_CurrentValue.lowerThan(other.m_CurrentValue);
104 }
104 }
105 bool operator>=(const SqpIterator &other) const { return !(*this < other); }
105 bool operator>=(const SqpIterator &other) const { return !(*this < other); }
106 bool operator<=(const SqpIterator &other) const { return !(*this > other); }
106 bool operator<=(const SqpIterator &other) const { return !(*this > other); }
107
107
108 private:
108 private:
109 T m_CurrentValue;
109 T m_CurrentValue;
110 };
110 };
111
111
112 #endif // SCIQLOP_SQPITERATOR_H
112 #endif // SCIQLOP_SQPITERATOR_H
@@ -1,50 +1,55
1 #include <Data/SpectrogramSeries.h>
1 #include <Data/SpectrogramSeries.h>
2 #include <Data/DataSeriesUtils.h>
2
3
3 SpectrogramSeries::SpectrogramSeries(std::vector<double> xAxisData, std::vector<double> yAxisData,
4 SpectrogramSeries::SpectrogramSeries(std::vector<double> xAxisData, std::vector<double> yAxisData,
4 std::vector<double> valuesData, const Unit &xAxisUnit,
5 std::vector<double> valuesData, const Unit &xAxisUnit,
5 const Unit &yAxisUnit, const Unit &valuesUnit,
6 const Unit &yAxisUnit, const Unit &valuesUnit,
6 double resolution)
7 double resolution)
7 : SpectrogramSeries{
8 : SpectrogramSeries{
8 std::make_shared<ArrayData<1> >(std::move(xAxisData)),
9 std::make_shared<ArrayData<1> >(std::move(xAxisData)),
9 xAxisUnit,
10 xAxisUnit,
10 std::make_shared<ArrayData<2> >(std::move(valuesData), yAxisData.size()),
11 std::make_shared<ArrayData<2> >(std::move(valuesData), yAxisData.size()),
11 valuesUnit,
12 valuesUnit,
12 OptionalAxis{std::make_shared<ArrayData<1> >(std::move(yAxisData)), yAxisUnit},
13 OptionalAxis{std::make_shared<ArrayData<1> >(std::move(yAxisData)), yAxisUnit},
13 resolution}
14 resolution}
14 {
15 {
15 }
16 }
16
17
17 SpectrogramSeries::SpectrogramSeries(std::shared_ptr<ArrayData<1> > xAxisData,
18 SpectrogramSeries::SpectrogramSeries(std::shared_ptr<ArrayData<1> > xAxisData,
18 const Unit &xAxisUnit,
19 const Unit &xAxisUnit,
19 std::shared_ptr<ArrayData<2> > valuesData,
20 std::shared_ptr<ArrayData<2> > valuesData,
20 const Unit &valuesUnit, OptionalAxis yAxis, double resolution)
21 const Unit &valuesUnit, OptionalAxis yAxis, double resolution)
21 : DataSeries{std::move(xAxisData), xAxisUnit, std::move(valuesData), valuesUnit,
22 : DataSeries{std::move(xAxisData), xAxisUnit, std::move(valuesData), valuesUnit,
22 std::move(yAxis)},
23 std::move(yAxis)},
23 m_XResolution{resolution}
24 m_XResolution{resolution}
24 {
25 {
26 if(std::isnan(m_XResolution))
27 {
28 //m_XResolution = DataSeriesUtils::resolution(xAxisData->begin(), xAxisData->end()).m_Val;
29 }
25 }
30 }
26
31
27 std::unique_ptr<IDataSeries> SpectrogramSeries::clone() const
32 std::unique_ptr<IDataSeries> SpectrogramSeries::clone() const
28 {
33 {
29 return std::make_unique<SpectrogramSeries>(*this);
34 return std::make_unique<SpectrogramSeries>(*this);
30 }
35 }
31
36
32 std::shared_ptr<IDataSeries> SpectrogramSeries::subDataSeries(const DateTimeRange &range)
37 std::shared_ptr<IDataSeries> SpectrogramSeries::subDataSeries(const DateTimeRange &range)
33 {
38 {
34 auto subXAxisData = std::vector<double>();
39 auto subXAxisData = std::vector<double>();
35 auto subValuesData = QVector<double>(); // Uses QVector to append easily values to it
40 auto subValuesData = QVector<double>(); // Uses QVector to append easily values to it
36 this->lockRead();
41 this->lockRead();
37 auto bounds = xAxisRange(range.m_TStart, range.m_TEnd);
42 auto bounds = xAxisRange(range.m_TStart, range.m_TEnd);
38 for (auto it = bounds.first; it != bounds.second; ++it) {
43 for (auto it = bounds.first; it != bounds.second; ++it) {
39 subXAxisData.push_back(it->x());
44 subXAxisData.push_back(it->x());
40 subValuesData.append(it->values());
45 subValuesData.append(it->values());
41 }
46 }
42
47
43 auto yAxis = this->yAxis();
48 auto yAxis = this->yAxis();
44 this->unlock();
49 this->unlock();
45
50
46 return std::make_shared<SpectrogramSeries>(
51 return std::make_shared<SpectrogramSeries>(
47 std::make_shared<ArrayData<1> >(std::move(subXAxisData)), this->xAxisUnit(),
52 std::make_shared<ArrayData<1> >(std::move(subXAxisData)), this->xAxisUnit(),
48 std::make_shared<ArrayData<2> >(subValuesData.toStdVector(), yAxis.size()),
53 std::make_shared<ArrayData<2> >(subValuesData.toStdVector(), yAxis.size()),
49 this->valuesUnit(), std::move(yAxis));
54 this->valuesUnit(), std::move(yAxis));
50 }
55 }
@@ -1,149 +1,152
1 #include <pybind11/pybind11.h>
1 #include <pybind11/pybind11.h>
2 #include <pybind11/operators.h>
2 #include <pybind11/operators.h>
3 #include <pybind11/embed.h>
3 #include <pybind11/embed.h>
4 #include <pybind11/numpy.h>
4 #include <pybind11/numpy.h>
5 #include <pybind11/chrono.h>
5 #include <pybind11/chrono.h>
6 #include <pybind11/functional.h>
6 #include <pybind11/functional.h>
7 #include <pybind11/stl.h>
8
7
9
8 #include <string>
10 #include <string>
9 #include <sstream>
11 #include <sstream>
10
12
11 #include "pywrappers_common.h"
13 #include "pywrappers_common.h"
12 #include "CoreWrappers.h"
14 #include "CoreWrappers.h"
13
15
14 #include <Data/DataSeriesType.h>
16 #include <Data/DataSeriesType.h>
15 #include <Data/ScalarSeries.h>
17 #include <Data/ScalarSeries.h>
16 #include <Data/VectorSeries.h>
18 #include <Data/VectorSeries.h>
17 #include <Data/SpectrogramSeries.h>
19 #include <Data/SpectrogramSeries.h>
18 #include <Data/Unit.h>
20 #include <Data/Unit.h>
19 #include <Data/OptionalAxis.h>
21 #include <Data/OptionalAxis.h>
20 #include <Data/IDataProvider.h>
22 #include <Data/IDataProvider.h>
21
23
22 #include <Variable/VariableController2.h>
24 #include <Variable/VariableController2.h>
23
25
24 #include <Time/TimeController.h>
26 #include <Time/TimeController.h>
25
27
26 #include <Network/Downloader.h>
28 #include <Network/Downloader.h>
27
29
28
30
29
31
30 namespace py = pybind11;
32 namespace py = pybind11;
31 using namespace std::chrono;
33 using namespace std::chrono;
32
34
33 PYBIND11_MODULE(pysciqlopcore,m){
35 PYBIND11_MODULE(pysciqlopcore,m){
34
36
35 py::enum_<DataSeriesType>(m, "DataSeriesType")
37 py::enum_<DataSeriesType>(m, "DataSeriesType")
36 .value("SCALAR", DataSeriesType::SCALAR)
38 .value("SCALAR", DataSeriesType::SCALAR)
37 .value("SPECTROGRAM", DataSeriesType::SPECTROGRAM)
39 .value("SPECTROGRAM", DataSeriesType::SPECTROGRAM)
38 .value("VECTOR", DataSeriesType::VECTOR)
40 .value("VECTOR", DataSeriesType::VECTOR)
39 .value("UNKNOWN", DataSeriesType::UNKNOWN)
41 .value("UNKNOWN", DataSeriesType::UNKNOWN)
40 .export_values();
42 .export_values();
41
43
42 py::class_<Unit>(m, "Unit")
44 py::class_<Unit>(m, "Unit")
43 .def_readwrite("name", &Unit::m_Name)
45 .def_readwrite("name", &Unit::m_Name)
44 .def_readwrite("time_unit", &Unit::m_TimeUnit)
46 .def_readwrite("time_unit", &Unit::m_TimeUnit)
45 .def(py::self == py::self)
47 .def(py::self == py::self)
46 .def(py::self != py::self)
48 .def(py::self != py::self)
47 .def("__repr__",__repr__<Unit>);
49 .def("__repr__",__repr__<Unit>);
48
50
49 py::class_<Response>(m,"Response")
51 py::class_<Response>(m,"Response")
50 .def("status_code", &Response::status_code);
52 .def("status_code", &Response::status_code);
51
53
52 py::class_<Downloader>(m,"Downloader")
54 py::class_<Downloader>(m,"Downloader")
53 .def_static("get", Downloader::get)
55 .def_static("get", Downloader::get)
54 .def_static("getAsync", Downloader::getAsync)
56 .def_static("getAsync", Downloader::getAsync)
55 .def_static("downloadFinished", Downloader::downloadFinished);
57 .def_static("downloadFinished", Downloader::downloadFinished);
56
58
57 py::class_<ArrayDataIteratorValue>(m, "ArrayDataIteratorValue")
59 py::class_<ArrayDataIteratorValue>(m, "ArrayDataIteratorValue")
58 .def_property_readonly("value", &ArrayDataIteratorValue::first);
60 .def_property_readonly("value", &ArrayDataIteratorValue::first);
59
61
60 py::class_<OptionalAxis>(m, "OptionalAxis")
62 py::class_<OptionalAxis>(m, "OptionalAxis")
61 .def("__len__", &OptionalAxis::size)
63 .def("__len__", &OptionalAxis::size)
62 .def_property_readonly("size", &OptionalAxis::size)
64 .def_property_readonly("size", &OptionalAxis::size)
63 .def("__getitem__", [](OptionalAxis& ax, int key) {
65 .def("__getitem__", [](OptionalAxis& ax, int key) {
64 return (*(ax.begin()+key)).first();
66 return (*(ax.begin()+key)).first();
65 }, py::is_operator())
67 }, py::is_operator())
66 .def("__iter__", [](OptionalAxis& ax) {
68 .def("__iter__", [](OptionalAxis& ax) {
67 return py::make_iterator(ax.begin(), ax.end());
69 return py::make_iterator(ax.begin(), ax.end());
68 }, py::keep_alive<0, 1>());
70 }, py::keep_alive<0, 1>());
69
71
70 py::class_<DataSeriesIteratorValue>(m,"DataSeriesIteratorValue")
72 py::class_<DataSeriesIteratorValue>(m,"DataSeriesIteratorValue")
71 .def_property_readonly("x", &DataSeriesIteratorValue::x)
73 .def_property_readonly("x", &DataSeriesIteratorValue::x)
74 .def_property_readonly("y", &DataSeriesIteratorValue::y)
72 .def("value", py::overload_cast<>(&DataSeriesIteratorValue::value, py::const_))
75 .def("value", py::overload_cast<>(&DataSeriesIteratorValue::value, py::const_))
73 .def("value", py::overload_cast<int>(&DataSeriesIteratorValue::value, py::const_))
76 .def("value", py::overload_cast<int>(&DataSeriesIteratorValue::value, py::const_))
74 .def("values", &DataSeriesIteratorValue::values);
77 .def("values", &DataSeriesIteratorValue::values);
75
78
76 py::class_<IDataSeries, std::shared_ptr<IDataSeries>>(m, "IDataSeries")
79 py::class_<IDataSeries, std::shared_ptr<IDataSeries>>(m, "IDataSeries")
77 .def("nbPoints", &IDataSeries::nbPoints)
80 .def("nbPoints", &IDataSeries::nbPoints)
78 .def_property_readonly("xAxisUnit", &IDataSeries::xAxisUnit)
81 .def_property_readonly("xAxisUnit", &IDataSeries::xAxisUnit)
79 .def_property_readonly("yAxisUnit", &IDataSeries::yAxisUnit)
82 .def_property_readonly("yAxisUnit", &IDataSeries::yAxisUnit)
80 .def_property_readonly("valuesUnit", &IDataSeries::valuesUnit)
83 .def_property_readonly("valuesUnit", &IDataSeries::valuesUnit)
81 .def("__getitem__", [](IDataSeries& serie, int key) {
84 .def("__getitem__", [](IDataSeries& serie, int key) {
82 return *(serie.begin()+key);
85 return *(serie.begin()+key);
83 }, py::is_operator())
86 }, py::is_operator())
84 .def("__len__", &IDataSeries::nbPoints)
87 .def("__len__", &IDataSeries::nbPoints)
85 .def("__iter__", [](IDataSeries& serie) {
88 .def("__iter__", [](IDataSeries& serie) {
86 return py::make_iterator(serie.begin(), serie.end());
89 return py::make_iterator(serie.begin(), serie.end());
87 }, py::keep_alive<0, 1>())
90 }, py::keep_alive<0, 1>())
88 .def("__repr__",__repr__<IDataSeries>);
91 .def("__repr__",__repr__<IDataSeries>);
89
92
90 py::class_<ScalarSeries, std::shared_ptr<ScalarSeries>, IDataSeries>(m, "ScalarSeries")
93 py::class_<ScalarSeries, std::shared_ptr<ScalarSeries>, IDataSeries>(m, "ScalarSeries")
91 .def("nbPoints", &ScalarSeries::nbPoints);
94 .def("nbPoints", &ScalarSeries::nbPoints);
92
95
93 py::class_<VectorSeries, std::shared_ptr<VectorSeries>, IDataSeries>(m, "VectorSeries")
96 py::class_<VectorSeries, std::shared_ptr<VectorSeries>, IDataSeries>(m, "VectorSeries")
94 .def("nbPoints", &VectorSeries::nbPoints);
97 .def("nbPoints", &VectorSeries::nbPoints);
95
98
96 py::class_<DataSeries<2>, std::shared_ptr<DataSeries<2>>, IDataSeries>(m,"DataSeries2d")
99 py::class_<DataSeries<2>, std::shared_ptr<DataSeries<2>>, IDataSeries>(m,"DataSeries2d")
97 .def_property_readonly("yAxis", py::overload_cast<>(&DataSeries<2>::yAxis, py::const_));
100 .def_property_readonly("yAxis", py::overload_cast<>(&DataSeries<2>::yAxis, py::const_));
98
101
99 py::class_<SpectrogramSeries, std::shared_ptr<SpectrogramSeries>, DataSeries<2>>(m, "SpectrogramSeries")
102 py::class_<SpectrogramSeries, std::shared_ptr<SpectrogramSeries>, DataSeries<2>>(m, "SpectrogramSeries")
100 .def("nbPoints", &SpectrogramSeries::nbPoints);
103 .def("nbPoints", &SpectrogramSeries::nbPoints);
101
104
102
105
103 py::class_<IDataProvider, std::shared_ptr<IDataProvider>>(m, "IDataProvider");
106 py::class_<IDataProvider, std::shared_ptr<IDataProvider>>(m, "IDataProvider");
104
107
105
108
106 py::class_<Variable,std::shared_ptr<Variable>>(m, "Variable")
109 py::class_<Variable,std::shared_ptr<Variable>>(m, "Variable")
107 .def(py::init<const QString&>())
110 .def(py::init<const QString&>())
108 .def_property("name", &Variable::name, &Variable::setName)
111 .def_property("name", &Variable::name, &Variable::setName)
109 .def_property("range", &Variable::range, &Variable::setRange)
112 .def_property("range", &Variable::range, &Variable::setRange)
110 .def_property("cacheRange", &Variable::cacheRange, &Variable::setCacheRange)
113 .def_property("cacheRange", &Variable::cacheRange, &Variable::setCacheRange)
111 .def_property_readonly("nbPoints", &Variable::nbPoints)
114 .def_property_readonly("nbPoints", &Variable::nbPoints)
112 .def_property_readonly("dataSeries", &Variable::dataSeries)
115 .def_property_readonly("dataSeries", &Variable::dataSeries)
113 .def("__len__", [](Variable& variable) {
116 .def("__len__", [](Variable& variable) {
114 auto rng = variable.dataSeries()->xAxisRange(variable.range().m_TStart,variable.range().m_TEnd);
117 auto rng = variable.dataSeries()->xAxisRange(variable.range().m_TStart,variable.range().m_TEnd);
115 return std::distance(rng.first,rng.second);
118 return std::distance(rng.first,rng.second);
116 })
119 })
117 .def("__iter__", [](Variable& variable) {
120 .def("__iter__", [](Variable& variable) {
118 auto rng = variable.dataSeries()->xAxisRange(variable.range().m_TStart,variable.range().m_TEnd);
121 auto rng = variable.dataSeries()->xAxisRange(variable.range().m_TStart,variable.range().m_TEnd);
119 return py::make_iterator(rng.first, rng.second);
122 return py::make_iterator(rng.first, rng.second);
120 }, py::keep_alive<0, 1>())
123 }, py::keep_alive<0, 1>())
121 .def("__getitem__", [](Variable& variable, int key) {
124 .def("__getitem__", [](Variable& variable, int key) {
122 //insane and slow!
125 //insane and slow!
123 auto rng = variable.dataSeries()->xAxisRange(variable.range().m_TStart,variable.range().m_TEnd);
126 auto rng = variable.dataSeries()->xAxisRange(variable.range().m_TStart,variable.range().m_TEnd);
124 if(key<0)
127 if(key<0)
125 return *(rng.second+key);
128 return *(rng.second+key);
126 else
129 else
127 return *(rng.first+key);
130 return *(rng.first+key);
128 })
131 })
129 .def("__repr__",__repr__<Variable>);
132 .def("__repr__",__repr__<Variable>);
130
133
131
134
132 py::class_<DateTimeRange>(m,"SqpRange")
135 py::class_<DateTimeRange>(m,"SqpRange")
133 //.def("fromDateTime", &DateTimeRange::fromDateTime, py::return_value_policy::move)
136 //.def("fromDateTime", &DateTimeRange::fromDateTime, py::return_value_policy::move)
134 .def(py::init([](double start, double stop){return DateTimeRange{start, stop};}))
137 .def(py::init([](double start, double stop){return DateTimeRange{start, stop};}))
135 .def(py::init([](system_clock::time_point start, system_clock::time_point stop)
138 .def(py::init([](system_clock::time_point start, system_clock::time_point stop)
136 {
139 {
137 double start_ = 0.001 * duration_cast<milliseconds>(start.time_since_epoch()).count();
140 double start_ = 0.001 * duration_cast<milliseconds>(start.time_since_epoch()).count();
138 double stop_ = 0.001 * duration_cast<milliseconds>(stop.time_since_epoch()).count();
141 double stop_ = 0.001 * duration_cast<milliseconds>(stop.time_since_epoch()).count();
139 return DateTimeRange{start_, stop_};
142 return DateTimeRange{start_, stop_};
140 }))
143 }))
141 .def_property_readonly("start", [](const DateTimeRange& range){
144 .def_property_readonly("start", [](const DateTimeRange& range){
142 return system_clock::from_time_t(range.m_TStart);
145 return system_clock::from_time_t(range.m_TStart);
143 })
146 })
144 .def_property_readonly("stop", [](const DateTimeRange& range){
147 .def_property_readonly("stop", [](const DateTimeRange& range){
145 return system_clock::from_time_t(range.m_TEnd);
148 return system_clock::from_time_t(range.m_TEnd);
146 })
149 })
147 .def("__repr__", __repr__<DateTimeRange>);
150 .def("__repr__", __repr__<DateTimeRange>);
148
151
149 }
152 }
General Comments 0
You need to be logged in to leave comments. Login now