From 94288843f1b1e0af0678bdaf67ac0fd0ecc498d5 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Mon, 27 Oct 2014 12:21:29 -0400 Subject: [PATCH] make entire_length variable a private member that cannot be set from the outside and only accessed thru a const getter. --- Descriptors/DescriptionFactory.cpp | 2 +- Descriptors/DescriptionFactory.h | 11 ++++++++--- Descriptors/JSONDescriptor.h | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Descriptors/DescriptionFactory.cpp b/Descriptors/DescriptionFactory.cpp index 715bf6903..6eb22c927 100644 --- a/Descriptors/DescriptionFactory.cpp +++ b/Descriptors/DescriptionFactory.cpp @@ -36,7 +36,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../DataStructures/SegmentInformation.h" #include "../DataStructures/TurnInstructions.h" -DescriptionFactory::DescriptionFactory() : entireLength(0) { via_indices.push_back(0); } +DescriptionFactory::DescriptionFactory() : entire_length(0) { via_indices.push_back(0); } std::vector const &DescriptionFactory::GetViaIndices() const { return via_indices; } diff --git a/Descriptors/DescriptionFactory.h b/Descriptors/DescriptionFactory.h index ac4c70234..b3c6e42a5 100644 --- a/Descriptors/DescriptionFactory.h +++ b/Descriptors/DescriptionFactory.h @@ -55,6 +55,8 @@ class DescriptionFactory std::vector via_indices; + double entire_length; + public: struct RouteSummary { @@ -72,8 +74,6 @@ class DescriptionFactory } } summary; - double entireLength; - // I know, declaring this public is considered bad. I'm lazy std::vector path_description; DescriptionFactory(); @@ -86,6 +86,11 @@ class DescriptionFactory JSON::Value AppendGeometryString(const bool return_encoded); std::vector const &GetViaIndices() const; + double get_entire_length() const + { + return entire_length; + } + template void Run(const DataFacadeT *facade, const unsigned zoomLevel) { if (path_description.empty()) @@ -152,7 +157,7 @@ class DescriptionFactory for (unsigned i = 1; i < path_description.size(); ++i) { - entireLength += path_description[i].length; + entire_length += path_description[i].length; segment_length += path_description[i].length; segment_duration += path_description[i].duration; path_description[segment_start_index].length = segment_length; diff --git a/Descriptors/JSONDescriptor.h b/Descriptors/JSONDescriptor.h index 609457e37..0614e2c71 100644 --- a/Descriptors/JSONDescriptor.h +++ b/Descriptors/JSONDescriptor.h @@ -149,7 +149,7 @@ template class JSONDescriptor final : public BaseDescriptor< shortest_path_segments); json_result.values["route_instructions"] = json_route_instructions; } - description_factory.BuildRouteSummary(description_factory.entireLength, + description_factory.BuildRouteSummary(description_factory.get_entire_length(), raw_route.shortest_path_length); JSON::Object json_route_summary; json_route_summary.values["total_distance"] = description_factory.summary.distance; @@ -231,7 +231,7 @@ template class JSONDescriptor final : public BaseDescriptor< json_result.values["alternative_instructions"] = json_alt_instructions; } alternate_description_factory.BuildRouteSummary( - alternate_description_factory.entireLength, raw_route.alternative_path_length); + alternate_description_factory.get_entire_length(), raw_route.alternative_path_length); JSON::Object json_alternate_route_summary; JSON::Array json_alternate_route_summary_array;