Intal version with working trainoverlord
This commit is contained in:
parent
a1f9fa172b
commit
872cc04a54
23 changed files with 992 additions and 46 deletions
43
src/trainOverlord/layout.h
Normal file
43
src/trainOverlord/layout.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#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
|
||||
Loading…
Add table
Add a link
Reference in a new issue