Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion siteupdate/cplusplus/classes/GraphGeneration/GraphListEntry.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
#define FMT_HEADER_ONLY
#include "GraphListEntry.h"
#include "PlaceRadius.h"
#include "../ErrorList/ErrorList.h"
#include "../HighwaySystem/HighwaySystem.h"
#include "../Region/Region.h"
#include <fmt/format.h>

std::vector<GraphListEntry> GraphListEntry::entries;
size_t GraphListEntry::num; // iterator for entries
std::unordered_map<std::string, GraphListEntry*> GraphListEntry::unique_names;

GraphListEntry::GraphListEntry(std::string r, std::string d, char f, char c, std::vector<Region*> *rg, std::vector<HighwaySystem*> *sys, PlaceRadius *pr):
regions(rg), systems(sys), placeradius(pr),
root(r), descr(d), form(f), cat(c) {}

void GraphListEntry::add_group(std::string&& r, std::string&& d, char c, std::vector<Region*> *rg, std::vector<HighwaySystem*> *sys, PlaceRadius *pr)
void GraphListEntry::add_group(std::string&& r, std::string&& d, char c, std::vector<Region*> *rg, std::vector<HighwaySystem*> *sys, PlaceRadius *pr, ErrorList& el)
{ GraphListEntry::entries.emplace_back(r, d, 's', c, rg, sys, pr);
GraphListEntry::entries.emplace_back(r, d, 'c', c, rg, sys, pr);
GraphListEntry::entries.emplace_back(r, d, 't', c, rg, sys, pr);
GraphListEntry* this_one = &GraphListEntry::entries.back();
auto ib = unique_names.emplace(r, this_one);
if (!ib.second)
{ GraphListEntry* that_one = ib.first->second;
std::string err = "Duplicate graph name " + r + " in " + that_one->category();
if (this_one->cat != that_one->cat)
err += " and " + this_one->category();
err += " graphs";
el.add_error(err);
}
}

std::string GraphListEntry::filename()
Expand Down
7 changes: 5 additions & 2 deletions siteupdate/cplusplus/classes/GraphGeneration/GraphListEntry.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
class ErrorList;
class HighwaySystem;
class PlaceRadius;
class Region;
#include <string>
#include <unordered_map>
#include <vector>

class GraphListEntry
Expand All @@ -26,8 +28,9 @@ class GraphListEntry

static std::vector<GraphListEntry> entries;
static size_t num; // iterator for entries
std::string tag();
static std::unordered_map<std::string, GraphListEntry*> unique_names;

GraphListEntry(std::string, std::string, char, char, std::vector<Region*>*, std::vector<HighwaySystem*>*, PlaceRadius*);
static void add_group(std::string&&, std::string&&, char, std::vector<Region*>*, std::vector<HighwaySystem*>*, PlaceRadius*);
static void add_group(std::string&&, std::string&&, char, std::vector<Region*>*, std::vector<HighwaySystem*>*, PlaceRadius*, ErrorList&);
std::string tag();
};
2 changes: 1 addition & 1 deletion siteupdate/cplusplus/tasks/graph_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ vector<HighwaySystem*> *systems;
list<array<string,3>> graph_types; // create list of graph information for the DB
graph_types.push_back({"master", "All Travel Mapping Data",
"These graphs contain all routes currently plotted in the Travel Mapping project."});
GraphListEntry::add_group("tm-master", "All Travel Mapping Data", 'M', nullptr, nullptr, nullptr);
GraphListEntry::add_group("tm-master", "All Travel Mapping Data", 'M', nullptr, nullptr, nullptr, el);
#include "subgraphs/continent.cpp"
#include "subgraphs/multisystem.cpp"
#include "subgraphs/system.cpp"
Expand Down
2 changes: 1 addition & 1 deletion siteupdate/cplusplus/tasks/subgraphs/area.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ while (getline(file, line))
GraphListEntry::add_group(
string(fields[1]) + fields[4] + "-area",
string(fields[0]) + " (" + fields[4] + " mi radius)",
'a', nullptr, nullptr, a);
'a', nullptr, nullptr, a, el);
delete[] cline;
}
file.close();
Expand Down
2 changes: 1 addition & 1 deletion siteupdate/cplusplus/tasks/subgraphs/continent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ for (auto c = Region::continents.data(), dummy = c+Region::continents.size()-1;
else { GraphListEntry::add_group(
c->first + "-continent",
c->second + " All Routes on Continent",
'C', regions, nullptr, nullptr);
'C', regions, nullptr, nullptr, el);
}
}
graph_types.push_back({"continent", "Routes Within a Continent", "These graphs contain the routes on a continent."});
2 changes: 1 addition & 1 deletion siteupdate/cplusplus/tasks/subgraphs/country.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ for (auto c = Region::countries.data(), dummy = c+Region::countries.size()-1; c
else { GraphListEntry::add_group(
c->first + "-country",
c->second + " All Routes in Country",
'c', regions, nullptr, nullptr);
'c', regions, nullptr, nullptr, el);
}
}
graph_types.push_back({"country", "Routes Within a Single Multi-Region Country",
Expand Down
2 changes: 1 addition & 1 deletion siteupdate/cplusplus/tasks/subgraphs/fullcustom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ if (file.is_open())
}
delete[] field;
}
if (ok) GraphListEntry::add_group(std::move(root), std::move(descr), 'f', regions, systems, a);
if (ok) GraphListEntry::add_group(std::move(root), std::move(descr), 'f', regions, systems, a, el);
else { delete regions;
delete systems;
delete a;
Expand Down
2 changes: 1 addition & 1 deletion siteupdate/cplusplus/tasks/subgraphs/multiregion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ while (getline(file, line))
catch (const out_of_range&)
{ el.add_error("unrecognized region code "+string(rg)+" in multiregion.csv line: "+line);
}
if (regions->size()) GraphListEntry::add_group(fields[1], fields[0], 'R', regions, nullptr, nullptr);
if (regions->size()) GraphListEntry::add_group(fields[1], fields[0], 'R', regions, nullptr, nullptr, el);
else delete regions;
delete[] cline;
}
Expand Down
2 changes: 1 addition & 1 deletion siteupdate/cplusplus/tasks/subgraphs/multisystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ while (getline(file, line))
catch (const std::out_of_range&)
{ el.add_error("unrecognized system code "+string(s)+" in multisystem.csv line: "+line);
}
if (systems->size()) GraphListEntry::add_group(fields[1], fields[0], 'S', nullptr, systems, nullptr);
if (systems->size()) GraphListEntry::add_group(fields[1], fields[0], 'S', nullptr, systems, nullptr, el);
else delete systems;
delete[] cline;
}
Expand Down
2 changes: 1 addition & 1 deletion siteupdate/cplusplus/tasks/subgraphs/region.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ for (Region& region : Region::allregions)
GraphListEntry::add_group(
region.code + "-region",
region.name + " (" + region.type + ")", 'r',
new vector<Region*>(1, &region), nullptr, nullptr);
new vector<Region*>(1, &region), nullptr, nullptr, el);
// deleted @ end of HighwayGraph::write_subgraphs_tmg
}
graph_types.push_back({"region", "Routes Within a Single Region", "These graphs contain all routes currently plotted within the given region."});
2 changes: 1 addition & 1 deletion siteupdate/cplusplus/tasks/subgraphs/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ while (getline(file, line))
{ GraphListEntry::add_group(
h->systemname + "-system",
h->systemname + " (" + h->fullname + ")",
's', nullptr, new vector<HighwaySystem*>(1, h), nullptr);
's', nullptr, new vector<HighwaySystem*>(1, h), nullptr, el);
// deleted @ end of HighwayGraph::write_subgraphs_tmg
h->is_subgraph_system = 1;
} else el.add_error("devel system "+h->systemname+" in systemgraphs.csv");
Expand Down