Skip to content

Commit

Permalink
cont: replace container allocator with a stateless allocator
Browse files Browse the repository at this point in the history
  • Loading branch information
quesnel committed Jan 14, 2025
1 parent d83864b commit 7f69a5a
Show file tree
Hide file tree
Showing 25 changed files with 1,269 additions and 1,919 deletions.
5 changes: 3 additions & 2 deletions app/gui/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -739,8 +739,9 @@ struct project_editor {
ImVector<int> selected_nodes;

/** Number of column in the tree node observation. */
constrained_value<int, 1, 100> tree_node_observation = 1;
float tree_node_observation_height = 200.f;
using tree_node_observation_t = constrained_value<int, 1, 100>;
tree_node_observation_t tree_node_observation{ 1 };
float tree_node_observation_height = 200.f;

//! Position of each node
int automatic_layout_iteration = 0;
Expand Down
6 changes: 3 additions & 3 deletions app/gui/component-selector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ bool component_selector::combobox(const char* label,

if (std::shared_lock lock(m_mutex, std::try_to_lock); lock.owns_lock()) {
const auto& app = container_of(this, &application::component_sel);
small_string<254> selected_name = "undefined";
small_string<254> selected_name("undefined");

cs_select(app.mod, *new_selected, selected_name);

Expand Down Expand Up @@ -194,7 +194,7 @@ bool component_selector::combobox(const char* label,

if (std::shared_lock lock(m_mutex, std::try_to_lock); lock.owns_lock()) {
const auto& app = container_of(this, &application::component_sel);
small_string<254> selected_name = "undefined";
small_string<254> selected_name("undefined");

cs_select(app.mod, *new_selected, selected_name);

Expand Down Expand Up @@ -242,7 +242,7 @@ bool component_selector::menu(const char* label,
if (std::shared_lock lock(m_mutex, std::try_to_lock); lock.owns_lock()) {
if (ImGui::BeginMenu(label)) {
const auto& app = container_of(this, &application::component_sel);
small_string<254> selected_name = "undefined";
small_string<254> selected_name("undefined");

cs_select(app.mod, *new_selected, selected_name);

Expand Down
12 changes: 8 additions & 4 deletions app/gui/project-editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -904,16 +904,20 @@ static void show_component_observations_actions(project_editor& sim_ed) noexcept
ImGui::TextUnformatted("Column: ");
ImGui::SameLine();
if (ImGui::Button("1"))
sim_ed.tree_node_observation = 1;
sim_ed.tree_node_observation =
project_editor::tree_node_observation_t(1);
ImGui::SameLine();
if (ImGui::Button("2"))
sim_ed.tree_node_observation = 2;
sim_ed.tree_node_observation =
project_editor::tree_node_observation_t(2);
ImGui::SameLine();
if (ImGui::Button("3"))
sim_ed.tree_node_observation = 3;
sim_ed.tree_node_observation =
project_editor::tree_node_observation_t(3);
ImGui::SameLine();
if (ImGui::Button("4"))
sim_ed.tree_node_observation = 4;
sim_ed.tree_node_observation =
project_editor::tree_node_observation_t(4);
ImGui::SameLine();

ImGui::TextUnformatted("Height in pixel: ");
Expand Down
4 changes: 1 addition & 3 deletions app/gui/window-logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

#include "application.hpp"
#include "imgui.h"
#include "internal.hpp"
#include "irritator/core.hpp"

namespace irt {

Expand All @@ -22,7 +20,7 @@ auto window_logger::enqueue() noexcept -> window_logger::string_t&
if (entries.full())
entries.pop_head();

entries.push_tail("");
entries.push_tail(small_string<string_length>(""));
return entries.back();
}

Expand Down
16 changes: 7 additions & 9 deletions app/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,8 @@ static constexpr const option* get_from_long(

class main_parameters
{
irt::sz memory = default_memory_size;
irt::simulation_memory_requirement smr{ default_memory_size };
irt::simulation sim;
irt::sz memory = 1024 * 1024 * 8;
irt::simulation sim;

irt::modeling_initializer init;
irt::modeling mod;
Expand All @@ -208,8 +207,8 @@ class main_parameters

public:
main_parameters(int ac, const char* av[])
: smr{ 1024 * 1024 * 8 }
, sim{ smr }
: sim(irt::simulation_memory_requirement(1024 * 1024 * 8),
irt::external_source_memory_requirement(8, 8, 8, 8, 256, 256))
, args{ av + 1, static_cast<std::size_t>(ac - 1) }
, r{ 0.0 }
{
Expand Down Expand Up @@ -516,10 +515,9 @@ class main_parameters
bool read_memory() noexcept
{
if (parse_integer() and u > memory) {
memory = u;
irt::simulation_memory_requirement smr_two{ u };
std::swap(smr, smr_two);
sim.realloc(smr);
sim.realloc(irt::simulation_memory_requirement(memory),
irt::external_source_memory_requirement(
16, 16, 16, 16, 256, 256));
memory = u;
return true;
}
Expand Down
Loading

0 comments on commit 7f69a5a

Please sign in to comment.