Add cargo entity
This commit is contained in:
parent
94b45aa946
commit
3ca5e0d537
2 changed files with 45 additions and 0 deletions
21
entities/cargo_entity.cpp
Normal file
21
entities/cargo_entity.cpp
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
#include "cargo_entity.h"
|
||||||
|
|
||||||
|
cargo_entity::cargo_entity(const QString &title, int volume) : _title(title), _volume(volume) {
|
||||||
|
this->_id = volume;
|
||||||
|
auto hash = QCryptographicHash::hash(title.toLocal8Bit(), QCryptographicHash::Md5);
|
||||||
|
for (auto bit : hash) {
|
||||||
|
this->_id |= bit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long long cargo_entity::id() {
|
||||||
|
return this->_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString cargo_entity::title() {
|
||||||
|
return this->_title;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int cargo_entity::volume() {
|
||||||
|
return this->_volume;
|
||||||
|
}
|
||||||
24
entities/cargo_entity.h
Normal file
24
entities/cargo_entity.h
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
#ifndef CARGO_ENTITY_H
|
||||||
|
#define CARGO_ENTITY_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QCryptographicHash>
|
||||||
|
|
||||||
|
|
||||||
|
class cargo_entity
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
unsigned long long _id;
|
||||||
|
QString _title;
|
||||||
|
unsigned int _volume;
|
||||||
|
|
||||||
|
public:
|
||||||
|
cargo_entity() = default;
|
||||||
|
cargo_entity(const QString &title, int volume);
|
||||||
|
|
||||||
|
unsigned long long id();
|
||||||
|
QString title();
|
||||||
|
unsigned int volume();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CARGO_ENTITY_H
|
||||||
Loading…
Add table
Add a link
Reference in a new issue