clang formatting

This commit is contained in:
2026-08-30 01:40:29 +02:00
parent c330f13bb8
commit a8894a51cd
11 changed files with 197 additions and 213 deletions
+3 -4
View File
@@ -10,6 +10,7 @@ using namespace std;
bool displaySortInput(shared_ptr<SortInput> input) { bool displaySortInput(shared_ptr<SortInput> input) {
cout << "name: " + input->name + " values: "; cout << "name: " + input->name + " values: ";
for (size_t i = 0; i < input->values.size(); ++i) { for (size_t i = 0; i < input->values.size(); ++i) {
printf("%d | ", input->values[i]); printf("%d | ", input->values[i]);
} }
@@ -27,8 +28,7 @@ string arraytostr(shared_ptr<SortInput> input) {
} }
App::App(unique_ptr<ViewSession> myviewsession, unique_ptr<TimerManager> mytimermanager) App::App(unique_ptr<ViewSession> myviewsession, unique_ptr<TimerManager> mytimermanager)
: viewsession(std::move(myviewsession)), : viewsession(std::move(myviewsession)), timermanager(std::move(mytimermanager)) {}
timermanager(std::move(mytimermanager)) {}
// just pushes to App for now // just pushes to App for now
void App::add_sort(shared_ptr<SortInput> myinput, SortBinding mysortbinding) { void App::add_sort(shared_ptr<SortInput> myinput, SortBinding mysortbinding) {
@@ -43,8 +43,7 @@ void App::run() {
// set up ui // set up ui
while (viewsession->mywindow.isOpen()) { while (viewsession->mywindow.isOpen()) {
while (const optional event = viewsession->mywindow.pollEvent()) { while (const optional event = viewsession->mywindow.pollEvent()) {
if (event->is<sf::Event::Closed>()) if (event->is<sf::Event::Closed>()) viewsession->mywindow.close();
viewsession->mywindow.close();
} }
// draw // draw
+2 -3
View File
@@ -1,16 +1,15 @@
#ifndef APP_HPP #ifndef APP_HPP
#define APP_HPP #define APP_HPP
#include <SFML/Graphics/Font.hpp> #include <SFML/Graphics/Font.hpp>
#include <SFML/Graphics/RenderWindow.hpp> #include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Graphics/Text.hpp> #include <SFML/Graphics/Text.hpp>
#include <memory> #include <memory>
#include <vector> #include <vector>
#include "../timer.hpp"
#include "../sorters.hpp"
#include "../sessions.hpp" #include "../sessions.hpp"
#include "../sorters.hpp"
#include "../timer.hpp"
// should connect the different parts // should connect the different parts
// for now data, mutation, and rendering // for now data, mutation, and rendering
+2 -2
View File
@@ -2,8 +2,8 @@
using namespace std; using namespace std;
ViewSession::ViewSession(): mywindow(sf::VideoMode({800,600}), "mywindow"), myfont(load_font("assets/NS-R.ttf")), text(myfont) ViewSession::ViewSession()
{ : mywindow(sf::VideoMode({800, 600}), "mywindow"), myfont(load_font("assets/NS-R.ttf")), text(myfont) {
text.setFont(myfont); text.setFont(myfont);
text.setString("Hello world"); text.setString("Hello world");
text.setCharacterSize(24); text.setCharacterSize(24);
+5 -7
View File
@@ -1,21 +1,18 @@
#include "sorters.hpp"
#include <cstdio> #include <cstdio>
#include <iostream> #include <iostream>
#include <memory> #include <memory>
#include <utility> #include <utility>
#include "sorters.hpp"
using namespace std; using namespace std;
SteppedBsort::SteppedBsort(shared_ptr<SortInput> input) : data(input) {};
SteppedBsort::SteppedBsort(shared_ptr<SortInput> input)
: data(input) {};
void SteppedBsort::step() { void SteppedBsort::step() {
cout << "step in SteppedBsort\n"; cout << "step in SteppedBsort\n";
if (is_finished) { if (is_finished) {
printf("finished"); printf("finished");
} }
if(data->values[j]>data->values[j+1]) if (data->values[j] > data->values[j + 1]) {
{
swap(data->values[j], data->values[j + 1]); swap(data->values[j], data->values[j + 1]);
} }
j++; j++;
@@ -29,7 +26,8 @@ void SteppedBsort:: step(){
} }
} }
SortBinding::SortBinding(std::shared_ptr<SortInput> input, std::shared_ptr<Steppable> sort, std::shared_ptr<Invoker> invoker) SortBinding::SortBinding(
std::shared_ptr<SortInput> input, std::shared_ptr<Steppable> sort, std::shared_ptr<Invoker> invoker)
: input(std::move(input)), sort(std::move(sort)), invoker(std::move(invoker)) {} : input(std::move(input)), sort(std::move(sort)), invoker(std::move(invoker)) {}
// connects data with the correct sort // connects data with the correct sort
+1 -3
View File
@@ -14,8 +14,7 @@ struct SortInput {
std::string name; std::string name;
std::vector<int> values; std::vector<int> values;
SortInput(std::string name, std::vector<int> data) SortInput(std::string name, std::vector<int> data) : name(name), values(data) {}
: name(name), values(data) {}
}; };
// ro rendering of data // ro rendering of data
@@ -47,7 +46,6 @@ struct SortBinding {
std::shared_ptr<Steppable> sort; std::shared_ptr<Steppable> sort;
std::shared_ptr<Invoker> invoker; std::shared_ptr<Invoker> invoker;
SortBinding(std::shared_ptr<SortInput> input, std::shared_ptr<Steppable> sort, std::shared_ptr<Invoker> invoker); SortBinding(std::shared_ptr<SortInput> input, std::shared_ptr<Steppable> sort, std::shared_ptr<Invoker> invoker);
}; };
std::shared_ptr<Steppable> make_sort(std::shared_ptr<SortInput> input, std::string sorttype); std::shared_ptr<Steppable> make_sort(std::shared_ptr<SortInput> input, std::string sorttype);
+3 -7
View File
@@ -4,13 +4,13 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include <SFML/Graphics.hpp>
#include <SFML/Graphics/Color.hpp> #include <SFML/Graphics/Color.hpp>
#include <SFML/Graphics/Font.hpp> #include <SFML/Graphics/Font.hpp>
#include <SFML/Graphics/RenderWindow.hpp> #include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Graphics/Text.hpp> #include <SFML/Graphics/Text.hpp>
#include <SFML/Window/Window.hpp>
#include <SFML/Window.hpp> #include <SFML/Window.hpp>
#include <SFML/Graphics.hpp> #include <SFML/Window/Window.hpp>
#include "core/app.hpp" #include "core/app.hpp"
#include "sessions.hpp" #include "sessions.hpp"
@@ -21,9 +21,7 @@
using namespace std::chrono; using namespace std::chrono;
using namespace std; using namespace std;
vector<int> dataprovider(){ vector<int> dataprovider() { return vector<int>{9, 8, 1, 2, 7, 3, 6, 4, 5}; }
return vector<int> {9,8,1,2,7,3,6,4,5};
}
int main() { int main() {
// create data // create data
@@ -47,8 +45,6 @@ int main() {
// add data and binding // add data and binding
myapp.add_sort(myinput, mysortbinding); myapp.add_sort(myinput, mysortbinding);
// actually start the app // actually start the app
myapp.run(); myapp.run();
} }
+4 -9
View File
@@ -2,16 +2,14 @@
#include <iostream> #include <iostream>
#include <memory> #include <memory>
#include "timer.hpp"
#include "Invoker.hpp" #include "Invoker.hpp"
#include "timer.hpp"
using namespace std::chrono; using namespace std::chrono;
using namespace std; using namespace std;
Timer::Timer(size_t triggeramount, std::weak_ptr<Invoker> invoker, milliseconds triggerinterval) Timer::Timer(size_t triggeramount, std::weak_ptr<Invoker> invoker, milliseconds triggerinterval)
:triggeramount(triggeramount) : triggeramount(triggeramount), invoker(invoker), triggerinterval(triggerinterval) {}
, invoker(invoker)
, triggerinterval(triggerinterval){}
void Timer::add_time(milliseconds deltatime) { void Timer::add_time(milliseconds deltatime) {
accumulator += deltatime; accumulator += deltatime;
@@ -28,13 +26,10 @@ void Timer::add_time(milliseconds deltatime) {
} }
} }
void TimerManager::add_timer(Timer timer){ void TimerManager::add_timer(Timer timer) { timers.push_back(std::move(timer)); }
timers.push_back(std::move(timer));
}
void TimerManager::update_timers() { void TimerManager::update_timers() {
steady_clock::time_point currenttime = steady_clock::time_point currenttime = steady_clock::now();
steady_clock::now();
milliseconds deltatime = duration_cast<milliseconds>(currenttime - previoustime); milliseconds deltatime = duration_cast<milliseconds>(currenttime - previoustime);
for (Timer &mytimer : timers) { for (Timer &mytimer : timers) {
mytimer.add_time(deltatime); mytimer.add_time(deltatime);
+1 -2
View File
@@ -1,9 +1,9 @@
#ifndef TIMER_HPP #ifndef TIMER_HPP
#define TIMER_HPP #define TIMER_HPP
#include <chrono>
#include <cstddef> #include <cstddef>
#include <ctime> #include <ctime>
#include <chrono>
#include <memory> #include <memory>
#include <vector> #include <vector>
@@ -24,7 +24,6 @@ private:
std::chrono::milliseconds triggerinterval = std::chrono::milliseconds(1000); // default to 1 sec std::chrono::milliseconds triggerinterval = std::chrono::milliseconds(1000); // default to 1 sec
}; };
// CRUD timers and give them dt on update // CRUD timers and give them dt on update
class TimerManager { class TimerManager {
public: public: