Skip to content
Snippets Groups Projects
Commit 415aa659 authored by Martin Hanzik's avatar Martin Hanzik Committed by Jan Trávníček
Browse files

Replace uint8_t with size_t

parent 64c329d7
No related branches found
No related tags found
No related merge requests found
...@@ -24,12 +24,12 @@ Algorithm::Algorithm(std::string fullName) ...@@ -24,12 +24,12 @@ Algorithm::Algorithm(std::string fullName)
} }
} }
   
uint8_t Algorithm::getInputCount() const { size_t Algorithm::getInputCount() const {
if (this->overloads.empty()) { if (this->overloads.empty()) {
throw std::runtime_error { std::string("Input count has not yet been determined for algorithm ") + this->fullName }; throw std::runtime_error { std::string("Input count has not yet been determined for algorithm ") + this->fullName };
} }
   
return static_cast<uint8_t>(this->overloads[0].parameterTypes.size()); return this->overloads[0].parameterTypes.size();
} }
   
void Algorithm::addOverload(Algorithm::Overload overload) { void Algorithm::addOverload(Algorithm::Overload overload) {
......
...@@ -22,7 +22,7 @@ public: ...@@ -22,7 +22,7 @@ public:
const std::string& getFullName() const { return this->fullName; } const std::string& getFullName() const { return this->fullName; }
std::string getPrettyName() const; std::string getPrettyName() const;
   
uint8_t getInputCount() const; size_t getInputCount() const;
   
std::shared_ptr<abstraction::OperationAbstraction> execute( std::shared_ptr<abstraction::OperationAbstraction> execute(
const std::vector<std::shared_ptr<abstraction::OperationAbstraction>>& params) const; const std::vector<std::shared_ptr<abstraction::OperationAbstraction>>& params) const;
......
...@@ -40,7 +40,7 @@ std::shared_ptr<abstraction::OperationAbstraction> ParallelExecutor::execute(Out ...@@ -40,7 +40,7 @@ std::shared_ptr<abstraction::OperationAbstraction> ParallelExecutor::execute(Out
} }
} }
   
std::vector<std::vector<uint8_t>> M; std::vector<std::vector<size_t>> M;
size_t N = boxes.size(); size_t N = boxes.size();
M.resize(N); M.resize(N);
for (size_t i = 0; i < N; ++i) { for (size_t i = 0; i < N; ++i) {
...@@ -58,7 +58,7 @@ std::shared_ptr<abstraction::OperationAbstraction> ParallelExecutor::execute(Out ...@@ -58,7 +58,7 @@ std::shared_ptr<abstraction::OperationAbstraction> ParallelExecutor::execute(Out
for (size_t k = 0; k < N; k++) { for (size_t k = 0; k < N; k++) {
for (size_t i = 0; i < N; i++) { for (size_t i = 0; i < N; i++) {
for (size_t j = 0; j < N; j++) { for (size_t j = 0; j < N; j++) {
M[i][j] = M[i][j] | static_cast<uint8_t>(M[i][k] & M[k][j]); M[i][j] = M[i][j] | static_cast<size_t>(M[i][k] & M[k][j]);
} }
} }
} }
......
#include <Graphics/Connection/InputConnectionBox.hpp> #include <Graphics/Connection/InputConnectionBox.hpp>
   
InputConnectionBox::InputConnectionBox(GraphicsBox* parent, uint8_t slot) InputConnectionBox::InputConnectionBox(GraphicsBox* parent, size_t slot)
: ConnectionBox(parent, ConnectionBox::Type::Input) : ConnectionBox(parent, ConnectionBox::Type::Input)
, slot(slot) , slot(slot)
{} {}
......
...@@ -5,18 +5,18 @@ class InputConnectionBox : public ConnectionBox { ...@@ -5,18 +5,18 @@ class InputConnectionBox : public ConnectionBox {
friend class Connection; friend class Connection;
   
public: public:
explicit InputConnectionBox(GraphicsBox* parent, uint8_t slot); explicit InputConnectionBox(GraphicsBox* parent, size_t slot);
   
void setConnection(Connection* connection); void setConnection(Connection* connection);
const Connection* getConnection() const { return this->connection; } const Connection* getConnection() const { return this->connection; }
uint8_t getSlot() const { return this->slot; } size_t getSlot() const { return this->slot; }
   
private: private:
void on_Disconnect() override; void on_Disconnect() override;
   
protected: protected:
Connection* connection = nullptr; Connection* connection = nullptr;
uint8_t slot; size_t slot;
}; };
   
   
...@@ -26,11 +26,11 @@ GraphicsBox::GraphicsBox(std::unique_ptr<ModelBox> modelBox, QPointF pos) ...@@ -26,11 +26,11 @@ GraphicsBox::GraphicsBox(std::unique_ptr<ModelBox> modelBox, QPointF pos)
this->setZValue(1); this->setZValue(1);
   
this->boundRect = QFontMetrics(this->font).boundingRect(this->text); this->boundRect = QFontMetrics(this->font).boundingRect(this->text);
this->boundRect.setHeight(std::max(this->boundRect.height(), std::max(this->modelBox->getMaxInputCount(), uint8_t(1)) * 16.0)); this->boundRect.setHeight(std::max(this->boundRect.height(), std::max(this->modelBox->getMaxInputCount(), size_t(1)) * 16.0));
this->boundRect.adjust(-20, -20, 20, 20); this->boundRect.adjust(-20, -20, 20, 20);
   
uint8_t maxInputCount = this->modelBox->getMaxInputCount(); size_t maxInputCount = this->modelBox->getMaxInputCount();
for (uint8_t i = 0; i < maxInputCount; ++i) for (size_t i = 0; i < maxInputCount; ++i)
{ {
auto* box = new InputConnectionBox(this, i); auto* box = new InputConnectionBox(this, i);
box->setPos(this->boundRect.left(), this->boundRect.top() + ((i + 1) * this->boundRect.height()) / float(maxInputCount + 1)); box->setPos(this->boundRect.left(), this->boundRect.top() + ((i + 1) * this->boundRect.height()) / float(maxInputCount + 1));
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
   
std::vector<ModelBox*> ModelBox::allModelBoxes; std::vector<ModelBox*> ModelBox::allModelBoxes;
   
ModelBox::ModelBox(ModelType type, uint8_t maxInputCount) ModelBox::ModelBox(ModelType type, size_t maxInputCount)
: type(type) : type(type)
, maxInputCount(maxInputCount) , maxInputCount(maxInputCount)
, inputs(maxInputCount, nullptr) , inputs(maxInputCount, nullptr)
...@@ -23,17 +23,17 @@ ModelBox::~ModelBox() { ...@@ -23,17 +23,17 @@ ModelBox::~ModelBox() {
bs.erase(std::remove(bs.begin(), bs.end(), this), bs.end()); bs.erase(std::remove(bs.begin(), bs.end(), this), bs.end());
} }
   
void ModelBox::setInput(uint8_t slot, ModelBox* model) { void ModelBox::setInput(size_t slot, ModelBox* model) {
Q_ASSERT(slot < this->maxInputCount); Q_ASSERT(slot < this->maxInputCount);
this->inputs[slot] = model; this->inputs[slot] = model;
} }
   
void ModelBox::addOutput(ModelBox* model, uint8_t slot) { void ModelBox::addOutput(ModelBox* model, size_t slot) {
Q_ASSERT(this->canHaveOutput()); Q_ASSERT(this->canHaveOutput());
this->outputs.emplace(model, slot); this->outputs.emplace(model, slot);
} }
   
void ModelBox::removeOutput(ModelBox* model, uint8_t slot) { void ModelBox::removeOutput(ModelBox* model, size_t slot) {
Q_ASSERT(this->canHaveOutput()); Q_ASSERT(this->canHaveOutput());
this->outputs.erase({model, slot}); this->outputs.erase({model, slot});
} }
......
...@@ -17,7 +17,7 @@ enum class ModelType { ...@@ -17,7 +17,7 @@ enum class ModelType {
class ModelBox { class ModelBox {
friend class ParallelExecutor; friend class ParallelExecutor;
protected: protected:
explicit ModelBox(ModelType type, uint8_t maxInputCount); explicit ModelBox(ModelType type, size_t maxInputCount);
   
public: public:
virtual ~ModelBox(); virtual ~ModelBox();
...@@ -26,11 +26,11 @@ public: ...@@ -26,11 +26,11 @@ public:
ModelType getType() const { return this->type; } ModelType getType() const { return this->type; }
virtual std::string getName() const = 0; virtual std::string getName() const = 0;
   
void setInput(uint8_t slot, ModelBox* model); void setInput(size_t slot, ModelBox* model);
void addOutput(ModelBox* model, uint8_t slot); void addOutput(ModelBox* model, size_t slot);
void removeOutput(ModelBox* model, uint8_t slot); void removeOutput(ModelBox* model, size_t slot);
   
uint8_t getMaxInputCount() const { return this->maxInputCount; } size_t getMaxInputCount() const { return this->maxInputCount; }
virtual bool canHaveOutput() const { return true; } virtual bool canHaveOutput() const { return true; }
   
std::shared_ptr<abstraction::OperationAbstraction> getCachedResult() const { return this->result; } std::shared_ptr<abstraction::OperationAbstraction> getCachedResult() const { return this->result; }
...@@ -44,9 +44,9 @@ public: ...@@ -44,9 +44,9 @@ public:
protected: protected:
ModelType type; ModelType type;
   
uint8_t maxInputCount = 0; size_t maxInputCount = 0;
std::vector<ModelBox*> inputs; std::vector<ModelBox*> inputs;
std::set<std::pair<ModelBox*, uint8_t>> outputs; std::set<std::pair<ModelBox*, size_t>> outputs;
std::shared_ptr<abstraction::OperationAbstraction> result; std::shared_ptr<abstraction::OperationAbstraction> result;
   
GraphicsBox* graphicsBox = nullptr; GraphicsBox* graphicsBox = nullptr;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment