diff options
author | Claudius "keldu" Holeksa <mail@keldu.de> | 2025-08-25 10:34:29 +0200 |
---|---|---|
committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2025-08-25 10:34:29 +0200 |
commit | 109a98d7d8b77628934e9288f01c64d5b3cdc7f8 (patch) | |
tree | e9b03c6be468093670d7ce7f6a4fba515e5199f9 | |
parent | 725e7644d737fe812c0c03cb5c781c9752ef20f2 (diff) |
Added progress bar. Best feature so far
-rw-r--r-- | c++/util.hpp | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/c++/util.hpp b/c++/util.hpp index 1a54541..441ffc8 100644 --- a/c++/util.hpp +++ b/c++/util.hpp @@ -1,10 +1,15 @@ #pragma once +#include <forstio/string_literal.hpp> +#include <forstio/codec/data.hpp> + +#include <iostream> + namespace kel { namespace lbm { +/* template<typename T, typename Descriptor, typename CellFieldSchema> struct is_neighbour { - template<typename CellFieldSchema> static bool operator()(saw::data<CellFieldSchema>& latt, saw::data<sch::FixedArray<sch::UInt64, Descriptor::D>& index) { using dfi = df_info<T,Descriptor>; @@ -20,5 +25,47 @@ struct is_neighbour { auto& cell = latt(index); } }; +*/ + +/* Might be stupidly complex +class cell_info_registry final { +public: + static uint8_t next_reg_id = 0u; + + template<string_literal T> + static uint8_t get_registration_id() { + static uint8_t reg_id = std::numeric_limit<uint8_t>::max(); + + if(reg_id == std::numeric_limit<uint8_t>::max()){ + reg_id = next_reg_id; + ++next_reg_id; + } + + return reg_id; + } +}; +*/ + +void print_progress_bar(uint32_t progress, uint32_t progress_target){ + std::cout + <<"\r" + <<"Progress: " + <<((100 * progress) / progress_target) + <<"% ["; + + uint64_t i{0u}; + + uint64_t max_display = 64u; + uint64_t progress_display = (max_display * progress) / progress_target; + for(; i < progress_display; ++i){ + std::cout<<"#"; + } + for(; i < max_display; ++i){ + std::cout<<"-"; + } + + std::cout<<"]"; + std::cout<<std::flush; +} } } |