Entities update

This commit is contained in:
Andrew nuark G 2020-12-23 01:30:11 +07:00
parent 4a3951938a
commit 05776f19f3
6 changed files with 18 additions and 7 deletions

View file

@ -53,7 +53,7 @@
<enum>QTabWidget::Rounded</enum>
</property>
<property name="currentIndex">
<number>2</number>
<number>0</number>
</property>
<property name="documentMode">
<bool>false</bool>

View file

@ -1,7 +1,7 @@
#include "dpoint_entity.h"
dpoint_entity::dpoint_entity(const QString &title) : _title(title) {
this->_id = 0;
dpoint_entity::dpoint_entity(entity_id dispatcher_id, const QString &title) : _dispatcher_id(dispatcher_id), _title(title) {
this->_id = dispatcher_id;
auto hash = QCryptographicHash::hash(title.toLocal8Bit(), QCryptographicHash::Md5);
for (auto bit : hash) {
this->_id += bit;
@ -12,6 +12,10 @@ entity_id dpoint_entity::id() const {
return this->_id;
}
entity_id dpoint_entity::dispatcher() const {
return this->_dispatcher_id;
}
QString dpoint_entity::title() const {
return this->_title;
}

View file

@ -12,14 +12,16 @@
class dpoint_entity : public IEntity {
private:
entity_id _id;
entity_id _dispatcher_id;
QString _title;
QVector<storage_entity> _storages;
public:
dpoint_entity() = default;
dpoint_entity(const QString &title);
dpoint_entity(entity_id dispatcher_id, const QString &title);
entity_id id() const;
entity_id dispatcher() const;
QString title() const;
const QVector<storage_entity> storages();

View file

@ -11,6 +11,10 @@ entity_id vessel_entity::id() const {
return this->_id;
}
entity_id vessel_entity::skipper() const {
return this->_skipper_id;
}
entity_id vessel_entity::harbor() const {
return this->_harbor_id;
}

View file

@ -21,6 +21,7 @@ public:
vessel_entity(entity_id skipper_id, entity_id harbor_id, unsigned int capacity);
entity_id id() const;
entity_id skipper() const;
entity_id harbor() const;
unsigned int capacity() const;
const QVector<cargo_entity> cargo();

View file

@ -164,8 +164,8 @@ void st_test::vessel_entity_serialization_test() {
f.open(QIODevice::WriteOnly);
stream.setDevice(&f);
dpoint_entity test_harbor("test_harbor_for_vessel");
ent1 = vessel_entity(test_harbor.id(), 256);
dpoint_entity test_harbor(0, "test_harbor_for_vessel");
ent1 = vessel_entity(0, test_harbor.id(), 256);
ent1.serialize(stream);
stream.setDevice(nullptr);
@ -265,7 +265,7 @@ void st_test::apparatus_check_auth_subsystem() {
void st_test::apparatus_check_object_subsystem() {
apparatus::init();
auto os = apparatus::instance()->get_object_subsystem();
dpoint_entity p("test");
dpoint_entity p(0, "test");
{
bool test = os->add_dpoint(p);
QVERIFY(test);