StitcherOptions.cpp

Go to the documentation of this file.
00001 // -*- c-basic-offset: 4 -*-
00009 /*  This is free software; you can redistribute it and/or
00010  *  modify it under the terms of the GNU General Public
00011  *  License as published by the Free Software Foundation; either
00012  *  version 2 of the License, or (at your option) any later version.
00013  *
00014  *  This software is distributed in the hope that it will be useful,
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017  *  Lesser General Public License for more details.
00018  *
00019  *  You should have received a copy of the GNU General Public
00020  *  License along with this software. If not, see
00021  *  <http://www.gnu.org/licenses/>.
00022  *
00023  */
00024 
00025 #include "StitcherOptions.h"
00026 #include "hugin_utils/utils.h"
00027 
00028 namespace HuginBase
00029 {
00030 namespace Nona
00031 {
00032 
00033 bool GetAdvancedOption(const AdvancedOptions& opts, const std::string& name, const bool defaultValue)
00034 {
00035     AdvancedOptions::const_iterator it = opts.find(name);
00036     if (it != opts.end())
00037     {
00038         //option is stored
00039         const std::string value(it->second);
00040         if (value == "true" || value == "1")
00041         {
00042             return true;
00043         }
00044         return false;
00045     }
00046     else
00047     {
00048         return defaultValue;
00049     };
00050 };
00051 
00052 std::string GetAdvancedOption(const AdvancedOptions& opts, const std::string& name, const std::string& defaultValue)
00053 {
00054     AdvancedOptions::const_iterator it = opts.find(name);
00055     if (it != opts.end())
00056     {
00057         //option is stored
00058         return it->second;
00059     }
00060     else
00061     {
00062         return defaultValue;
00063     };
00064 };
00065 
00066 float GetAdvancedOption(const AdvancedOptions& opts, const std::string& name, const float defaultValue)
00067 {
00068     AdvancedOptions::const_iterator it = opts.find(name);
00069     if (it != opts.end())
00070     {
00071         //option is stored
00072         double value;
00073         if (hugin_utils::stringToDouble(it->second, value))
00074         {
00075             return static_cast<float>(value);
00076         }
00077         else
00078         {
00079             return defaultValue;
00080         };
00081     }
00082     else
00083     {
00084         return defaultValue;
00085     };
00086 };
00087 
00088 void SetAdvancedOption(AdvancedOptions& opts, const std::string& name, const bool value)
00089 {
00090     if (value)
00091     {
00092         opts[name] = "true";
00093     }
00094     else
00095     {
00096         opts[name] = "false";
00097     };
00098 };
00099 
00100 void SetAdvancedOption(AdvancedOptions& opts, const std::string& name, const std::string& value)
00101 {
00102     opts[name] = value;
00103 };
00104 
00105 void SetAdvancedOption(AdvancedOptions& opts, const std::string& name, const float value)
00106 {
00107     opts[name] = hugin_utils::doubleToString(value);
00108 };
00109 
00110 } // namespace Nona
00111 } // namespace HuginBase

Generated on 21 Jan 2018 for Hugintrunk by  doxygen 1.4.7