Fixed memory leak
Added logging
This commit is contained in:
@ -9,33 +9,28 @@
|
||||
#include "../../src/model/Community.h"
|
||||
#include "../../src/model/Energy_Tariff.h"
|
||||
|
||||
namespace Building
|
||||
{
|
||||
namespace Building {
|
||||
class Cost;
|
||||
}
|
||||
|
||||
class Factory
|
||||
{
|
||||
class Factory {
|
||||
public:
|
||||
std::unique_ptr<Building::Cost> static create_test_cost()
|
||||
{
|
||||
std::unique_ptr<Building::Cost> static create_test_cost() {
|
||||
auto cost = std::make_unique<Building::Cost>();
|
||||
cost->set_special_rate_consumption(0.15f);
|
||||
cost->set_special_rate_generation(0.10f);
|
||||
return cost;
|
||||
}
|
||||
|
||||
std::unique_ptr<Building::Simulation_Values> static create_test_simulation_values()
|
||||
{
|
||||
std::unique_ptr<Building::Simulation_Values> static create_test_simulation_values() {
|
||||
auto values = std::make_unique<Building::Simulation_Values>();
|
||||
|
||||
auto communityCoverage = std::vector<std::unique_ptr<float>>();
|
||||
auto ownUsage = std::vector<std::unique_ptr<float>>();
|
||||
auto neededCon = std::vector<std::unique_ptr<float>>();
|
||||
auto neededGen = std::vector<std::unique_ptr<float>>();
|
||||
auto communityCoverage = std::vector<std::unique_ptr<float> >();
|
||||
auto ownUsage = std::vector<std::unique_ptr<float> >();
|
||||
auto neededCon = std::vector<std::unique_ptr<float> >();
|
||||
auto neededGen = std::vector<std::unique_ptr<float> >();
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
for (int i = 0; i < 5; i++) {
|
||||
// Populate with test values
|
||||
communityCoverage.push_back(std::make_unique<float>(i * 10.0f));
|
||||
ownUsage.push_back(std::make_unique<float>(i * 5.0f));
|
||||
@ -51,8 +46,7 @@ public:
|
||||
return values;
|
||||
}
|
||||
|
||||
std::unique_ptr<Building::Metadata> static create_test_metadata()
|
||||
{
|
||||
std::unique_ptr<Building::Metadata> static create_test_metadata() {
|
||||
auto metadata = std::make_unique<Building::Metadata>();
|
||||
metadata->set_name("Test Building");
|
||||
metadata->set_annual_consumption(12000.0f);
|
||||
@ -62,11 +56,10 @@ public:
|
||||
metadata->set_connection_power(100);
|
||||
metadata->set_grid_power(50);
|
||||
|
||||
auto consumptionProfile = std::vector<std::unique_ptr<float>>();
|
||||
auto generationProfile = std::vector<std::unique_ptr<float>>();
|
||||
auto consumptionProfile = std::vector<std::unique_ptr<float> >();
|
||||
auto generationProfile = std::vector<std::unique_ptr<float> >();
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
for (int i = 0; i < 5; i++) {
|
||||
// Populate with test values
|
||||
consumptionProfile.push_back(std::make_unique<float>(i * 100.0f));
|
||||
generationProfile.push_back(std::make_unique<float>(i * 50.0f));
|
||||
@ -78,8 +71,7 @@ public:
|
||||
return metadata;
|
||||
}
|
||||
|
||||
std::unique_ptr<Building::Base> static create_test_building()
|
||||
{
|
||||
std::unique_ptr<Building::Base> static create_test_building() {
|
||||
auto building = std::make_unique<Building::Base>();
|
||||
|
||||
building->set_cost(create_test_cost());
|
||||
@ -89,19 +81,16 @@ public:
|
||||
return building;
|
||||
}
|
||||
|
||||
Energy_Tariff static create_test_energy_tariff()
|
||||
{
|
||||
Energy_Tariff static create_test_energy_tariff() {
|
||||
return {};
|
||||
}
|
||||
|
||||
std::unique_ptr<Community> static create_test_community()
|
||||
{
|
||||
std::unique_ptr<Community> static create_test_community() {
|
||||
auto community = std::make_unique<Community>();
|
||||
community->set_name("Test Community");
|
||||
|
||||
std::vector<std::unique_ptr<Building::Base>> buildings;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
std::vector<std::unique_ptr<Building::Base> > buildings;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
buildings.push_back(create_test_building());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user