TrainControllerUi/src/trainOverlord/layout.h

44 lines
1.2 KiB
C++

#ifndef BLOCKSTORE_H
#define BLOCKSTORE_H
#include <QObject>
#include <memory>
#include <vector>
#include "block.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<std::weak_ptr<Train>, std::weak_ptr<BlockBorder>>> trainLimbo_;
void removeTrainFromAllBlocks(std::shared_ptr<Train> train);
void registerTrainInLimbo(std::shared_ptr<Train> train, std::shared_ptr<BlockBorder>);
public:
explicit Layout(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 trainArrivedAtReader(uint8_t reader, std::shared_ptr<Train> train, int tagType);
void itemAdded(std::weak_ptr<Item> item);
signals:
void trainArrivedAtBorder(std::weak_ptr<BlockBorder>, std::weak_ptr<Train> train, int tagType);
};
#endif // BLOCKSTORE_H