TrainControllerUi/src/trainOverlord/layout.h

42 lines
1 KiB
C++

#ifndef BLOCKSTORE_H
#define BLOCKSTORE_H
#include <QObject>
#include <memory>
#include <vector>
#include "block.h"
#include "overlorditemstore.h"
#include "blockborder.h"
#include "microcontroller.h"
#include "itemstore.h"
class Layout : public QObject
{
Q_OBJECT
private:
private:
std::vector<std::shared_ptr<Block>> blocks_;
std::vector<std::shared_ptr<BlockBorder>> borders_;
std::vector<std::pair<NfcUid, std::weak_ptr<BlockBorder>>> limbo_;
void removeTagFromAllBlocks(const NfcUid& tag);
void registerTagInLimbo(const NfcUid& tag, std::shared_ptr<BlockBorder>);
OverlordItemStore *items_;
public:
explicit Layout(OverlordItemStore *items, QObject *parent = nullptr);
void addBlock(std::shared_ptr<Block> block);
void addBorder(std::shared_ptr<BlockBorder> border);
void store(QJsonObject& json);
void load(const QJsonObject& json);
std::shared_ptr<BlockBorder> getBorder(uint32_t id);
std::shared_ptr<Block> getBlock(uint32_t id);
public slots:
void tagArrivedAtReader(uint8_t reader, NfcUid tag);
};
#endif // BLOCKSTORE_H