Files
sortui/src/sortui.cpp
T
lyrgb d3c966b268 moved instantiation responsibility from App::add_sort
Invoker is now an object that we attach to the sortbinding rather than
the HasInvoker.
we now create a binding in main, then pass it on to App.
Timer now has a weak ptr to its invoker, so it could clean itself up.
2026-08-27 23:04:57 +02:00

55 lines
1.4 KiB
C++

// for now juist CLI, print an arr, then print each it
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include <SFML/Graphics/Color.hpp>
#include <SFML/Graphics/Font.hpp>
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Graphics/Text.hpp>
#include <SFML/Window/Window.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include "core/app.hpp"
#include "sessions.hpp"
#include "sorters.hpp"
#include "steppable.hpp"
#include "timer.hpp"
using namespace std::chrono;
using namespace std;
vector<int> dataprovider(){
return vector<int> {9,8,1,2,7,3,6,4,5};
}
int main() {
//create data
auto myinput = make_shared<SortInput>("arr1", dataprovider());
auto myinput2 = make_shared<SortInput>("arr2", dataprovider());
auto myviewsession = make_unique<ViewSession>();
auto mytimermanager = make_unique<TimerManager>();
//create app with initialized dependencies
App myapp(std::move(myviewsession),std::move(mytimermanager));
//create binding
shared_ptr<Steppable> asort = make_sort(myinput, "bsort");
shared_ptr<Invoker> myinvoker = make_shared<Invoker>(asort);
SortBinding mysortbinding(myinput, asort, myinvoker);
Timer timer(0, myinvoker, chrono::milliseconds(250));
myapp.timermanager->add_timer(std::move(timer));
//add data and binding
myapp.add_sort(myinput, mysortbinding);
//actually start the app
myapp.run();
}