diff --git a/examples/bankreserves/bankreserves.cc b/examples/bankreserves/bankreserves.cc index 3ebba97..5f87d7f 100644 --- a/examples/bankreserves/bankreserves.cc +++ b/examples/bankreserves/bankreserves.cc @@ -53,6 +53,9 @@ std::shared_ptr console = nullptr; std::shared_ptr rng = nullptr; +#pragma clang diagnostic push +#pragma ide diagnostic ignored "EmptyDeclOrStmt" + int main(int argc, char **argv) { std::string ident = "bankreserves"; std::string log_level_option = "info"; @@ -99,3 +102,5 @@ int main(int argc, char **argv) { console->info("JSON data report written to {}", output_file_name); console->trace("Done."); } + +#pragma clang diagnostic pop diff --git a/examples/bankreserves/person.cc b/examples/bankreserves/person.cc index 82ddb86..0641489 100644 --- a/examples/bankreserves/person.cc +++ b/examples/bankreserves/person.cc @@ -85,7 +85,7 @@ std::optional PersonAgent::do_business(std::shared_ptrsize() < 2) diff --git a/examples/boltzmann1d/boltzmann1d.cc b/examples/boltzmann1d/boltzmann1d.cc index a3cc694..406ebd9 100644 --- a/examples/boltzmann1d/boltzmann1d.cc +++ b/examples/boltzmann1d/boltzmann1d.cc @@ -169,6 +169,9 @@ std::shared_ptr BoltzmannWealthModel1D::step() { return shared_from_this(); } +#pragma clang diagnostic push +#pragma ide diagnostic ignored "EmptyDeclOrStmt" + int main(int argc, char **argv) { std::string ident = "boltzmann1d"; std::string log_level_option = "info"; @@ -202,3 +205,5 @@ int main(int argc, char **argv) { console->info("Boltzmann Wealth Model simulation complete, requiring {} seconds", sw); } + +#pragma clang diagnostic pop diff --git a/examples/boltzmann1d/boltzmann1d.h b/examples/boltzmann1d/boltzmann1d.h index be38c89..b5f479e 100644 --- a/examples/boltzmann1d/boltzmann1d.h +++ b/examples/boltzmann1d/boltzmann1d.h @@ -96,11 +96,10 @@ public: /** * Execute a single time-step for the model. */ - std::shared_ptr step(); + std::shared_ptr step() final; private: unsigned int _step_count; - }; #endif // BOLTZMANN1D_H diff --git a/examples/boltzmann2d/boltzmann2d.cc b/examples/boltzmann2d/boltzmann2d.cc index 506cc73..e4c546b 100644 --- a/examples/boltzmann2d/boltzmann2d.cc +++ b/examples/boltzmann2d/boltzmann2d.cc @@ -77,7 +77,7 @@ kami::AgentID MoneyAgent2D::step(std::shared_ptr model) { return this->get_agent_id(); } -std::optional MoneyAgent2D::move_agent(std::shared_ptr model) { +std::optional MoneyAgent2D::move_agent(const std::shared_ptr &model) { console->trace("Entering move_agent"); auto agent_id = get_agent_id(); @@ -100,7 +100,7 @@ std::optional MoneyAgent2D::move_agent(std::shared_ptr MoneyAgent2D::give_money(std::shared_ptr model) { +std::optional MoneyAgent2D::give_money(const std::shared_ptr &model) { console->trace("Entering give_money"); auto agent_id = get_agent_id(); @@ -170,6 +170,9 @@ std::shared_ptr BoltzmannWealthModel2D::step() { return shared_from_this(); } +#pragma clang diagnostic push +#pragma ide diagnostic ignored "EmptyDeclOrStmt" + int main(int argc, char **argv) { std::string ident = "boltzmann2d"; std::string log_level_option = "info"; @@ -204,3 +207,5 @@ int main(int argc, char **argv) { console->info("Boltzmann Wealth Model simulation complete, requiring {} seconds", sw); } + +#pragma clang diagnostic pop diff --git a/examples/boltzmann2d/boltzmann2d.h b/examples/boltzmann2d/boltzmann2d.h index 8e52426..07bffed 100644 --- a/examples/boltzmann2d/boltzmann2d.h +++ b/examples/boltzmann2d/boltzmann2d.h @@ -64,17 +64,16 @@ public: /** * Move the agent to a random location on the world */ - std::optional move_agent(std::shared_ptr model); + std::optional move_agent(const std::shared_ptr &model); /** * Give money to a random agent */ - std::optional give_money(std::shared_ptr model); + std::optional give_money(const std::shared_ptr &model); private: int _step_counter; int _agent_wealth; - }; /** @@ -99,11 +98,10 @@ public: /** * Execute a single time-step for the model. */ - std::shared_ptr step(); + std::shared_ptr step() final; private: unsigned int _step_count; - }; #endif // BOLTZMANN2D_H diff --git a/include/kami/grid1d.h b/include/kami/grid1d.h index 35b3a50..b0f8b4b 100644 --- a/include/kami/grid1d.h +++ b/include/kami/grid1d.h @@ -132,7 +132,7 @@ namespace kami { * @returns false if the agent is not placed at the specified * location, otherwise, true. */ - virtual std::optional add_agent(const AgentID agent_id, const GridCoord1D &coord) = 0; + virtual std::optional add_agent(AgentID agent_id, const GridCoord1D &coord) = 0; /** * @brief Remove agent from the grid. @@ -141,7 +141,7 @@ namespace kami { * * @returns the `AgentID` of the `Agent` deleted */ - std::optional delete_agent(const AgentID agent_id); + std::optional delete_agent(AgentID agent_id); /** * @brief Remove agent from the grid at the specified location @@ -151,7 +151,7 @@ namespace kami { * * @returns the `AgentID` of the `Agent` deleted */ - std::optional delete_agent(const AgentID agent_id, const GridCoord1D &coord); + std::optional delete_agent(AgentID agent_id, const GridCoord1D &coord); /** * @brief Move an agent to the specified location. @@ -159,7 +159,7 @@ namespace kami { * @param[in] agent_id the `AgentID` of the agent to move. * @param[in] coord the coordinates of the agent. */ - std::optional move_agent(const AgentID agent_id, const GridCoord1D &coord); + std::optional move_agent(AgentID agent_id, const GridCoord1D &coord); /** * @brief Inquire if the specified location is empty. @@ -220,7 +220,7 @@ namespace kami { * for all adjacent points. */ [[nodiscard]] std::optional>> - get_neighborhood(const AgentID agent_id, const bool include_center) const; + get_neighborhood(AgentID agent_id, const bool include_center) const; /** * @brief Return the neighborhood of the specified location @@ -233,7 +233,7 @@ namespace kami { * for all adjacent points. */ [[nodiscard]] std::optional>> - get_neighborhood(const GridCoord1D &coord, const bool include_center) const; + get_neighborhood(const GridCoord1D &coord, bool include_center) const; /** * @brief Get the size of the grid in the `x` dimension. diff --git a/include/kami/grid2d.h b/include/kami/grid2d.h index ee16bca..d00506f 100644 --- a/include/kami/grid2d.h +++ b/include/kami/grid2d.h @@ -154,7 +154,7 @@ namespace kami { * @returns false if the agent is not placed at the specified * location, otherwise, true. */ - virtual std::optional add_agent(const AgentID agent_id, const GridCoord2D &coord) = 0; + virtual std::optional add_agent(AgentID agent_id, const GridCoord2D &coord) = 0; /** * @brief Remove agent from the grid. @@ -163,7 +163,7 @@ namespace kami { * * @returns false if the agent is not removed, otherwise, true. */ - std::optional delete_agent(const AgentID agent_id); + std::optional delete_agent(AgentID agent_id); /** * @brief Remove agent from the grid at the specified location @@ -173,7 +173,7 @@ namespace kami { * * @returns false if the agent is not removed, otherwise, true. */ - std::optional delete_agent(const AgentID agent_id, const GridCoord2D &coord); + std::optional delete_agent(AgentID agent_id, const GridCoord2D &coord); /** * @brief Move an agent to the specified location. @@ -181,7 +181,7 @@ namespace kami { * @param[in] agent_id the `AgentID` of the agent to move. * @param[in] coord the coordinates of the agent. */ - std::optional move_agent(const AgentID agent_id, const GridCoord2D &coord); + std::optional move_agent(AgentID agent_id, const GridCoord2D &coord); /** * @brief Inquire if the specified location is empty. diff --git a/include/kami/multigrid1d.h b/include/kami/multigrid1d.h index 0820dae..0afb4f0 100644 --- a/include/kami/multigrid1d.h +++ b/include/kami/multigrid1d.h @@ -65,7 +65,7 @@ namespace kami { * @returns false if the agent is not placed at the specified * location, otherwise, true */ - std::optional add_agent(const AgentID agent_id, const GridCoord1D &coord) override; + std::optional add_agent(AgentID agent_id, const GridCoord1D &coord) override; }; } // namespace kami diff --git a/include/kami/multigrid2d.h b/include/kami/multigrid2d.h index 821adbe..d6fdeeb 100644 --- a/include/kami/multigrid2d.h +++ b/include/kami/multigrid2d.h @@ -69,7 +69,7 @@ namespace kami { * @returns false if the agent is not placed at the specified * location, otherwise, true */ - std::optional add_agent(const AgentID agent_id, const GridCoord2D &coord) override; + std::optional add_agent(AgentID agent_id, const GridCoord2D &coord) override; }; } // namespace kami diff --git a/include/kami/position.h b/include/kami/position.h index 45822ba..4f4955f 100644 --- a/include/kami/position.h +++ b/include/kami/position.h @@ -36,10 +36,10 @@ #include namespace kami { - typedef std::variant < - kami::GridCoord1D, - kami::GridCoord2D, - kami::HexCoord + typedef std::variant< + GridCoord1D, + GridCoord2D, + HexCoord > Position; } diff --git a/include/kami/sologrid1d.h b/include/kami/sologrid1d.h index 3572ba9..dc167a8 100644 --- a/include/kami/sologrid1d.h +++ b/include/kami/sologrid1d.h @@ -37,7 +37,7 @@ namespace kami { /** - * @brief A one-dimensional grid where each cell may contain one agenta + * @brief A one-dimensional grid where each cell may contain one agents * * @details The grid is linear and may wrap around in its only dimension. * @@ -64,7 +64,7 @@ namespace kami { * @returns false if the agent is not placed at the specified * location, otherwise, true */ - std::optional add_agent(const AgentID agent_id, const GridCoord1D &coord) override; + std::optional add_agent(AgentID agent_id, const GridCoord1D &coord) override; }; } // namespace kami diff --git a/include/kami/sologrid2d.h b/include/kami/sologrid2d.h index 47568f0..7cab84d 100644 --- a/include/kami/sologrid2d.h +++ b/include/kami/sologrid2d.h @@ -66,7 +66,7 @@ namespace kami { * @returns false if the agent is not placed at the specified * location, otherwise, true */ - std::optional add_agent(const AgentID agent_id, const GridCoord2D &coord) override; + std::optional add_agent(AgentID agent_id, const GridCoord2D &coord) override; }; diff --git a/test/unit-kami-agent.cc b/test/unit-kami-agent.cc index ba6e04b..c89a8b7 100644 --- a/test/unit-kami-agent.cc +++ b/test/unit-kami-agent.cc @@ -51,7 +51,7 @@ protected: shared_ptr model_world = nullptr; void SetUp() override { - auto model_world = make_shared(); + model_world = make_shared(); } }; diff --git a/test/unit-kami-model.cc b/test/unit-kami-model.cc index b03582b..55a3e13 100644 --- a/test/unit-kami-model.cc +++ b/test/unit-kami-model.cc @@ -45,7 +45,7 @@ public: class TestModel : public Model { public: - shared_ptr step() { + shared_ptr step() final { return shared_from_this(); } }; @@ -61,24 +61,24 @@ TEST(Model, DefaultConstructor) { TEST(Model, set_population) { auto model_foo = make_shared(); - auto popul_foo = make_shared(); + auto pop_foo = make_shared(); - auto popul_bar = model_foo->set_population(popul_foo); - EXPECT_EQ(popul_foo, popul_bar); + auto pop_bar = model_foo->set_population(pop_foo); + EXPECT_EQ(pop_foo, pop_bar); } TEST(Model, get_population) { auto model_foo = make_shared(); - auto popul_foo = make_shared(); + auto pop_foo = make_shared(); - auto popul_nul = model_foo->get_population(); + auto pop_nul = model_foo->get_population(); - auto popul_bar = model_foo->set_population(popul_foo); - auto popul_baz = model_foo->get_population(); + auto pop_bar = model_foo->set_population(pop_foo); + auto pop_baz = model_foo->get_population(); - EXPECT_TRUE(popul_baz); - EXPECT_EQ(popul_foo, popul_baz); - EXPECT_EQ(popul_bar, popul_baz); + EXPECT_TRUE(pop_baz); + EXPECT_EQ(pop_foo, pop_baz); + EXPECT_EQ(pop_bar, pop_baz); } TEST(Model, set_scheduler) { diff --git a/test/unit-kami-reporteragent.cc b/test/unit-kami-reporteragent.cc index 86af6a4..9698e62 100644 --- a/test/unit-kami-reporteragent.cc +++ b/test/unit-kami-reporteragent.cc @@ -65,7 +65,7 @@ protected: shared_ptr model_world = nullptr; void SetUp() override { - auto model_world = make_shared(); + model_world = make_shared(); } }; diff --git a/test/unit-kami-sequential.cc b/test/unit-kami-sequential.cc index 484c65a..4b855d5 100644 --- a/test/unit-kami-sequential.cc +++ b/test/unit-kami-sequential.cc @@ -65,16 +65,16 @@ protected: void SetUp() override { mod = make_shared(); - auto popul_foo = make_shared(); + auto pop_foo = make_shared(); auto sched_foo = make_shared(); // Domain is not required for this test - static_cast(mod->set_population(popul_foo)); + static_cast(mod->set_population(pop_foo)); static_cast(mod->set_scheduler(sched_foo)); for (auto i = 0; i < 10; i++) { auto agent_foo = make_shared(); - static_cast(popul_foo->add_agent(agent_foo)); + static_cast(pop_foo->add_agent(agent_foo)); } } }; diff --git a/test/unit-kami-stagedagent.cc b/test/unit-kami-stagedagent.cc index 21e300d..83f2c97 100644 --- a/test/unit-kami-stagedagent.cc +++ b/test/unit-kami-stagedagent.cc @@ -55,7 +55,7 @@ protected: shared_ptr model_world = nullptr; void SetUp() override { - auto model_world = make_shared(); + model_world = make_shared(); } };