Parameters.cpp
Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2010-2014, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
00003 All rights reserved.
00004 
00005 Redistribution and use in source and binary forms, with or without
00006 modification, are permitted provided that the following conditions are met:
00007     * Redistributions of source code must retain the above copyright
00008       notice, this list of conditions and the following disclaimer.
00009     * Redistributions in binary form must reproduce the above copyright
00010       notice, this list of conditions and the following disclaimer in the
00011       documentation and/or other materials provided with the distribution.
00012     * Neither the name of the Universite de Sherbrooke nor the
00013       names of its contributors may be used to endorse or promote products
00014       derived from this software without specific prior written permission.
00015 
00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00017 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00018 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
00020 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00021 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00022 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00023 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00024 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00025 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026 */
00027 
00028 #include "rtabmap/core/Parameters.h"
00029 #include <rtabmap/utilite/UDirectory.h>
00030 #include <rtabmap/utilite/ULogger.h>
00031 #include <rtabmap/utilite/UConversion.h>
00032 #include <math.h>
00033 #include <stdlib.h>
00034 #include <sstream>
00035 
00036 namespace rtabmap
00037 {
00038 
00039 ParametersMap Parameters::parameters_;
00040 ParametersMap Parameters::descriptions_;
00041 Parameters Parameters::instance_;
00042 
00043 Parameters::Parameters()
00044 {
00045 }
00046 
00047 Parameters::~Parameters()
00048 {
00049 }
00050 
00051 std::string Parameters::getDefaultWorkingDirectory()
00052 {
00053         std::string path = UDirectory::homeDir();
00054         if(!path.empty())
00055         {
00056                 UDirectory::makeDir(path += UDirectory::separator() + "Documents");
00057                 UDirectory::makeDir(path += UDirectory::separator() + "RTAB-Map");
00058 
00059         }
00060         else
00061         {
00062                 UFATAL("Can't get the HOME variable environment!");
00063         }
00064         return path;
00065 }
00066 
00067 std::string Parameters::getDefaultDatabaseName()
00068 {
00069         return "rtabmap.db";
00070 }
00071 
00072 std::string Parameters::getDescription(const std::string & paramKey)
00073 {
00074         std::string description;
00075         ParametersMap::iterator iter = descriptions_.find(paramKey);
00076         if(iter != descriptions_.end())
00077         {
00078                 description = iter->second;
00079         }
00080         else
00081         {
00082                 UERROR("Parameters \"%s\" doesn't exist!", paramKey.c_str());
00083         }
00084         return description;
00085 }
00086 
00087 void Parameters::parse(const ParametersMap & parameters, const std::string & key, bool & value)
00088 {
00089         ParametersMap::const_iterator iter = parameters.find(key);
00090         if(iter != parameters.end())
00091         {
00092                 value = uStr2Bool(iter->second.c_str());
00093         }
00094 }
00095 void Parameters::parse(const ParametersMap & parameters, const std::string & key, int & value)
00096 {
00097         ParametersMap::const_iterator iter = parameters.find(key);
00098         if(iter != parameters.end())
00099         {
00100                 value = atoi(iter->second.c_str());
00101         }
00102 }
00103 void Parameters::parse(const ParametersMap & parameters, const std::string & key, unsigned int & value)
00104 {
00105         ParametersMap::const_iterator iter = parameters.find(key);
00106         if(iter != parameters.end())
00107         {
00108                 value = atoi(iter->second.c_str());
00109         }
00110 }
00111 void Parameters::parse(const ParametersMap & parameters, const std::string & key, float & value)
00112 {
00113         ParametersMap::const_iterator iter = parameters.find(key);
00114         if(iter != parameters.end())
00115         {
00116                 value = uStr2Float(iter->second);
00117         }
00118 }
00119 void Parameters::parse(const ParametersMap & parameters, const std::string & key, double & value)
00120 {
00121         ParametersMap::const_iterator iter = parameters.find(key);
00122         if(iter != parameters.end())
00123         {
00124                 value = uStr2Double(iter->second);
00125         }
00126 }
00127 void Parameters::parse(const ParametersMap & parameters, const std::string & key, std::string & value)
00128 {
00129         ParametersMap::const_iterator iter = parameters.find(key);
00130         if(iter != parameters.end())
00131         {
00132                 value = iter->second;
00133         }
00134 }
00135 
00136 }


rtabmap
Author(s): Mathieu Labbe
autogenerated on Fri Aug 28 2015 12:51:32