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.
This commit is contained in:
+14
-2
@@ -1,6 +1,7 @@
|
||||
// for now juist CLI, print an arr, then print each it
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <SFML/Graphics/Color.hpp>
|
||||
@@ -14,6 +15,7 @@
|
||||
#include "core/app.hpp"
|
||||
#include "sessions.hpp"
|
||||
#include "sorters.hpp"
|
||||
#include "steppable.hpp"
|
||||
#include "timer.hpp"
|
||||
|
||||
using namespace std::chrono;
|
||||
@@ -34,8 +36,18 @@ int main() {
|
||||
//create app with initialized dependencies
|
||||
App myapp(std::move(myviewsession),std::move(mytimermanager));
|
||||
|
||||
//add and connect data
|
||||
myapp.add_sort(myinput, "bsort");
|
||||
//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();
|
||||
|
||||
Reference in New Issue
Block a user