Improved dpoint entity interactions

This commit is contained in:
Andrew nuark G 2020-12-16 00:01:36 +07:00
parent 96a8e7c586
commit 44ccc07360
2 changed files with 15 additions and 6 deletions

View file

@ -16,14 +16,22 @@ QString dpoint_entity::title() {
return this->_title; return this->_title;
} }
const QVector<entity_id> dpoint_entity::storages_ids() { const QVector<storage_entity> dpoint_entity::storages() {
return this->_storages_ids; return this->_storages;
} }
void dpoint_entity::serialize(QDataStream &output) { void dpoint_entity::serialize(QDataStream &output) {
output << this->_id << this->_title << this->_storages_ids; output << this->_id << this->_title << this->_storages.size();
for (auto &item : this->_storages) {
item.serialize(output);
}
} }
void dpoint_entity::deserialize(QDataStream &input) { void dpoint_entity::deserialize(QDataStream &input) {
input >> this->_id >> this->_title >> this->_storages_ids; int icnt;
input >> this->_id >> this->_title >> icnt;
this->_storages.resize(icnt);
for (int i = 0; i < icnt; i++) {
this->_storages[i].deserialize(input);
}
} }

View file

@ -2,6 +2,7 @@
#define DPOINT_ENTITY_H #define DPOINT_ENTITY_H
#include "IEntity.h" #include "IEntity.h"
#include "storage_entity.h"
#include <QString> #include <QString>
#include <QVector> #include <QVector>
@ -12,7 +13,7 @@ class dpoint_entity : public IEntity {
private: private:
entity_id _id; entity_id _id;
QString _title; QString _title;
QVector<entity_id> _storages_ids; QVector<storage_entity> _storages;
public: public:
dpoint_entity() = default; dpoint_entity() = default;
@ -20,7 +21,7 @@ public:
entity_id id(); entity_id id();
QString title(); QString title();
const QVector<entity_id> storages_ids(); const QVector<storage_entity> storages();
void serialize(QDataStream &output); void serialize(QDataStream &output);
void deserialize(QDataStream &input); void deserialize(QDataStream &input);