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) {
cout << "name: " + input->name + " values: ";
for (size_t i = 0; i < input->values.size(); ++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)
: viewsession(std::move(myviewsession)),
timermanager(std::move(mytimermanager)) {}
: viewsession(std::move(myviewsession)), timermanager(std::move(mytimermanager)) {}
// just pushes to App for now
void App::add_sort(shared_ptr<SortInput> myinput, SortBinding mysortbinding) {
@@ -43,8 +43,7 @@ void App::run() {
// set up ui
while (viewsession->mywindow.isOpen()) {
while (const optional event = viewsession->mywindow.pollEvent()) {
if (event->is<sf::Event::Closed>())
viewsession->mywindow.close();
if (event->is<sf::Event::Closed>()) viewsession->mywindow.close();
}
// draw
+2 -3
View File
@@ -1,16 +1,15 @@
#ifndef APP_HPP
#define APP_HPP
#include <SFML/Graphics/Font.hpp>
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Graphics/Text.hpp>
#include <memory>
#include <vector>
#include "../timer.hpp"
#include "../sorters.hpp"
#include "../sessions.hpp"
#include "../sorters.hpp"
#include "../timer.hpp"
// should connect the different parts
// for now data, mutation, and rendering
+2 -2
View File
@@ -2,8 +2,8 @@
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.setString("Hello world");
text.setCharacterSize(24);
+5 -7
View File
@@ -1,21 +1,18 @@
#include "sorters.hpp"
#include <cstdio>
#include <iostream>
#include <memory>
#include <utility>
#include "sorters.hpp"
using namespace std;
SteppedBsort::SteppedBsort(shared_ptr<SortInput> input)
: data(input) {};
SteppedBsort::SteppedBsort(shared_ptr<SortInput> input) : data(input) {};
void SteppedBsort::step() {
cout << "step in SteppedBsort\n";
if (is_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]);
}
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)) {}
// connects data with the correct sort
+1 -3
View File
@@ -14,8 +14,7 @@ struct SortInput {
std::string name;
std::vector<int> values;
SortInput(std::string name, std::vector<int> data)
: name(name), values(data) {}
SortInput(std::string name, std::vector<int> data) : name(name), values(data) {}
};
// ro rendering of data
@@ -47,7 +46,6 @@ struct SortBinding {
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);
+3 -7
View File
@@ -4,13 +4,13 @@
#include <utility>
#include <vector>
#include <SFML/Graphics.hpp>
#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 <SFML/Window/Window.hpp>
#include "core/app.hpp"
#include "sessions.hpp"
@@ -21,9 +21,7 @@
using namespace std::chrono;
using namespace std;
vector<int> dataprovider(){
return vector<int> {9,8,1,2,7,3,6,4,5};
}
vector<int> dataprovider() { return vector<int>{9, 8, 1, 2, 7, 3, 6, 4, 5}; }
int main() {
// create data
@@ -47,8 +45,6 @@ int main() {
// add data and binding
myapp.add_sort(myinput, mysortbinding);
// actually start the app
myapp.run();
}
+4 -9
View File
@@ -2,16 +2,14 @@
#include <iostream>
#include <memory>
#include "timer.hpp"
#include "Invoker.hpp"
#include "timer.hpp"
using namespace std::chrono;
using namespace std;
Timer::Timer(size_t triggeramount, std::weak_ptr<Invoker> invoker, milliseconds triggerinterval)
:triggeramount(triggeramount)
, invoker(invoker)
, triggerinterval(triggerinterval){}
: triggeramount(triggeramount), invoker(invoker), triggerinterval(triggerinterval) {}
void Timer::add_time(milliseconds deltatime) {
accumulator += deltatime;
@@ -28,13 +26,10 @@ void Timer::add_time(milliseconds deltatime) {
}
}
void TimerManager::add_timer(Timer timer){
timers.push_back(std::move(timer));
}
void TimerManager::add_timer(Timer timer) { timers.push_back(std::move(timer)); }
void TimerManager::update_timers() {
steady_clock::time_point currenttime =
steady_clock::now();
steady_clock::time_point currenttime = steady_clock::now();
milliseconds deltatime = duration_cast<milliseconds>(currenttime - previoustime);
for (Timer &mytimer : timers) {
mytimer.add_time(deltatime);
+1 -2
View File
@@ -1,9 +1,9 @@
#ifndef TIMER_HPP
#define TIMER_HPP
#include <chrono>
#include <cstddef>
#include <ctime>
#include <chrono>
#include <memory>
#include <vector>
@@ -24,7 +24,6 @@ private:
std::chrono::milliseconds triggerinterval = std::chrono::milliseconds(1000); // default to 1 sec
};
// CRUD timers and give them dt on update
class TimerManager {
public: