From 99c815a5610f22ff32ef83c69bb2e4bc330a9eac Mon Sep 17 00:00:00 2001 From: Phuntsok Drak-pa Date: Wed, 27 Mar 2019 14:31:07 +0100 Subject: [PATCH] changed function signature (best practices) --- include/genimg/methods.hh | 6 +++--- src/methods.cc | 10 +++++----- src/parseargs.cc | 15 ++++++++------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/include/genimg/methods.hh b/include/genimg/methods.hh index a0a2078..edd095b 100644 --- a/include/genimg/methods.hh +++ b/include/genimg/methods.hh @@ -5,10 +5,10 @@ #include #include -void method1(cv::Mat &t_reference, cv::Mat &t_output, int t_iterations); +void method1(cv::Mat const &, cv::Mat &, int); -void method2(cv::Mat &t_reference, cv::Mat &t_output, int t_iterations); +void method2(cv::Mat const &, cv::Mat &, int); -void method3(cv::Mat &t_reference, cv::Mat &t_output, int t_iterations); +void method3(cv::Mat const &, cv::Mat &, int); #endif /* GENETIC_IMAGE_INCLUDE_GENIMG_METHODS_HH_ */ diff --git a/src/methods.cc b/src/methods.cc index 5f0619b..8ae79a9 100644 --- a/src/methods.cc +++ b/src/methods.cc @@ -40,7 +40,7 @@ void newSquare1(cv::Mat &t_process_img, cv::Point &&t_top_left, int t_size) { draw_shape(t_process_img, t_top_left, t_size, randomColor(), Shapes::Square); } -void threadedGetColor(cv::Mat &t_reference, ColorSet &t_colors, int t_h) { +void threadedGetColor(cv::Mat const &t_reference, ColorSet &t_colors, int t_h) { if (t_h > t_reference.size().height) return; for (int w = 0; w < t_reference.size().width; w += 3) { @@ -56,7 +56,7 @@ void threadedGetColor(cv::Mat &t_reference, ColorSet &t_colors, int t_h) { } } -[[nodiscard]] ColorSet getColorSet(cv::Mat &t_reference) { +[[nodiscard]] ColorSet getColorSet(cv::Mat const &t_reference) { ColorSet res{}; for (int h = 0; h < t_reference.size().height; h += thread_nbr) { std::vector thread_list{}; @@ -83,7 +83,7 @@ void newSquare2(cv::Mat &t_process_img, cv::Point &&t_top_left, int t_size, } // namespace methods_private -void method1(cv::Mat &t_reference, cv::Mat &t_output, int t_iterations) { +void method1(cv::Mat const &t_reference, cv::Mat &t_output, int t_iterations) { auto diff = euclidian_distance(t_reference, t_output); spdlog::debug("Beginning method1, initial difference: {}", diff); while (t_iterations > 0 && diff >= 0) { @@ -103,7 +103,7 @@ void method1(cv::Mat &t_reference, cv::Mat &t_output, int t_iterations) { } } -void method2(cv::Mat &t_reference, cv::Mat &t_output, int t_iterations) { +void method2(cv::Mat const &t_reference, cv::Mat &t_output, int t_iterations) { auto diff = euclidian_distance(t_reference, t_output); spdlog::debug("Beginning method2, initial difference: {}", diff); spdlog::debug("Running {} threads.", thread_nbr); @@ -128,7 +128,7 @@ void method2(cv::Mat &t_reference, cv::Mat &t_output, int t_iterations) { } } -void method3(cv::Mat &t_reference, cv::Mat &t_output, int t_iterations) { +void method3(cv::Mat const &t_reference, cv::Mat &t_output, int t_iterations) { auto const init_iter = t_iterations; auto diff = euclidian_distance(t_reference, t_output); spdlog::debug("Beginning method2, initial difference: {}", diff); diff --git a/src/parseargs.cc b/src/parseargs.cc index fe735e7..dfb9720 100644 --- a/src/parseargs.cc +++ b/src/parseargs.cc @@ -21,13 +21,14 @@ void processFilenames(po::variables_map const &vm, path const &t_input, [[nodiscard]] std::tuple parse_args(int t_ac, char **t_av) { po::options_description desc("Allowed options"); - desc.add_options()("help,h", "Display this help message")( - "input,i", po::value(), - "Input image")("output,o", po::value(), - "Image output path (default: input path + \"_output\")")( - "method,m", po::value(), "Method number to be used (default: 1)")( - "iterations,n", po::value(), - "Number of iterations (default: 5000)")("verbose,v", "Enables verbosity"); + desc.add_options() + ("help,h", "Display this help message") + ("input,i", po::value(), "Input image") + ("output,o", po::value(), + "Image output path (default: input path + \"_output\")") + ("method,m", po::value(), "Method number to be used (default: 1)") + ("iterations,n", po::value(), "Number of iterations (default: 5000)") + ("verbose,v", "Enables verbosity"); po::variables_map vm; po::store(po::parse_command_line(t_ac, t_av, desc), vm); po::notify(vm);