From 415ede2b913f95e5a5991e552e20fe738afbe898 Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 10 Sep 2020 00:43:40 +0700 Subject: [PATCH] Add entities w/out logic --- cargoentity.cpp | 5 +++-- cargoentity.h | 9 ++++++++- deliverypointentity.cpp | 6 ++++++ deliverypointentity.h | 19 +++++++++++++++++++ sea_transport.pro | 29 ++++++++++++++++++++++++----- storageentity.cpp | 8 ++++++++ storageentity.h | 19 +++++++++++++++++++ userentity.cpp | 14 ++++++++++++++ userentity.h | 22 ++++++++++++++++++++++ vesselentity.cpp | 9 +++++++++ vesselentity.h | 21 +++++++++++++++++++++ 11 files changed, 153 insertions(+), 8 deletions(-) create mode 100644 deliverypointentity.cpp create mode 100644 deliverypointentity.h create mode 100644 storageentity.cpp create mode 100644 storageentity.h create mode 100644 userentity.cpp create mode 100644 userentity.h create mode 100644 vesselentity.cpp create mode 100644 vesselentity.h diff --git a/cargoentity.cpp b/cargoentity.cpp index dbedcc0..1b63d35 100644 --- a/cargoentity.cpp +++ b/cargoentity.cpp @@ -1,6 +1,7 @@ #include "cargoentity.h" -CargoEntity::CargoEntity() +CargoEntity::CargoEntity(QString c_id, DeliveryPointEntity dest) { - + this->_cargo_id = c_id; + this->_destination = dest; } diff --git a/cargoentity.h b/cargoentity.h index e5fbdf0..a682774 100644 --- a/cargoentity.h +++ b/cargoentity.h @@ -1,11 +1,18 @@ #ifndef CARGOENTITY_H #define CARGOENTITY_H +#include "deliverypointentity.h" + +#include + class CargoEntity { + QString _cargo_id; + DeliveryPointEntity _destination; + public: - CargoEntity(); + CargoEntity(QString _cargo_id, DeliveryPointEntity _destination); }; #endif // CARGOENTITY_H diff --git a/deliverypointentity.cpp b/deliverypointentity.cpp new file mode 100644 index 0000000..f541f83 --- /dev/null +++ b/deliverypointentity.cpp @@ -0,0 +1,6 @@ +#include "deliverypointentity.h" + +DeliveryPointEntity::DeliveryPointEntity(QString title) +{ + this->_title = title; +} diff --git a/deliverypointentity.h b/deliverypointentity.h new file mode 100644 index 0000000..6cb566f --- /dev/null +++ b/deliverypointentity.h @@ -0,0 +1,19 @@ +#ifndef DELIVERYPOINTENTITY_H +#define DELIVERYPOINTENTITY_H + +#include "storageentity.h" + +#include +#include + + +class DeliveryPointEntity +{ + QString _title; + std::vector _storage; + +public: + DeliveryPointEntity(QString title); +}; + +#endif // DELIVERYPOINTENTITY_H diff --git a/sea_transport.pro b/sea_transport.pro index fa7d61e..16df44b 100644 --- a/sea_transport.pro +++ b/sea_transport.pro @@ -10,18 +10,37 @@ CONFIG += c++11 SOURCES += \ authwindow.cpp \ + cargoeditdialog.cpp \ + cargoentity.cpp \ + deliverypointeditdialog.cpp \ + deliverypointentity.cpp \ main.cpp \ - mainwindow.cpp \ - vesseleditdialog.cpp + storageeditdialog.cpp \ + storageentity.cpp \ + usereditdialog.cpp \ + userentity.cpp \ + vesseleditdialog.cpp \ + vesselentity.cpp HEADERS += \ authwindow.h \ - mainwindow.h \ - vesseleditdialog.h + cargoeditdialog.h \ + cargoentity.h \ + deliverypointeditdialog.h \ + deliverypointentity.h \ + storageeditdialog.h \ + storageentity.h \ + usereditdialog.h \ + userentity.h \ + vesseleditdialog.h \ + vesselentity.h FORMS += \ authwindow.ui \ - mainwindow.ui \ + cargoeditdialog.ui \ + deliverypointeditdialog.ui \ + storageeditdialog.ui \ + usereditdialog.ui \ vesseleditdialog.ui # Default rules for deployment. diff --git a/storageentity.cpp b/storageentity.cpp new file mode 100644 index 0000000..31b70bb --- /dev/null +++ b/storageentity.cpp @@ -0,0 +1,8 @@ +#include "storageentity.h" + +StorageEntity::StorageEntity(int st_id, int mx_cap) +{ + this->_storage_id = st_id; + this->_max_capacity = mx_cap; + this->_cargo.reserve(mx_cap); +} diff --git a/storageentity.h b/storageentity.h new file mode 100644 index 0000000..5ec6d36 --- /dev/null +++ b/storageentity.h @@ -0,0 +1,19 @@ +#ifndef STORAGEENTITY_H +#define STORAGEENTITY_H + +#include "cargoentity.h" + +#include + + +class StorageEntity +{ + int _storage_id; + int _max_capacity; + std::vector _cargo; + +public: + StorageEntity(int st_id, int mx_cap); +}; + +#endif // STORAGEENTITY_H diff --git a/userentity.cpp b/userentity.cpp new file mode 100644 index 0000000..55971e9 --- /dev/null +++ b/userentity.cpp @@ -0,0 +1,14 @@ +#include "userentity.h" + +UserEntity::UserEntity(QString login, QString password, UserEntity::UserRoleEnum role) +{ + this->_login = login; + + this->_password_hash = 0; + for (auto pchar : password) { + this->_password_hash += pchar.unicode(); + } + this->_password_hash %= (1 << 16); + + this->_role = role; +} diff --git a/userentity.h b/userentity.h new file mode 100644 index 0000000..f1ec583 --- /dev/null +++ b/userentity.h @@ -0,0 +1,22 @@ +#ifndef USERENTITY_H +#define USERENTITY_H + +#include + +typedef long long pwd_type; + +class UserEntity +{ + QString _login; + pwd_type _password_hash; + enum UserRoleEnum { + ADMINISTRATOR = 0, + DISPATCHER = 1, + CAPTAIN = 2 + } _role; + +public: + UserEntity(QString login, QString password, UserEntity::UserRoleEnum role); +}; + +#endif // USERENTITY_H diff --git a/vesselentity.cpp b/vesselentity.cpp new file mode 100644 index 0000000..14cf57d --- /dev/null +++ b/vesselentity.cpp @@ -0,0 +1,9 @@ +#include "vesselentity.h" + +VesselEntity::VesselEntity(int v_id, QString hp, int mx_cap) +{ + this->_vessel_id = v_id; + this->_home_port = hp; + this->_max_capacity = mx_cap; + this->_cargo_list.reserve(mx_cap); +} diff --git a/vesselentity.h b/vesselentity.h new file mode 100644 index 0000000..abb8453 --- /dev/null +++ b/vesselentity.h @@ -0,0 +1,21 @@ +#ifndef VESSELENTITY_H +#define VESSELENTITY_H + +#include "cargoentity.h" + +#include +#include + + +class VesselEntity +{ + int _vessel_id; + QString _home_port; + int _max_capacity; + std::vector _cargo_list; + +public: + VesselEntity(int v_id, QString hp, int mx_cap); +}; + +#endif // VESSELENTITY_H