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

Remove WrapperFactory

parent 22f14cc1
No related branches found
No related tags found
No related merge requests found
......@@ -81,8 +81,6 @@ add_executable(${PROJECT_NAME}
src/Models/OutputSettings.hpp
src/Utils.cpp
src/Utils.hpp
src/WrapperFactory.cpp
src/WrapperFactory.hpp
)
 
target_link_libraries(
......
......@@ -16,7 +16,7 @@
#include <Graphics/InputGraphicsBox.hpp>
#include <Models/InputModelBox.hpp>
#include <ui_MainWindow.h>
#include <WrapperFactory.hpp>
#include <Models/AlgorithmModelBox.hpp>
 
MainWindow::MainWindow()
: ui(new Ui::MainWindow)
......@@ -27,8 +27,8 @@ MainWindow::MainWindow()
 
Registry::initialize();
 
this->scene->addItem(WrapperFactory::createNew(WrapperFactory::INPUT, 0, 200));
outputBox = WrapperFactory::createNew(WrapperFactory::OUTPUT, 400, 200);
this->scene->addItem(new InputGraphicsBox(std::make_unique<InputModelBox>(), {0, 200}));
outputBox = new GraphicsBox(std::make_unique<InputModelBox>(), {400, 200});;
this->scene->addItem(outputBox);
}
 
......@@ -58,22 +58,22 @@ void MainWindow::on_RunBtn_clicked()
 
void MainWindow::on_DeterminizeBtn_clicked()
{
this->scene->addItem(WrapperFactory::createNew(WrapperFactory::DETERMINIZE, 200, 50));
this->scene->addItem(new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::determinize::Determinize")), {200, 50}));
}
 
void MainWindow::on_TotalBtn_clicked()
{
this->scene->addItem(WrapperFactory::createNew(WrapperFactory::TOTAL, 300, 50));
this->scene->addItem(new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::simplify::Total")), {300, 50}));
}
 
void MainWindow::on_CompactBtn_clicked()
{
this->scene->addItem(WrapperFactory::createNew(WrapperFactory::COMPACT, 200, -50));
this->scene->addItem(new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::transform::Compaction")), {200, -50}));
}
 
void MainWindow::on_SingleInitialBtn_clicked()
{
this->scene->addItem(WrapperFactory::createNew(WrapperFactory::SINGLE_INITIAL, 200, 30));
this->scene->addItem(new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::simplify::SingleInitialState")), {200, 30}));
}
 
void MainWindow::on_EpsilonRemoveBtn_clicked()
......@@ -90,47 +90,47 @@ void MainWindow::on_EpsilonRemoveBtn_clicked()
 
void MainWindow::on_MinimizeBtn_clicked()
{
this->scene->addItem(WrapperFactory::createNew(WrapperFactory::MINIMIZE, 200, 100));
this->scene->addItem(new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::simplify::Minimize")), {200, 100}));
}
 
void MainWindow::on_NormilizeBtn_clicked()
{
this->scene->addItem(WrapperFactory::createNew(WrapperFactory::NORMALIZE, 200, 100));
this->scene->addItem(new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::simplify::Normalize")), {200, 100}));
}
 
void MainWindow::on_EpsilonRemoveIncoming()
{
this->scene->addItem(WrapperFactory::createNew(WrapperFactory::EPSILON_REMOVE_IN, 200, 30));
this->scene->addItem(new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::simplify::EpsilonRemoverIncoming")), {200, 30}));
}
 
void MainWindow::on_EpsilonRemoveOutgoing()
{
this->scene->addItem(WrapperFactory::createNew(WrapperFactory::EPSILON_REMOVE_OUT, 200, 30));
this->scene->addItem(new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::simplify::EpsilonRemoverOutgoing")), {200, 30}));
}
 
void MainWindow::on_RenameBtn_clicked()
{
this->scene->addItem(WrapperFactory::createNew(WrapperFactory::RENAME, 200, 30));
this->scene->addItem(new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::simplify::Rename")), {200, 30}));
}
 
void MainWindow::on_TrimBtn_clicked()
{
this->scene->addItem(WrapperFactory::createNew(WrapperFactory::TRIM, 200, 30));
this->scene->addItem(new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::simplify::Trim")), {200, 30}));
}
 
void MainWindow::on_RemoveUselessBtn_clicked()
{
this->scene->addItem(WrapperFactory::createNew(WrapperFactory::REMOVE_USELES, 200, 30));
this->scene->addItem(new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::simplify::UselessStatesRemover")), {200, 30}));
}
 
void MainWindow::on_RemoveUnreachableBtn_clicked()
{
this->scene->addItem(WrapperFactory::createNew(WrapperFactory::REMOVE_UNREACHABLE, 200, 30));
this->scene->addItem(new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::simplify::UnreachableStatesRemover")), {200, 30}));
}
 
void MainWindow::on_ReverseBtn_clicked()
{
this->scene->addItem(WrapperFactory::createNew(WrapperFactory::REVERSE, 200, 30));
this->scene->addItem(new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::transform::Reverse")), {200, 30}));
}
 
void MainWindow::on_IterateBtn_clicked()
......@@ -147,12 +147,12 @@ void MainWindow::on_IterateBtn_clicked()
 
void MainWindow::on_Iterate()
{
this->scene->addItem(WrapperFactory::createNew(WrapperFactory::ITERATE, 200, 30));
this->scene->addItem(new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::transform::AutomatonIteration")), {200, 30}));
}
 
void MainWindow::on_IterateEpsilon()
{
this->scene->addItem(WrapperFactory::createNew(WrapperFactory::ITERATE_EPSILON, 200, 30));
this->scene->addItem(new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::transform::AutomatonIterationEpsilonTransition")), {200, 30}));
}
 
void MainWindow::on_ConcatenateBtn_clicked()
......@@ -169,12 +169,12 @@ void MainWindow::on_ConcatenateBtn_clicked()
 
void MainWindow::on_Concatenate()
{
this->scene->addItem(WrapperFactory::createNew(WrapperFactory::CONCATENATE, 200, 100));
this->scene->addItem(new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::transform::AutomataConcatenation")), {200, 100}));
}
 
void MainWindow::on_ConcatenateEpsilon()
{
this->scene->addItem(WrapperFactory::createNew(WrapperFactory::CONCATENATE_EPSILON, 200, 100));
this->scene->addItem(new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::transform::AutomataConcatenationEpsilonTransition")), {200, 100}));
}
 
void MainWindow::on_UnionBtn_clicked()
......@@ -191,21 +191,21 @@ void MainWindow::on_UnionBtn_clicked()
 
void MainWindow::on_Union()
{
this->scene->addItem(WrapperFactory::createNew(WrapperFactory::UNION, 200, 100));
this->scene->addItem(new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::transform::AutomataUnionCartesianProduct")), {200, 100}));
}
 
void MainWindow::on_UnionEpsilon()
{
this->scene->addItem(WrapperFactory::createNew(WrapperFactory::UNION_EPSILON, 200, 100));
this->scene->addItem(new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::transform::AutomataUnionEpsilonTransition")), {200, 100}));
}
 
void MainWindow::on_IntersectBtn_clicked()
{
this->scene->addItem(WrapperFactory::createNew(WrapperFactory::INTERSECT, 200, 100));
this->scene->addItem(new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::transform::AutomataIntersectionCartesianProduct")), {200, 100}));
}
 
void MainWindow::on_AddInputBtn_clicked()
{
int y = qrand()%4 * 100;
this->scene->addItem(WrapperFactory::createNew(WrapperFactory::INPUT, 0, y));
qreal y = qrand() % 4 * 100;
this->scene->addItem(new InputGraphicsBox(std::make_unique<InputModelBox>(), {0, y}));
}
#include <WrapperFactory.hpp>
#include <QChar>
#include <QString>
#include <Algorithm/Registry.hpp>
#include <Graphics/InputGraphicsBox.hpp>
#include <Graphics/GraphicsBox.hpp>
#include <Models/AlgorithmModelBox.hpp>
#include <Models/InputModelBox.hpp>
#include <Models/OutputModelBox.hpp>
GraphicsBox* WrapperFactory::createNew(WrapperFactory::Algorithms algorithm, qreal x = 0, qreal y = 0)
{
QString eps (QChar(0xb5, 0x03));
switch( algorithm )
{
// Special
case INPUT:
return new InputGraphicsBox(std::make_unique<InputModelBox>(), {x, y});
case OUTPUT:
return new GraphicsBox(std::make_unique<OutputModelBox>(), {x, y});
// Single simplify
case DETERMINIZE:
return new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::determinize::Determinize")), {x, y});
case TOTAL:
return new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::simplify::Total")), {x, y});
case MINIMIZE:
return new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::simplify::Minimize")), {x, y});
case NORMALIZE:
return new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::simplify::Normalize")), {x, y});
case SINGLE_INITIAL:
return new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::simplify::SingleInitialState")), {x, y});
case EPSILON_REMOVE_IN:
return new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::simplify::EpsilonRemoverIncoming")), {x, y});
case EPSILON_REMOVE_OUT:
return new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::simplify::EpsilonRemoverOutgoing")), {x, y});
case RENAME:
return new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::simplify::Rename")), {x, y});
case TRIM:
return new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::simplify::Trim")), {x, y});
case REMOVE_USELES:
return new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::simplify::UselessStatesRemover")), {x, y});
case REMOVE_UNREACHABLE:
return new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::simplify::UnreachableStatesRemover")), {x, y});
// Single transform
case COMPACT:
return new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::transform::Compaction")), {x, y});
case REVERSE:
return new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::transform::Reverse")), {x, y});
case ITERATE:
return new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::transform::AutomatonIteration")), {x, y});
case ITERATE_EPSILON:
return new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::transform::AutomatonIterationEpsilonTransition")), {x, y});
//Double
case CONCATENATE:
return new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::transform::AutomataConcatenation")), {x, y});
case CONCATENATE_EPSILON:
return new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::transform::AutomataConcatenationEpsilonTransition")), {x, y});
case UNION:
return new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::transform::AutomataUnionCartesianProduct")), {x, y});
case UNION_EPSILON:
return new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::transform::AutomataUnionEpsilonTransition")), {x, y});
case INTERSECT:
return new GraphicsBox(std::make_unique<AlgorithmModelBox>(Registry::getAlgorithm("automaton::transform::AutomataIntersectionCartesianProduct")), {x, y});
default:
return nullptr;
}
}
#pragma once
#include <QRectF>
class GraphicsBox;
class WrapperFactory
{
public:
enum Algorithms
{
INPUT,
DETERMINIZE,
TOTAL,
COMPACT,
SINGLE_INITIAL,
EPSILON_REMOVE_IN,
EPSILON_REMOVE_OUT,
CONCATENATE,
CONCATENATE_EPSILON,
MINIMIZE,
NORMALIZE,
OUTPUT,
RENAME,
TRIM,
REMOVE_USELES,
REMOVE_UNREACHABLE,
INTERSECT,
UNION,
UNION_EPSILON,
REVERSE,
ITERATE,
ITERATE_EPSILON
};
static GraphicsBox* createNew( WrapperFactory::Algorithms algorithm, qreal x, qreal y );
};
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