Minor system improvements
This commit is contained in:
parent
3e196f3574
commit
9686b96d8a
16 changed files with 144 additions and 86 deletions
|
|
@ -6,6 +6,7 @@ cargo_entity::cargo_entity(const QString &title, unsigned int volume) : _title(t
|
|||
for (auto bit : hash) {
|
||||
this->_id += bit;
|
||||
}
|
||||
this->_id += QRandomGenerator().generate64();
|
||||
}
|
||||
|
||||
entity_id cargo_entity::id() const {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "IEntity.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QRandomGenerator>
|
||||
#include <QCryptographicHash>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ dpoint_entity::dpoint_entity(entity_id dispatcher_id, const QString &title) : _d
|
|||
for (auto bit : hash) {
|
||||
this->_id += bit;
|
||||
}
|
||||
this->_id += QRandomGenerator().generate64();
|
||||
}
|
||||
|
||||
entity_id dpoint_entity::id() const {
|
||||
|
|
@ -33,9 +34,20 @@ void dpoint_entity::set_storages(QVector<storage_entity> storages) {
|
|||
}
|
||||
|
||||
void dpoint_entity::remove_storage(entity_id sid) {
|
||||
std::remove_if(this->_storages.begin(), this->_storages.end(), [sid](storage_entity ent) {
|
||||
return ent.id() == sid;
|
||||
});
|
||||
// std::remove_if(this->_storages.begin(), this->_storages.end(), [sid](storage_entity ent) {
|
||||
// return ent.id() == sid;
|
||||
// });
|
||||
|
||||
QVector<storage_entity> st(this->_storages);
|
||||
|
||||
for (int i = 0; i < st.length(); i++) {
|
||||
if (st[i].id() == sid) {
|
||||
st.removeAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this->set_storages(st);
|
||||
}
|
||||
|
||||
void dpoint_entity::add_storage(storage_entity ent) {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
#include <QRandomGenerator>
|
||||
#include <QCryptographicHash>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
entity_id storage_entity::__global_id = 0;
|
||||
|
||||
storage_entity::storage_entity(unsigned int capacity) : _capacity(capacity) {
|
||||
this->_id = ++storage_entity::__global_id;
|
||||
this->_id = ++storage_entity::__global_id + QRandomGenerator().generate64();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include "cargo_entity.h"
|
||||
|
||||
#include <QVector>
|
||||
#include <QCryptographicHash>
|
||||
#include <QRandomGenerator>
|
||||
|
||||
|
||||
class storage_entity : public IEntity {
|
||||
|
|
@ -13,7 +13,7 @@ private:
|
|||
static entity_id __global_id;
|
||||
|
||||
entity_id _id;
|
||||
unsigned int _capacity;
|
||||
unsigned int _capacity = 500000;
|
||||
QVector<cargo_entity> _cargo;
|
||||
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
user_entity::user_entity(const QString &login, const QString &password, UserRole role) : _login(login), _role(role) {
|
||||
this->_pwd_hash = QCryptographicHash::hash(password.toLocal8Bit(), QCryptographicHash::Sha3_256);
|
||||
foreach (auto bit, this->_pwd_hash) {
|
||||
this->_id += bit;
|
||||
}
|
||||
this->_id += QRandomGenerator().generate64();
|
||||
}
|
||||
|
||||
entity_id user_entity::id() const {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "IEntity.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QRandomGenerator>
|
||||
#include <QCryptographicHash>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
entity_id vessel_entity::__global_id = 0;
|
||||
|
||||
vessel_entity::vessel_entity(entity_id skipper_id, entity_id harbor_id, unsigned int capacity) : _skipper_id(skipper_id), _harbor_id(harbor_id), _capacity(capacity) {
|
||||
this->_id = ++vessel_entity::__global_id;
|
||||
this->_id = ++vessel_entity::__global_id + QRandomGenerator().generate64();
|
||||
}
|
||||
|
||||
entity_id vessel_entity::id() const {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
#include "cargo_entity.h"
|
||||
#include "dpoint_entity.h"
|
||||
|
||||
#include <QRandomGenerator>
|
||||
|
||||
|
||||
class vessel_entity : public IEntity {
|
||||
private:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue