##// END OF EJS Templates
Few minor tweaks and removed memory leak.....
jeandet -
r73:68c01155acd2
parent child
Show More
@@ -4,7 +4,6
4 #include "CoreGlobal.h"
4 #include "CoreGlobal.h"
5
5
6 #include <Common/spimpl.h>
6 #include <Common/spimpl.h>
7
8 #include <QVariant>
7 #include <QVariant>
9 #include <QVector>
8 #include <QVector>
10
9
@@ -13,152 +12,164 class DataSourceItemAction;
13 /**
12 /**
14 * Possible types of an item
13 * Possible types of an item
15 */
14 */
16 enum class DataSourceItemType { NODE, PRODUCT, COMPONENT };
15 enum class DataSourceItemType
16 {
17 NODE,
18 PRODUCT,
19 COMPONENT
20 };
17
21
18 /**
22 /**
19 * @brief The DataSourceItem class aims to represent a structure element of a data source.
23 * @brief The DataSourceItem class aims to represent a structure element of a
20 * A data source has a tree structure that is made up of a main DataSourceItem object (root)
24 * data source. A data source has a tree structure that is made up of a main
21 * containing other DataSourceItem objects (children).
25 * DataSourceItem object (root) containing other DataSourceItem objects
22 * For each DataSourceItem can be associated a set of data representing it.
26 * (children). For each DataSourceItem can be associated a set of data
27 * representing it.
23 */
28 */
24 class SCIQLOP_CORE_EXPORT DataSourceItem {
29 class SCIQLOP_CORE_EXPORT DataSourceItem
30 {
25 public:
31 public:
26 /// Key associated with the name of the item
32 /// Key associated with the name of the item
27 static const QString NAME_DATA_KEY;
33 static const QString NAME_DATA_KEY;
28 /// Key associated with the plugin of the item
34 /// Key associated with the plugin of the item
29 static const QString PLUGIN_DATA_KEY;
35 static const QString PLUGIN_DATA_KEY;
30 /// Key associated with a unique id of the plugin
36 /// Key associated with a unique id of the plugin
31 static const QString ID_DATA_KEY;
37 static const QString ID_DATA_KEY;
32
38
33 explicit DataSourceItem(DataSourceItemType type, const QString &name);
39 explicit DataSourceItem(DataSourceItemType type, const QString& name);
34 explicit DataSourceItem(DataSourceItemType type, QVariantHash data = {});
40 explicit DataSourceItem(DataSourceItemType type, QVariantHash data = {});
35
41
36 std::unique_ptr<DataSourceItem> clone() const;
42 std::unique_ptr<DataSourceItem> clone() const;
37
43
38 /// @return the actions of the item as a vector
44 /// @return the actions of the item as a vector
39 QVector<DataSourceItemAction *> actions() const noexcept;
45 QVector<DataSourceItemAction*> actions() const noexcept;
40
46
41 /**
47 /**
42 * Adds an action to the item. The item takes ownership of the action, and the action is
48 * Adds an action to the item. The item takes ownership of the action, and the
43 * automatically associated to the item
49 * action is automatically associated to the item
44 * @param action the action to add
50 * @param action the action to add
45 */
51 */
46 void addAction(std::unique_ptr<DataSourceItemAction> action) noexcept;
52 void addAction(std::unique_ptr<DataSourceItemAction> action) noexcept;
47
53
48 /**
54 /**
49 * Adds a child to the item. The item takes ownership of the child.
55 * Adds a child to the item. The item takes ownership of the child.
50 * @param child the child to add
56 * @param child the child to add
51 */
57 */
52 void appendChild(std::unique_ptr<DataSourceItem> child) noexcept;
58 void appendChild(std::unique_ptr<DataSourceItem> child) noexcept;
53
59
54 /**
60 /**
55 * Returns the item's child associated to an index
61 * Returns the item's child associated to an index
56 * @param childIndex the index to search
62 * @param childIndex the index to search
57 * @return a pointer to the child if index is valid, nullptr otherwise
63 * @return a pointer to the child if index is valid, nullptr otherwise
58 */
64 */
59 DataSourceItem *child(int childIndex) const noexcept;
65 DataSourceItem* child(int childIndex) const noexcept;
60
66
61 int childCount() const noexcept;
67 int childCount() const noexcept;
62
68
63 /**
69 /**
64 * Get the data associated to a key
70 * Get the data associated to a key
65 * @param key the key to search
71 * @param key the key to search
66 * @return the data found if key is valid, default QVariant otherwise
72 * @return the data found if key is valid, default QVariant otherwise
67 */
73 */
68 QVariant data(const QString &key) const noexcept;
74 QVariant data(const QString& key) const noexcept;
69
75
70 /// Gets all data
76 /// Gets all data
71 QVariantHash data() const noexcept;
77 QVariantHash data() const noexcept;
72
78
73 /**
79 /**
74 * Merge in the item the source item passed as parameter.
80 * Merge in the item the source item passed as parameter.
75 *
81 *
76 * The merge is done by adding as child of the item the complete tree represented by the source
82 * The merge is done by adding as child of the item the complete tree
77 * item. If a part of the tree already exists in the item (based on the name of the nodes), it
83 * represented by the source item. If a part of the tree already exists in the
78 * is merged by completing the existing tree by items "leaves" (products, components or nodes
84 * item (based on the name of the nodes), it is merged by completing the
79 * with no child).
85 * existing tree by items "leaves" (products, components or nodes with no
80 *
86 * child).
81 * For example, with item representing the tree:
87 *
82 * R (root node)
88 * For example, with item representing the tree:
83 * - N1 (node)
89 * R (root node)
84 * -- N11 (node)
90 * - N1 (node)
85 * --- P1 (product)
91 * -- N11 (node)
86 * --- P2 (product)
92 * --- P1 (product)
87 * - N2 (node)
93 * --- P2 (product)
88 *
94 * - N2 (node)
89 * and the source item representing the tree:
95 *
90 * N1 (root node)
96 * and the source item representing the tree:
91 * - N11 (node)
97 * N1 (root node)
92 * -- P3 (product)
98 * - N11 (node)
93 * - N12 (node)
99 * -- P3 (product)
94 *
100 * - N12 (node)
95 * The leaves of the source item to merge into the item are N1/N11/P3 and N1/N12 => we therefore
101 *
96 * have the following merge result:
102 * The leaves of the source item to merge into the item are N1/N11/P3 and
97 * R
103 * N1/N12 => we therefore have the following merge result:
98 * - N1
104 * R
99 * -- N11
105 * - N1
100 * --- P1
106 * -- N11
101 * --- P2
107 * --- P1
102 * --- P3 (added leaf)
108 * --- P2
103 * -- N12 (added leaf)
109 * --- P3 (added leaf)
104 *
110 * -- N12 (added leaf)
105 * @param item the source item
111 *
106 * @remarks No control is performed on products or components that are merged into the same tree
112 * @param item the source item
107 * part (two products or components may have the same name)
113 * @remarks No control is performed on products or components that are merged
108 * @remarks the merge is made by copy (source item is not changed and still exists after the
114 * into the same tree part (two products or components may have the same name)
109 * operation)
115 * @remarks the merge is made by copy (source item is not changed and still
110 */
116 * exists after the operation)
111 void merge(const DataSourceItem &item);
117 */
112
118 void merge(const DataSourceItem& item);
113 bool isRoot() const noexcept;
119
114
120 bool isRoot() const noexcept;
115 QString name() const noexcept;
121
116
122 QString name() const noexcept;
117 /**
123
118 * Get the item's parent
124 /**
119 * @return a pointer to the parent if it exists, nullptr if the item is a root
125 * Get the item's parent
120 */
126 * @return a pointer to the parent if it exists, nullptr if the item is a root
121 DataSourceItem *parentItem() const noexcept;
127 */
122
128 DataSourceItem* parentItem() const noexcept;
123 /**
129
124 * Gets the item's root
130 /**
125 * @return the top parent, the item itself if it's the root item
131 * Gets the item's root
126 */
132 * @return the top parent, the item itself if it's the root item
127 const DataSourceItem &rootItem() const noexcept;
133 */
128
134 const DataSourceItem& rootItem() const noexcept;
129 /**
135
130 * Sets or appends a value to a key
136 /**
131 * @param key the key
137 * Sets or appends a value to a key
132 * @param value the value
138 * @param key the key
133 * @param append if true, the value is added to the values already existing for the key,
139 * @param value the value
134 * otherwise it replaces the existing values
140 * @param append if true, the value is added to the values already existing
135 */
141 * for the key, otherwise it replaces the existing values
136 void setData(const QString &key, const QVariant &value, bool append = false) noexcept;
142 */
137
143 void setData(const QString& key, const QVariant& value,
138 DataSourceItemType type() const noexcept;
144 bool append = false) noexcept;
139
145
140 /**
146 DataSourceItemType type() const noexcept;
141 * @brief Searches the first child matching the specified data.
147
142 * @param data The data to search.
148 /**
143 * @param recursive So the search recursively.
149 * @brief Searches the first child matching the specified data.
144 * @return the item matching the data or nullptr if it was not found.
150 * @param data The data to search.
145 */
151 * @param recursive So the search recursively.
146 DataSourceItem *findItem(const QVariantHash &data, bool recursive);
152 * @return the item matching the data or nullptr if it was not found.
147
153 */
148 /**
154 DataSourceItem* findItem(const QVariantHash& data, bool recursive);
149 * @brief Searches the first child matching the specified \p ID_DATA_KEY in its metadata.
155
150 * @param id The id to search.
156 DataSourceItem* findItem(const QString& name);
151 * @param recursive So the search recursively.
157
152 * @return the item matching the data or nullptr if it was not found.
158 /**
153 */
159 * @brief Searches the first child matching the specified \p ID_DATA_KEY in
154 DataSourceItem *findItem(const QString &datasourceIdKey, bool recursive);
160 * its metadata.
155
161 * @param id The id to search.
156 bool operator==(const DataSourceItem &other);
162 * @param recursive So the search recursively.
157 bool operator!=(const DataSourceItem &other);
163 * @return the item matching the data or nullptr if it was not found.
164 */
165 DataSourceItem* findItem(const QString& datasourceIdKey, bool recursive);
166
167 bool operator==(const DataSourceItem& other);
168 bool operator!=(const DataSourceItem& other);
158
169
159 private:
170 private:
160 class DataSourceItemPrivate;
171 class DataSourceItemPrivate;
161 spimpl::unique_impl_ptr<DataSourceItemPrivate> impl;
172 spimpl::unique_impl_ptr<DataSourceItemPrivate> impl;
162 };
173 };
163
174
164 #endif // SCIQLOP_DATASOURCEITEMMODEL_H
175 #endif // SCIQLOP_DATASOURCEITEMMODEL_H
@@ -74,6 +74,8 public:
74 data.push_back(_variable->data().get());
74 data.push_back(_variable->data().get());
75 _variable->setData(data, _range, true);
75 _variable->setData(data, _range, true);
76 }
76 }
77 std::for_each(std::begin(data), std::end(data),
78 [](TimeSeries::ITimeSerie* ts) { delete ts; });
77 emit transactionComplete();
79 emit transactionComplete();
78 }
80 }
79 signals:
81 signals:
@@ -1,205 +1,221
1 #include <DataSource/DataSourceItem.h>
1 #include <DataSource/DataSourceItem.h>
2 #include <DataSource/DataSourceItemAction.h>
2 #include <DataSource/DataSourceItemAction.h>
3 #include <DataSource/DataSourceItemMergeHelper.h>
3 #include <DataSource/DataSourceItemMergeHelper.h>
4
5 #include <QVector>
4 #include <QVector>
6
5
7 const QString DataSourceItem::NAME_DATA_KEY = QStringLiteral("name");
6 const QString DataSourceItem::NAME_DATA_KEY = QStringLiteral("name");
8 const QString DataSourceItem::PLUGIN_DATA_KEY = QStringLiteral("plugin");
7 const QString DataSourceItem::PLUGIN_DATA_KEY = QStringLiteral("plugin");
9 const QString DataSourceItem::ID_DATA_KEY = QStringLiteral("uuid");
8 const QString DataSourceItem::ID_DATA_KEY = QStringLiteral("uuid");
10
9
11 struct DataSourceItem::DataSourceItemPrivate {
10 struct DataSourceItem::DataSourceItemPrivate
12 explicit DataSourceItemPrivate(DataSourceItemType type, QVariantHash data)
11 {
13 : m_Parent{nullptr}, m_Children{}, m_Type{type}, m_Data{std::move(data)}, m_Actions{}
12 explicit DataSourceItemPrivate(DataSourceItemType type, QVariantHash data)
14 {
13 : m_Parent{nullptr},
15 }
14 m_Children{}, m_Type{type}, m_Data{std::move(data)}, m_Actions{}
15 {}
16
16
17 DataSourceItem *m_Parent;
17 DataSourceItem* m_Parent;
18 std::vector<std::unique_ptr<DataSourceItem> > m_Children;
18 std::vector<std::unique_ptr<DataSourceItem>> m_Children;
19 DataSourceItemType m_Type;
19 DataSourceItemType m_Type;
20 QVariantHash m_Data;
20 QVariantHash m_Data;
21 std::vector<std::unique_ptr<DataSourceItemAction> > m_Actions;
21 std::vector<std::unique_ptr<DataSourceItemAction>> m_Actions;
22 };
22 };
23
23
24 DataSourceItem::DataSourceItem(DataSourceItemType type, const QString &name)
24 DataSourceItem::DataSourceItem(DataSourceItemType type, const QString& name)
25 : DataSourceItem{type, QVariantHash{{NAME_DATA_KEY, name}}}
25 : DataSourceItem{type, QVariantHash{{NAME_DATA_KEY, name}}}
26 {
26 {}
27 }
28
27
29 DataSourceItem::DataSourceItem(DataSourceItemType type, QVariantHash data)
28 DataSourceItem::DataSourceItem(DataSourceItemType type, QVariantHash data)
30 : impl{spimpl::make_unique_impl<DataSourceItemPrivate>(type, std::move(data))}
29 : impl{spimpl::make_unique_impl<DataSourceItemPrivate>(type,
31 {
30 std::move(data))}
32 }
31 {}
33
32
34 std::unique_ptr<DataSourceItem> DataSourceItem::clone() const
33 std::unique_ptr<DataSourceItem> DataSourceItem::clone() const
35 {
34 {
36 auto result = std::make_unique<DataSourceItem>(impl->m_Type, impl->m_Data);
35 auto result = std::make_unique<DataSourceItem>(impl->m_Type, impl->m_Data);
37
36
38 // Clones children
37 // Clones children
39 for (const auto &child : impl->m_Children) {
38 for(const auto& child : impl->m_Children)
40 result->appendChild(std::move(child->clone()));
39 {
41 }
40 result->appendChild(std::move(child->clone()));
41 }
42
42
43 // Clones actions
43 // Clones actions
44 for (const auto &action : impl->m_Actions) {
44 for(const auto& action : impl->m_Actions)
45 result->addAction(std::move(action->clone()));
45 {
46 }
46 result->addAction(std::move(action->clone()));
47 }
47
48
48 return result;
49 return result;
49 }
50 }
50
51
51 QVector<DataSourceItemAction *> DataSourceItem::actions() const noexcept
52 QVector<DataSourceItemAction*> DataSourceItem::actions() const noexcept
52 {
53 {
53 auto result = QVector<DataSourceItemAction *>{};
54 auto result = QVector<DataSourceItemAction*>{};
54
55
55 std::transform(std::cbegin(impl->m_Actions), std::cend(impl->m_Actions),
56 std::transform(std::cbegin(impl->m_Actions), std::cend(impl->m_Actions),
56 std::back_inserter(result), [](const auto &action) { return action.get(); });
57 std::back_inserter(result),
58 [](const auto& action) { return action.get(); });
57
59
58 return result;
60 return result;
59 }
61 }
60
62
61 void DataSourceItem::addAction(std::unique_ptr<DataSourceItemAction> action) noexcept
63 void DataSourceItem::addAction(
64 std::unique_ptr<DataSourceItemAction> action) noexcept
62 {
65 {
63 action->setDataSourceItem(this);
66 action->setDataSourceItem(this);
64 impl->m_Actions.push_back(std::move(action));
67 impl->m_Actions.push_back(std::move(action));
65 }
68 }
66
69
67 void DataSourceItem::appendChild(std::unique_ptr<DataSourceItem> child) noexcept
70 void DataSourceItem::appendChild(std::unique_ptr<DataSourceItem> child) noexcept
68 {
71 {
69 child->impl->m_Parent = this;
72 child->impl->m_Parent = this;
70 impl->m_Children.push_back(std::move(child));
73 impl->m_Children.push_back(std::move(child));
71 }
74 }
72
75
73 DataSourceItem *DataSourceItem::child(int childIndex) const noexcept
76 DataSourceItem* DataSourceItem::child(int childIndex) const noexcept
74 {
77 {
75 if (childIndex < 0 || childIndex >= childCount()) {
78 if(childIndex < 0 || childIndex >= childCount()) { return nullptr; }
76 return nullptr;
79 else
77 }
80 {
78 else {
81 return impl->m_Children.at(childIndex).get();
79 return impl->m_Children.at(childIndex).get();
82 }
80 }
81 }
83 }
82
84
83 int DataSourceItem::childCount() const noexcept
85 int DataSourceItem::childCount() const noexcept
84 {
86 {
85 return impl->m_Children.size();
87 return impl->m_Children.size();
86 }
88 }
87
89
88 QVariant DataSourceItem::data(const QString &key) const noexcept
90 QVariant DataSourceItem::data(const QString& key) const noexcept
89 {
91 {
90 return impl->m_Data.value(key);
92 return impl->m_Data.value(key);
91 }
93 }
92
94
93 QVariantHash DataSourceItem::data() const noexcept
95 QVariantHash DataSourceItem::data() const noexcept { return impl->m_Data; }
94 {
95 return impl->m_Data;
96 }
97
96
98 void DataSourceItem::merge(const DataSourceItem &item)
97 void DataSourceItem::merge(const DataSourceItem& item)
99 {
98 {
100 DataSourceItemMergeHelper::merge(item, *this);
99 DataSourceItemMergeHelper::merge(item, *this);
101 }
100 }
102
101
103 bool DataSourceItem::isRoot() const noexcept
102 bool DataSourceItem::isRoot() const noexcept
104 {
103 {
105 return impl->m_Parent == nullptr;
104 return impl->m_Parent == nullptr;
106 }
105 }
107
106
108 QString DataSourceItem::name() const noexcept
107 QString DataSourceItem::name() const noexcept
109 {
108 {
110 return data(NAME_DATA_KEY).toString();
109 return data(NAME_DATA_KEY).toString();
111 }
110 }
112
111
113 DataSourceItem *DataSourceItem::parentItem() const noexcept
112 DataSourceItem* DataSourceItem::parentItem() const noexcept
114 {
113 {
115 return impl->m_Parent;
114 return impl->m_Parent;
116 }
115 }
117
116
118 const DataSourceItem &DataSourceItem::rootItem() const noexcept
117 const DataSourceItem& DataSourceItem::rootItem() const noexcept
119 {
118 {
120 return isRoot() ? *this : parentItem()->rootItem();
119 return isRoot() ? *this : parentItem()->rootItem();
121 }
120 }
122
121
123 void DataSourceItem::setData(const QString &key, const QVariant &value, bool append) noexcept
122 void DataSourceItem::setData(const QString& key, const QVariant& value,
123 bool append) noexcept
124 {
124 {
125 auto it = impl->m_Data.constFind(key);
125 auto it = impl->m_Data.constFind(key);
126 if (append && it != impl->m_Data.constEnd()) {
126 if(append && it != impl->m_Data.constEnd())
127 // Case of an existing value to which we want to add to the new value
127 {
128 if (it->canConvert<QVariantList>()) {
128 // Case of an existing value to which we want to add to the new value
129 auto variantList = it->value<QVariantList>();
129 if(it->canConvert<QVariantList>())
130 variantList.append(value);
130 {
131 auto variantList = it->value<QVariantList>();
132 variantList.append(value);
131
133
132 impl->m_Data.insert(key, variantList);
134 impl->m_Data.insert(key, variantList);
133 }
134 else {
135 impl->m_Data.insert(key, QVariantList{*it, value});
136 }
137 }
135 }
138 else {
136 else
139 // Other cases :
137 {
140 // - new value in map OR
138 impl->m_Data.insert(key, QVariantList{*it, value});
141 // - replacement of an existing value (not appending)
142 impl->m_Data.insert(key, value);
143 }
139 }
140 }
141 else
142 {
143 // Other cases :
144 // - new value in map OR
145 // - replacement of an existing value (not appending)
146 impl->m_Data.insert(key, value);
147 }
144 }
148 }
145
149
146 DataSourceItemType DataSourceItem::type() const noexcept
150 DataSourceItemType DataSourceItem::type() const noexcept
147 {
151 {
148 return impl->m_Type;
152 return impl->m_Type;
149 }
153 }
150
154
151 DataSourceItem *DataSourceItem::findItem(const QVariantHash &data, bool recursive)
155 DataSourceItem* DataSourceItem::findItem(const QVariantHash& data,
156 bool recursive)
152 {
157 {
153 for (const auto &child : impl->m_Children) {
158 for(const auto& child : impl->m_Children)
154 if (child->impl->m_Data == data) {
159 {
155 return child.get();
160 if(child->impl->m_Data == data) { return child.get(); }
156 }
157
161
158 if (recursive) {
162 if(recursive)
159 if (auto foundItem = child->findItem(data, true)) {
163 {
160 return foundItem;
164 if(auto foundItem = child->findItem(data, true)) { return foundItem; }
161 }
162 }
163 }
165 }
166 }
164
167
165 return nullptr;
168 return nullptr;
166 }
169 }
167
170
168 DataSourceItem *DataSourceItem::findItem(const QString &datasourceIdKey, bool recursive)
171 DataSourceItem* DataSourceItem::findItem(const QString& name)
169 {
172 {
170 for (const auto &child : impl->m_Children) {
173 auto item =
171 auto childId = child->impl->m_Data.value(ID_DATA_KEY);
174 std::find_if(std::cbegin(impl->m_Children), std::cend(impl->m_Children),
172 if (childId == datasourceIdKey) {
175 [name](const auto& item) { return item->name() == name; });
173 return child.get();
176 if(item != std::cend(impl->m_Children)) return item->get();
174 }
177 return nullptr;
178 }
175
179
176 if (recursive) {
180 DataSourceItem* DataSourceItem::findItem(const QString& datasourceIdKey,
177 if (auto foundItem = child->findItem(datasourceIdKey, true)) {
181 bool recursive)
178 return foundItem;
182 {
179 }
183 for(const auto& child : impl->m_Children)
180 }
184 {
185 auto childId = child->impl->m_Data.value(ID_DATA_KEY);
186 if(childId == datasourceIdKey) { return child.get(); }
187
188 if(recursive)
189 {
190 if(auto foundItem = child->findItem(datasourceIdKey, true))
191 { return foundItem; }
181 }
192 }
193 }
182
194
183 return nullptr;
195 return nullptr;
184 }
196 }
185
197
186 bool DataSourceItem::operator==(const DataSourceItem &other)
198 bool DataSourceItem::operator==(const DataSourceItem& other)
187 {
199 {
188 // Compares items' attributes
200 // Compares items' attributes
189 if (std::tie(impl->m_Type, impl->m_Data) == std::tie(other.impl->m_Type, other.impl->m_Data)) {
201 if(std::tie(impl->m_Type, impl->m_Data) ==
190 // Compares contents of items' children
202 std::tie(other.impl->m_Type, other.impl->m_Data))
191 return std::equal(std::cbegin(impl->m_Children), std::cend(impl->m_Children),
203 {
192 std::cbegin(other.impl->m_Children), std::cend(other.impl->m_Children),
204 // Compares contents of items' children
193 [](const auto &itemChild, const auto &otherChild) {
205 return std::equal(
194 return *itemChild == *otherChild;
206 std::cbegin(impl->m_Children), std::cend(impl->m_Children),
195 });
207 std::cbegin(other.impl->m_Children), std::cend(other.impl->m_Children),
196 }
208 [](const auto& itemChild, const auto& otherChild) {
197 else {
209 return *itemChild == *otherChild;
198 return false;
210 });
199 }
211 }
212 else
213 {
214 return false;
215 }
200 }
216 }
201
217
202 bool DataSourceItem::operator!=(const DataSourceItem &other)
218 bool DataSourceItem::operator!=(const DataSourceItem& other)
203 {
219 {
204 return !(*this == other);
220 return !(*this == other);
205 }
221 }
@@ -114,7 +114,8 PYBIND11_MODULE(pysciqlopcore, m)
114 },
114 },
115 py::return_value_policy::reference);
115 py::return_value_policy::reference);
116
116
117 py::class_<ScalarTimeSerie, TimeSeries::ITimeSerie>(m, "ScalarTimeSerie")
117 py::class_<ScalarTimeSerie, TimeSeries::ITimeSerie,
118 std::shared_ptr<ScalarTimeSerie>>(m, "ScalarTimeSerie")
118 .def(py::init<>())
119 .def(py::init<>())
119 .def(py::init<std::size_t>())
120 .def(py::init<std::size_t>())
120 .def(py::init([](py::array_t<double> t, py::array_t<double> values) {
121 .def(py::init([](py::array_t<double> t, py::array_t<double> values) {
@@ -137,7 +138,8 PYBIND11_MODULE(pysciqlopcore, m)
137 .def_readwrite("y", &VectorTimeSerie::raw_value_type::y)
138 .def_readwrite("y", &VectorTimeSerie::raw_value_type::y)
138 .def_readwrite("z", &VectorTimeSerie::raw_value_type::z);
139 .def_readwrite("z", &VectorTimeSerie::raw_value_type::z);
139
140
140 py::class_<VectorTimeSerie, TimeSeries::ITimeSerie>(m, "VectorTimeSerie")
141 py::class_<VectorTimeSerie, TimeSeries::ITimeSerie,
142 std::shared_ptr<VectorTimeSerie>>(m, "VectorTimeSerie")
141 .def(py::init<>())
143 .def(py::init<>())
142 .def(py::init<std::size_t>())
144 .def(py::init<std::size_t>())
143 .def(py::init([](py::array_t<double> t, py::array_t<double> values) {
145 .def(py::init([](py::array_t<double> t, py::array_t<double> values) {
@@ -173,8 +175,8 PYBIND11_MODULE(pysciqlopcore, m)
173 [](SpectrogramTimeSerie::iterator_t& self, std::size_t key,
175 [](SpectrogramTimeSerie::iterator_t& self, std::size_t key,
174 double value) { (*self)[key] = value; });
176 double value) { (*self)[key] = value; });
175
177
176 py::class_<SpectrogramTimeSerie, TimeSeries::ITimeSerie>(
178 py::class_<SpectrogramTimeSerie, TimeSeries::ITimeSerie,
177 m, "SpectrogramTimeSerie")
179 std::shared_ptr<SpectrogramTimeSerie>>(m, "SpectrogramTimeSerie")
178 .def(py::init<>())
180 .def(py::init<>())
179 .def(py::init<const std::vector<std::size_t>>())
181 .def(py::init<const std::vector<std::size_t>>())
180 .def(py::init([](py::array_t<double> t, py::array_t<double> values) {
182 .def(py::init([](py::array_t<double> t, py::array_t<double> values) {
General Comments 0
You need to be logged in to leave comments. Login now