<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>The MRPT project: types.h Source File</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> <link href="tabs.css" rel="stylesheet" type="text/css"> </head><body> <div align="left"><a href="http://www.mrpt.org/">Main MRPT website</a> > <b>C++ reference</b> </div> <div align="right"> <a href="index.html"><img border="0" src="mrpt_logo.png" alt="MRPT logo"></a> </div> <!-- Generated by Doxygen 1.7.2 --> <script type="text/javascript"><!-- var searchBox = new SearchBox("searchBox", "search",false,'Search'); --></script> <div class="navigation" id="top"> <div class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li id="searchli"> <div id="MSearchBox" class="MSearchBoxInactive"> <span class="left"> <form id="FSearchBox" action="search.php" method="get"> <img id="MSearchSelect" src="search/mag.png" alt=""/> <input type="text" id="MSearchField" name="query" value="Search" size="20" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" onblur="searchBox.OnSearchFieldFocus(false)"/> </form> </span><span class="right"></span> </div> </li> </ul> </div> <div class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <div class="header"> <div class="headertitle"> <h1>types.h</h1> </div> </div> <div class="contents"> <a href="base_2include_2mrpt_2utils_2types_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* +---------------------------------------------------------------------------+</span> <a name="l00002"></a>00002 <span class="comment"> | The Mobile Robot Programming Toolkit (MRPT) C++ library |</span> <a name="l00003"></a>00003 <span class="comment"> | |</span> <a name="l00004"></a>00004 <span class="comment"> | http://mrpt.sourceforge.net/ |</span> <a name="l00005"></a>00005 <span class="comment"> | |</span> <a name="l00006"></a>00006 <span class="comment"> | Copyright (C) 2005-2011 University of Malaga |</span> <a name="l00007"></a>00007 <span class="comment"> | |</span> <a name="l00008"></a>00008 <span class="comment"> | This software was written by the Machine Perception and Intelligent |</span> <a name="l00009"></a>00009 <span class="comment"> | Robotics Lab, University of Malaga (Spain). |</span> <a name="l00010"></a>00010 <span class="comment"> | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |</span> <a name="l00011"></a>00011 <span class="comment"> | |</span> <a name="l00012"></a>00012 <span class="comment"> | This file is part of the MRPT project. |</span> <a name="l00013"></a>00013 <span class="comment"> | |</span> <a name="l00014"></a>00014 <span class="comment"> | MRPT is free software: you can redistribute it and/or modify |</span> <a name="l00015"></a>00015 <span class="comment"> | it under the terms of the GNU General Public License as published by |</span> <a name="l00016"></a>00016 <span class="comment"> | the Free Software Foundation, either version 3 of the License, or |</span> <a name="l00017"></a>00017 <span class="comment"> | (at your option) any later version. |</span> <a name="l00018"></a>00018 <span class="comment"> | |</span> <a name="l00019"></a>00019 <span class="comment"> | MRPT is distributed in the hope that it will be useful, |</span> <a name="l00020"></a>00020 <span class="comment"> | but WITHOUT ANY WARRANTY; without even the implied warranty of |</span> <a name="l00021"></a>00021 <span class="comment"> | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |</span> <a name="l00022"></a>00022 <span class="comment"> | GNU General Public License for more details. |</span> <a name="l00023"></a>00023 <span class="comment"> | |</span> <a name="l00024"></a>00024 <span class="comment"> | You should have received a copy of the GNU General Public License |</span> <a name="l00025"></a>00025 <span class="comment"> | along with MRPT. If not, see <http://www.gnu.org/licenses/>. |</span> <a name="l00026"></a>00026 <span class="comment"> | |</span> <a name="l00027"></a>00027 <span class="comment"> +---------------------------------------------------------------------------+ */</span> <a name="l00028"></a>00028 <a name="l00029"></a>00029 <span class="preprocessor">#ifndef mrpt_utils_types_H</span> <a name="l00030"></a>00030 <span class="preprocessor"></span><span class="preprocessor">#define mrpt_utils_types_H</span> <a name="l00031"></a>00031 <span class="preprocessor"></span> <a name="l00032"></a>00032 <span class="preprocessor">#include <vector></span> <a name="l00033"></a>00033 <span class="preprocessor">#include <list></span> <a name="l00034"></a>00034 <span class="preprocessor">#include <set></span> <a name="l00035"></a>00035 <span class="preprocessor">#include <map></span> <a name="l00036"></a>00036 <span class="preprocessor">#include <string></span> <a name="l00037"></a>00037 <span class="preprocessor">#include <stdexcept></span> <a name="l00038"></a>00038 <span class="preprocessor">#include <cstdarg></span> <a name="l00039"></a>00039 <span class="preprocessor">#include <iostream></span> <a name="l00040"></a>00040 <span class="preprocessor">#include <sstream></span> <a name="l00041"></a>00041 <a name="l00042"></a>00042 <span class="preprocessor">#include <ctime></span> <a name="l00043"></a>00043 <a name="l00044"></a>00044 <span class="comment">// Define macros in platform dependant stdint.h header:</span> <a name="l00045"></a>00045 <span class="preprocessor">#ifndef __STDC_FORMAT_MACROS</span> <a name="l00046"></a><a class="code" href="base_2include_2mrpt_2utils_2types_8h.html#aacbb9e1f38be71e22df1584a37c56693">00046</a> <span class="preprocessor"></span><span class="preprocessor"># define __STDC_FORMAT_MACROS</span> <a name="l00047"></a>00047 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00048"></a>00048 <span class="preprocessor"></span><span class="preprocessor">#ifndef __STDC_CONSTANT_MACROS</span> <a name="l00049"></a><a class="code" href="base_2include_2mrpt_2utils_2types_8h.html#a786132414c30f947907be33a4c28125a">00049</a> <span class="preprocessor"></span><span class="preprocessor"># define __STDC_CONSTANT_MACROS</span> <a name="l00050"></a>00050 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00051"></a>00051 <span class="preprocessor"></span><span class="preprocessor">#ifndef __STDC_LIMIT_MACROS</span> <a name="l00052"></a><a class="code" href="base_2include_2mrpt_2utils_2types_8h.html#aeb7e7a856ab7a794b05b6b63ef36ea3e">00052</a> <span class="preprocessor"></span><span class="preprocessor"># define __STDC_LIMIT_MACROS</span> <a name="l00053"></a>00053 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00054"></a>00054 <span class="preprocessor"></span> <a name="l00055"></a>00055 <span class="comment">// Standard elemental types:</span> <a name="l00056"></a>00056 <span class="preprocessor">#include "<a class="code" href="pstdint_8h.html">pstdint.h</a>"</span> <span class="comment">// The "portable stdint header file"</span> <a name="l00057"></a>00057 <a name="l00058"></a>00058 <span class="preprocessor">#if HAVE_INTTYPES_H</span> <a name="l00059"></a>00059 <span class="preprocessor"></span><span class="preprocessor"># include <inttypes.h></span> <a name="l00060"></a>00060 <span class="preprocessor">#elif defined(_MSC_VER)</span> <a name="l00061"></a>00061 <span class="preprocessor"></span><span class="preprocessor"># include <<a class="code" href="msvc__inttypes_8h.html">mrpt/utils/msvc_inttypes.h</a>></span> <a name="l00062"></a>00062 <span class="preprocessor">#endif</span> <a name="l00063"></a>00063 <span class="preprocessor"></span> <a name="l00064"></a>00064 <span class="comment">// SSE2, SSE3 types:</span> <a name="l00065"></a>00065 <span class="preprocessor">#if MRPT_HAS_SSE2</span> <a name="l00066"></a>00066 <span class="preprocessor"></span><span class="preprocessor"> #include <emmintrin.h></span> <a name="l00067"></a>00067 <span class="preprocessor"> #include <mmintrin.h></span> <a name="l00068"></a>00068 <span class="preprocessor">#endif</span> <a name="l00069"></a>00069 <span class="preprocessor"></span> <a name="l00070"></a>00070 <span class="comment">// needed here for a few basic types used in Eigen MRPT's plugin:</span> <a name="l00071"></a>00071 <span class="preprocessor">#include <<a class="code" href="math__frwds_8h.html">mrpt/math/math_frwds.h</a>></span> <a name="l00072"></a>00072 <a name="l00073"></a>00073 <span class="comment">// --------------------------------------------------</span> <a name="l00074"></a>00074 <span class="comment">// Include the Eigen3 library headers, including</span> <a name="l00075"></a>00075 <span class="comment">// MRPT's extensions:</span> <a name="l00076"></a>00076 <span class="comment">// --------------------------------------------------</span> <a name="l00077"></a>00077 <span class="preprocessor">#include <iostream></span> <span class="comment">// These headers are assumed by <mrpt/math/eigen_plugins.h>:</span> <a name="l00078"></a>00078 <span class="preprocessor">#include <fstream></span> <a name="l00079"></a>00079 <span class="preprocessor">#include <sstream></span> <a name="l00080"></a>00080 <span class="preprocessor">#ifdef EIGEN_MAJOR_VERSION</span> <a name="l00081"></a>00081 <span class="preprocessor"></span><span class="preprocessor"># error **FATAL ERROR**: MRPT headers must be included before Eigen headers.</span> <a name="l00082"></a>00082 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00083"></a><a class="code" href="base_2include_2mrpt_2utils_2types_8h.html#add81a3e8d99fc68c376b2e54acb2412c">00083</a> <span class="preprocessor"></span><span class="preprocessor">#define EIGEN_USE_NEW_STDVECTOR</span> <a name="l00084"></a>00084 <span class="preprocessor"></span><span class="preprocessor">#include <<a class="code" href="_dense.html">Eigen/Dense</a>></span> <a name="l00085"></a>00085 <span class="preprocessor">#include <Eigen/StdVector></span> <a name="l00086"></a>00086 <span class="preprocessor">#include <Eigen/StdDeque></span> <a name="l00087"></a>00087 <a name="l00088"></a>00088 <span class="preprocessor">#if !EIGEN_VERSION_AT_LEAST(2,90,0)</span> <a name="l00089"></a>00089 <span class="preprocessor"></span><span class="preprocessor">#error MRPT needs version 3.0.0-beta of Eigen or newer</span> <a name="l00090"></a>00090 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00091"></a>00091 <span class="preprocessor"></span> <a name="l00092"></a>00092 <span class="comment">// Template implementations that need to be after all Eigen includes:</span> <a name="l00093"></a>00093 <span class="preprocessor">#include EIGEN_MATRIXBASE_PLUGIN_POST_IMPL</span> <a name="l00094"></a>00094 <span class="preprocessor"></span><span class="comment">// --------------------------------------------------</span> <a name="l00095"></a>00095 <span class="comment">// End of Eigen includes</span> <a name="l00096"></a>00096 <span class="comment">// --------------------------------------------------</span> <a name="l00097"></a>00097 <a name="l00098"></a>00098 <a name="l00099"></a>00099 <span class="comment">// This must be put inside any MRPT class that inherits from an Eigen class:</span> <a name="l00100"></a><a class="code" href="base_2include_2mrpt_2utils_2types_8h.html#a5423f1c8bf92c8c2bb6592ee8ac333ef">00100</a> <span class="preprocessor">#define MRPT_EIGEN_DERIVED_CLASS_CTOR_OPERATOR_EQUAL(_CLASS_) \</span> <a name="l00101"></a>00101 <span class="preprocessor"></span><span class="comment"> /*! Assignment operator from any other Eigen class */</span> \ <a name="l00102"></a>00102 template<typename OtherDerived> \ <a name="l00103"></a>00103 inline mrpt_autotype & operator= (const Eigen::MatrixBase <OtherDerived>& other) { \ <a name="l00104"></a>00104 <span class="comment">/*Base::operator=(other.template cast<typename Base::Scalar>());*/</span> \ <a name="l00105"></a>00105 Base::operator=(other); \ <a name="l00106"></a>00106 return *this; \ <a name="l00107"></a>00107 } \ <a name="l00108"></a>00108 <span class="comment"> /*! Constructor from any other Eigen class */</span> \ <a name="l00109"></a>00109 template<typename OtherDerived> \ <a name="l00110"></a>00110 inline _CLASS_(const Eigen::MatrixBase <OtherDerived>& other) : Base(other.template cast<typename Base::Scalar>()) { } \ <a name="l00111"></a>00111 <a name="l00112"></a>00112 <span class="keyword">namespace </span>mrpt <a name="l00113"></a>00113 {<span class="comment"></span> <a name="l00114"></a>00114 <span class="comment"> /** The base class of MRPT vectors, actually, Eigen column matrices of dynamic size with specialized constructors that resemble std::vector. */</span> <a name="l00115"></a>00115 <span class="keyword">template</span> <<span class="keyword">typename</span> T> <a name="l00116"></a><a class="code" href="structmrpt_1_1dynamicsize__vector.html">00116</a> <span class="keyword">struct </span><a class="code" href="structmrpt_1_1dynamicsize__vector.html" title="The base class of MRPT vectors, actually, Eigen column matrices of dynamic size with specialized cons...">dynamicsize_vector</a> : <span class="keyword">public</span> Eigen::<a class="code" href="class_matrix.html" title="The matrix class, also used for vectors and row-vectors.">Matrix</a><T,Eigen::Dynamic,1> <a name="l00117"></a>00117 { <a name="l00118"></a><a class="code" href="structmrpt_1_1dynamicsize__vector.html#aeff1d743897d0e82cf534b3d32c97744">00118</a> <span class="keyword">typedef</span> Eigen::Matrix<T,Eigen::Dynamic,1> <a class="code" href="structmrpt_1_1dynamicsize__vector.html#aeff1d743897d0e82cf534b3d32c97744">Base</a>; <a name="l00119"></a><a class="code" href="structmrpt_1_1dynamicsize__vector.html#afbc525adfbc96730ee44d2c95cba1d30">00119</a> <span class="keyword">typedef</span> <a class="code" href="structmrpt_1_1dynamicsize__vector.html" title="The base class of MRPT vectors, actually, Eigen column matrices of dynamic size with specialized cons...">dynamicsize_vector<T></a> <a class="code" href="structmrpt_1_1dynamicsize__vector.html#afbc525adfbc96730ee44d2c95cba1d30">mrpt_autotype</a>; <a name="l00120"></a>00120 <a class="code" href="base_2include_2mrpt_2utils_2types_8h.html#a5423f1c8bf92c8c2bb6592ee8ac333ef">MRPT_EIGEN_DERIVED_CLASS_CTOR_OPERATOR_EQUAL</a>(<a class="code" href="structmrpt_1_1dynamicsize__vector.html" title="The base class of MRPT vectors, actually, Eigen column matrices of dynamic size with specialized cons...">dynamicsize_vector</a>) <a name="l00121"></a>00121 <a name="l00122"></a>00122 <span class="comment">/** Default constructor: empty vector */</span> <a name="l00123"></a><a class="code" href="structmrpt_1_1dynamicsize__vector.html#a5b7fd25ba9aedb72bb3dee2d047239d3">00123</a> inline <a class="code" href="structmrpt_1_1dynamicsize__vector.html" title="The base class of MRPT vectors, actually, Eigen column matrices of dynamic size with specialized cons...">dynamicsize_vector</a>() : <a class="code" href="structmrpt_1_1dynamicsize__vector.html#aeff1d743897d0e82cf534b3d32c97744">Base</a>() {}<span class="comment"></span> <a name="l00124"></a>00124 <span class="comment"> /** Constructor, initializes to a given initial size */</span> <a name="l00125"></a><a class="code" href="structmrpt_1_1dynamicsize__vector.html#a6386994904cd888107a518a17a2d22fd">00125</a> <span class="keyword">inline</span> <a class="code" href="structmrpt_1_1dynamicsize__vector.html#a6386994904cd888107a518a17a2d22fd" title="Constructor, initializes to a given initial size.">dynamicsize_vector</a>(<span class="keywordtype">size_t</span> N) : <a class="code" href="structmrpt_1_1dynamicsize__vector.html#aeff1d743897d0e82cf534b3d32c97744">Base</a>(N,1) { Base::derived().setZero(); }<span class="comment"></span> <a name="l00126"></a>00126 <span class="comment"> /** Constructor, initializes to a given initial size, all elements to a given value */</span> <a name="l00127"></a><a class="code" href="structmrpt_1_1dynamicsize__vector.html#aab16e3784537297462c4e035fc48aa96">00127</a> <span class="keyword">inline</span> <a class="code" href="structmrpt_1_1dynamicsize__vector.html#aab16e3784537297462c4e035fc48aa96" title="Constructor, initializes to a given initial size, all elements to a given value.">dynamicsize_vector</a>(<span class="keywordtype">size_t</span> N, T init_val) : <a class="code" href="structmrpt_1_1dynamicsize__vector.html#aeff1d743897d0e82cf534b3d32c97744">Base</a>(N,1) { Base::derived().assign(init_val); }<span class="comment"></span> <a name="l00128"></a>00128 <span class="comment"> /** Constructor, initializes from a std::vector<> of scalars */</span> <a name="l00129"></a>00129 <span class="keyword">template</span> <<span class="keyword">typename</span> R> <a name="l00130"></a><a class="code" href="structmrpt_1_1dynamicsize__vector.html#a18849d5b374c8a1eedaa68a109cc0ed9">00130</a> <span class="keyword">inline</span> <a class="code" href="structmrpt_1_1dynamicsize__vector.html#a18849d5b374c8a1eedaa68a109cc0ed9" title="Constructor, initializes from a std::vector&lt;&gt; of scalars.">dynamicsize_vector</a>(<span class="keyword">const</span> std::vector<R>& v) : <a class="code" href="structmrpt_1_1dynamicsize__vector.html#aeff1d743897d0e82cf534b3d32c97744">Base</a>(v.<a class="code" href="namespacemrpt_1_1math.html#a34f37758cc35f29279a8e6ad91215ad1">size</a>(),1) { <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i=0;i<v.size();i++) (*<span class="keyword">this</span>)[i]=v[i]; }<span class="comment"></span> <a name="l00131"></a>00131 <span class="comment"> /** Overloaded resize method that mimics std::vector::resize(SIZE,DEFAULT_VALUE) instead of resize(nrows,ncols) \note This method exists for backward compatibility in MRPT */</span> <a name="l00132"></a><a class="code" href="structmrpt_1_1dynamicsize__vector.html#addd63fe911fadd077f1f2bccdfe6675b">00132</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="structmrpt_1_1dynamicsize__vector.html#addd63fe911fadd077f1f2bccdfe6675b" title="Overloaded resize method that mimics std::vector::resize(SIZE,DEFAULT_VALUE) instead of resize(nrows...">resize</a>(<span class="keyword">const</span> <span class="keywordtype">size_t</span> N, <span class="keyword">const</span> T default_val) { Base::derived().resize(N,1); Base::derived().setConstant(default_val); }<span class="comment"></span> <a name="l00133"></a>00133 <span class="comment"> /** Normal resize of the vector (preserving old contents). */</span> <a name="l00134"></a><a class="code" href="structmrpt_1_1dynamicsize__vector.html#ab603bea969a4d1fcb4e96696bcbbcdd5">00134</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="structmrpt_1_1dynamicsize__vector.html#ab603bea969a4d1fcb4e96696bcbbcdd5" title="Normal resize of the vector (preserving old contents).">resize</a>(<span class="keyword">const</span> <span class="keywordtype">size_t</span> N) { Base::derived().conservativeResize(N); }<span class="comment"></span> <a name="l00135"></a>00135 <span class="comment"> /** Reset the vector to a 0-length */</span> <a name="l00136"></a><a class="code" href="structmrpt_1_1dynamicsize__vector.html#ae4a027b1d6aa2cb04a217be9c5cf7f6a">00136</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="structmrpt_1_1dynamicsize__vector.html#ae4a027b1d6aa2cb04a217be9c5cf7f6a" title="Reset the vector to a 0-length.">clear</a>() { *<span class="keyword">this</span> = <a class="code" href="structmrpt_1_1dynamicsize__vector.html" title="The base class of MRPT vectors, actually, Eigen column matrices of dynamic size with specialized cons...">dynamicsize_vector<T></a>(); }<span class="comment"></span> <a name="l00137"></a>00137 <span class="comment"> /** DOES NOTHING (it's here for backward compatibility) */</span> <a name="l00138"></a><a class="code" href="structmrpt_1_1dynamicsize__vector.html#a4bc5f7f59a16e3eefefcab02e439a94b">00138</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="structmrpt_1_1dynamicsize__vector.html#a4bc5f7f59a16e3eefefcab02e439a94b" title="DOES NOTHING (it&#39;s here for backward compatibility)">reserve</a>(<span class="keywordtype">size_t</span> dummy_size) { } <a name="l00139"></a>00139 }; <a name="l00140"></a>00140 <a name="l00141"></a><a class="code" href="namespacemrpt.html#aa271572e3985202e030758bfd54a02e1">00141</a> <span class="keyword">typedef</span> <a class="code" href="structmrpt_1_1dynamicsize__vector.html">dynamicsize_vector<float></a> <a class="code" href="namespacemrpt.html#aa271572e3985202e030758bfd54a02e1">vector_float</a>; <a name="l00142"></a><a class="code" href="namespacemrpt.html#a4a6aab2c98368ca6b554c04f8fe84cfb">00142</a> <span class="keyword">typedef</span> <a class="code" href="structmrpt_1_1dynamicsize__vector.html">dynamicsize_vector<double></a> <a class="code" href="namespacemrpt.html#a4a6aab2c98368ca6b554c04f8fe84cfb">vector_double</a>; <a name="l00143"></a>00143 <a name="l00144"></a><a class="code" href="namespacemrpt.html#ad0fd30f28659350aa6ed37b31152e6c4">00144</a> <span class="keyword">typedef</span> std::vector<int8_t> <a class="code" href="namespacemrpt.html#ad0fd30f28659350aa6ed37b31152e6c4">vector_signed_byte</a>; <a name="l00145"></a><a class="code" href="namespacemrpt.html#a23dec6de1d390f62796a046bf60dd8c3">00145</a> <span class="keyword">typedef</span> std::vector<int16_t> <a class="code" href="namespacemrpt.html#a23dec6de1d390f62796a046bf60dd8c3">vector_signed_word</a>; <a name="l00146"></a><a class="code" href="namespacemrpt.html#ac2e04951e7bd82f53b6ecaa0fd8a2662">00146</a> <span class="keyword">typedef</span> std::vector<int32_t> <a class="code" href="namespacemrpt.html#ac2e04951e7bd82f53b6ecaa0fd8a2662">vector_int</a>; <a name="l00147"></a><a class="code" href="namespacemrpt.html#a6b02ea04c95f3f6a5c4b267da99d93ca">00147</a> <span class="keyword">typedef</span> std::vector<int64_t> <a class="code" href="namespacemrpt.html#a6b02ea04c95f3f6a5c4b267da99d93ca">vector_long</a>; <a name="l00148"></a><a class="code" href="namespacemrpt.html#ad4d2b1efd37ed750302c76ebbcfc310d">00148</a> <span class="keyword">typedef</span> std::vector<size_t> <a class="code" href="namespacemrpt.html#ad4d2b1efd37ed750302c76ebbcfc310d">vector_size_t</a>; <a name="l00149"></a><a class="code" href="namespacemrpt.html#a3250fe562baad62b3da2e166eb8867df">00149</a> <span class="keyword">typedef</span> std::vector<uint8_t> <a class="code" href="namespacemrpt.html#a3250fe562baad62b3da2e166eb8867df">vector_byte</a>; <a name="l00150"></a><a class="code" href="namespacemrpt.html#a47c2035f9c7d1897b91f97ab90290725">00150</a> <span class="keyword">typedef</span> std::vector<uint16_t> <a class="code" href="namespacemrpt.html#a47c2035f9c7d1897b91f97ab90290725">vector_word</a>; <a name="l00151"></a><a class="code" href="namespacemrpt.html#aa4dc027dbc3804c847a78892a2982047">00151</a> <span class="keyword">typedef</span> std::vector<uint32_t> <a class="code" href="namespacemrpt.html#aa4dc027dbc3804c847a78892a2982047">vector_uint</a>; <a name="l00152"></a><a class="code" href="namespacemrpt.html#a9fdb3cc3f73c5190fa022f858efbe6b1">00152</a> <span class="keyword">typedef</span> std::vector<bool> <a class="code" href="namespacemrpt.html#a9fdb3cc3f73c5190fa022f858efbe6b1" title="A type for passing a vector of bools.">vector_bool</a>; <span class="comment">//!< A type for passing a vector of bools.</span> <a name="l00153"></a><a class="code" href="namespacemrpt.html#a4d04fc5241bf87fcaffec90f3b23b1ea">00153</a> <span class="comment"></span> <span class="keyword">typedef</span> std::vector<std::string> <a class="code" href="namespacemrpt.html#a4d04fc5241bf87fcaffec90f3b23b1ea" title="A type for passing a vector of strings.">vector_string</a>; <span class="comment">//!< A type for passing a vector of strings.</span> <a name="l00154"></a>00154 <span class="comment"></span><span class="comment"></span> <a name="l00155"></a>00155 <span class="comment"> /** Helper types for STL containers with Eigen memory allocators. */</span> <a name="l00156"></a>00156 <span class="keyword">template</span> <<span class="keyword">class</span> TYPE1,<span class="keyword">class</span> TYPE2=TYPE1> <a name="l00157"></a><a class="code" href="structmrpt_1_1aligned__containers.html">00157</a> <span class="keyword">struct </span><a class="code" href="structmrpt_1_1aligned__containers.html" title="Helper types for STL containers with Eigen memory allocators.">aligned_containers</a> <a name="l00158"></a>00158 { <a name="l00159"></a><a class="code" href="structmrpt_1_1aligned__containers.html#aac68866c13daa914537f89e813ffb990">00159</a> <span class="keyword">typedef</span> std::pair<TYPE1,TYPE2> <a class="code" href="structmrpt_1_1aligned__containers.html#aac68866c13daa914537f89e813ffb990">pair_t</a>; <a name="l00160"></a><a class="code" href="structmrpt_1_1aligned__containers.html#a85594e0b9e8a9bf5c623a19b4a971e91">00160</a> <span class="keyword">typedef</span> std::vector<TYPE1, Eigen::aligned_allocator<TYPE1> > <a class="code" href="structmrpt_1_1aligned__containers.html#a85594e0b9e8a9bf5c623a19b4a971e91">vector_t</a>; <a name="l00161"></a><a class="code" href="structmrpt_1_1aligned__containers.html#af7a0bac8608c911b99053d8213110ba3">00161</a> <span class="keyword">typedef</span> std::deque<TYPE1, Eigen::aligned_allocator<TYPE1> > <a class="code" href="structmrpt_1_1aligned__containers.html#af7a0bac8608c911b99053d8213110ba3">deque_t</a>; <a name="l00162"></a><a class="code" href="structmrpt_1_1aligned__containers.html#a03873872579975d7d198d5dae86a064f">00162</a> <span class="keyword">typedef</span> std::map<TYPE1,TYPE2,std::less<TYPE1>,Eigen::aligned_allocator<std::pair<const TYPE1,TYPE2> > > <a class="code" href="structmrpt_1_1aligned__containers.html#a03873872579975d7d198d5dae86a064f">map_t</a>; <a name="l00163"></a><a class="code" href="structmrpt_1_1aligned__containers.html#aa2f51997be30b0711fb512c8b5a179b1">00163</a> <span class="keyword">typedef</span> std::multimap<TYPE1,TYPE2,std::less<TYPE1>,Eigen::aligned_allocator<std::pair<const TYPE1,TYPE2> > > <a class="code" href="structmrpt_1_1aligned__containers.html#aa2f51997be30b0711fb512c8b5a179b1">multimap_t</a>; <a name="l00164"></a>00164 }; <a name="l00165"></a>00165 <a name="l00166"></a>00166 <span class="keyword">namespace </span>utils <a name="l00167"></a>00167 {<span class="comment"></span> <a name="l00168"></a>00168 <span class="comment"> /** For performing type casting from a pointer to its numeric value.</span> <a name="l00169"></a>00169 <span class="comment"> */</span> <a name="l00170"></a>00170 <span class="preprocessor"> #if defined(_MSC_VER) && (_MSC_VER>=1300)</span> <a name="l00171"></a>00171 <span class="preprocessor"></span> <span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> <a class="code" href="namespacemrpt_1_1utils.html#ab8c166dc1bc5fe5628d214754539bfb2" title="For performing type casting from a pointer to its numeric value.">POINTER_TYPE</a>; <a name="l00172"></a>00172 <span class="preprocessor"> #else</span> <a name="l00173"></a><a class="code" href="namespacemrpt_1_1utils.html#ab8c166dc1bc5fe5628d214754539bfb2">00173</a> <span class="preprocessor"></span> <span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="namespacemrpt_1_1utils.html#ab8c166dc1bc5fe5628d214754539bfb2" title="For performing type casting from a pointer to its numeric value.">POINTER_TYPE</a>; <a name="l00174"></a>00174 <span class="preprocessor"> #endif</span> <a name="l00175"></a>00175 <span class="preprocessor"></span><span class="comment"></span> <a name="l00176"></a>00176 <span class="comment"> /** A RGB color - 8bit */</span> <a name="l00177"></a><a class="code" href="structmrpt_1_1utils_1_1_t_color.html">00177</a> <span class="keyword">struct </span><a class="code" href="base_2include_2mrpt_2base_2link__pragmas_8h.html#a6045fa0129b1a3d6c8bf895470e66574">BASE_IMPEXP</a> <a class="code" href="structmrpt_1_1utils_1_1_t_color.html" title="A RGB color - 8bit.">TColor</a> <a name="l00178"></a>00178 { <a name="l00179"></a><a class="code" href="structmrpt_1_1utils_1_1_t_color.html#a7848db38e0d06ab2c60c65dd5e9c12ec">00179</a> <span class="keyword">inline</span> <a class="code" href="structmrpt_1_1utils_1_1_t_color.html#a7848db38e0d06ab2c60c65dd5e9c12ec">TColor</a>() : R(0),G(0),B(0),A(255) { } <a name="l00180"></a><a class="code" href="structmrpt_1_1utils_1_1_t_color.html#af5bdff62161a7ccfc5ecf71b6dd22e33">00180</a> <span class="keyword">inline</span> <a class="code" href="structmrpt_1_1utils_1_1_t_color.html#af5bdff62161a7ccfc5ecf71b6dd22e33">TColor</a>(uint8_t r,uint8_t g,uint8_t b, uint8_t alpha=255) : R(r),G(g),B(b),A(alpha) { } <a name="l00181"></a><a class="code" href="structmrpt_1_1utils_1_1_t_color.html#ac1499b2822a146a490a5cc526dc4fdb6">00181</a> <span class="keyword">inline</span> <span class="keyword">explicit</span> <a class="code" href="structmrpt_1_1utils_1_1_t_color.html#ac1499b2822a146a490a5cc526dc4fdb6">TColor</a>(<span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> color_RGB_24bit) : R(uint8_t(color_RGB_24bit>>16)),G(uint8_t(color_RGB_24bit>>8)),B(uint8_t(color_RGB_24bit)),A(255) { } <a name="l00182"></a><a class="code" href="structmrpt_1_1utils_1_1_t_color.html#a0f62f632e30adf825cecb3e65d719ca5">00182</a> uint8_t <a class="code" href="structmrpt_1_1utils_1_1_t_color.html#a0f62f632e30adf825cecb3e65d719ca5">R</a>,G,B,A;<span class="comment"></span> <a name="l00183"></a>00183 <span class="comment"> /** Operator for implicit conversion into an int binary representation 0xRRGGBB */</span> <a name="l00184"></a><a class="code" href="structmrpt_1_1utils_1_1_t_color.html#a9dfac91d02cc5f8f3381bb3ed2489f1a">00184</a> <span class="keyword">inline</span> <a class="code" href="structmrpt_1_1utils_1_1_t_color.html#a9dfac91d02cc5f8f3381bb3ed2489f1a" title="Operator for implicit conversion into an int binary representation 0xRRGGBB.">operator unsigned int</a>(<span class="keywordtype">void</span>)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> (((<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>)R)<<16) | (((<span class="keywordtype">unsigned</span> int)G)<<8) | B; } <a name="l00185"></a>00185 <a name="l00186"></a><a class="code" href="structmrpt_1_1utils_1_1_t_color.html#a889b647441f8534a0e205e387635e1c1">00186</a> <span class="keyword">static</span> <a class="code" href="structmrpt_1_1utils_1_1_t_color.html" title="A RGB color - 8bit.">TColor</a> <a class="code" href="structmrpt_1_1utils_1_1_t_color.html#a889b647441f8534a0e205e387635e1c1" title="Predefined colors.">red</a>; <span class="comment">//!< Predefined colors</span> <a name="l00187"></a><a class="code" href="structmrpt_1_1utils_1_1_t_color.html#a5bf90664d0b8252eb2538af5ef9c29c1">00187</a> <span class="comment"></span> <span class="keyword">static</span> <a class="code" href="structmrpt_1_1utils_1_1_t_color.html" title="A RGB color - 8bit.">TColor</a> <a class="code" href="structmrpt_1_1utils_1_1_t_color.html#a5bf90664d0b8252eb2538af5ef9c29c1" title="Predefined colors.">green</a>;<span class="comment">//!< Predefined colors</span> <a name="l00188"></a><a class="code" href="structmrpt_1_1utils_1_1_t_color.html#a18bc65f7262e4dc77569f502cd14260e">00188</a> <span class="comment"></span> <span class="keyword">static</span> <a class="code" href="structmrpt_1_1utils_1_1_t_color.html" title="A RGB color - 8bit.">TColor</a> <a class="code" href="structmrpt_1_1utils_1_1_t_color.html#a18bc65f7262e4dc77569f502cd14260e" title="Predefined colors.">blue</a>;<span class="comment">//!< Predefined colors</span> <a name="l00189"></a><a class="code" href="structmrpt_1_1utils_1_1_t_color.html#a027d442b5be142e286b30859b71188cd">00189</a> <span class="comment"></span> <span class="keyword">static</span> <a class="code" href="structmrpt_1_1utils_1_1_t_color.html" title="A RGB color - 8bit.">TColor</a> <a class="code" href="structmrpt_1_1utils_1_1_t_color.html#a027d442b5be142e286b30859b71188cd" title="Predefined colors.">white</a>;<span class="comment">//!< Predefined colors</span> <a name="l00190"></a><a class="code" href="structmrpt_1_1utils_1_1_t_color.html#ae112ea044360e8bbee5b2553a79240e8">00190</a> <span class="comment"></span> <span class="keyword">static</span> <a class="code" href="structmrpt_1_1utils_1_1_t_color.html" title="A RGB color - 8bit.">TColor</a> <a class="code" href="structmrpt_1_1utils_1_1_t_color.html#ae112ea044360e8bbee5b2553a79240e8" title="Predefined colors.">black</a>;<span class="comment">//!< Predefined colors</span> <a name="l00191"></a><a class="code" href="structmrpt_1_1utils_1_1_t_color.html#a3be8b8a51425783d005914b82b9f8891">00191</a> <span class="comment"></span> <span class="keyword">static</span> <a class="code" href="structmrpt_1_1utils_1_1_t_color.html" title="A RGB color - 8bit.">TColor</a> <a class="code" href="structmrpt_1_1utils_1_1_t_color.html#a3be8b8a51425783d005914b82b9f8891" title="Predefined colors.">gray</a>; <span class="comment">//!< Predefined colors</span> <a name="l00192"></a>00192 <span class="comment"></span> }; <a name="l00193"></a>00193 <span class="comment"></span> <a name="l00194"></a>00194 <span class="comment"> /** A RGB color - floats in the range [0,1] */</span> <a name="l00195"></a><a class="code" href="structmrpt_1_1utils_1_1_t_colorf.html">00195</a> <span class="keyword">struct </span><a class="code" href="base_2include_2mrpt_2base_2link__pragmas_8h.html#a6045fa0129b1a3d6c8bf895470e66574">BASE_IMPEXP</a> <a class="code" href="structmrpt_1_1utils_1_1_t_colorf.html" title="A RGB color - floats in the range [0,1].">TColorf</a> <a name="l00196"></a>00196 { <a name="l00197"></a><a class="code" href="structmrpt_1_1utils_1_1_t_colorf.html#af16218bd2db97e01bb64e05c2a0ec616">00197</a> <a class="code" href="structmrpt_1_1utils_1_1_t_colorf.html#af16218bd2db97e01bb64e05c2a0ec616">TColorf</a>(<span class="keywordtype">float</span> r=0,<span class="keywordtype">float</span> g=0,<span class="keywordtype">float</span> b=0, <span class="keywordtype">float</span> alpha=1.0f) : R(r),G(g),B(b),A(alpha) { } <a name="l00198"></a><a class="code" href="structmrpt_1_1utils_1_1_t_colorf.html#ab97d3dfc6bf44d8336011f3e2684289b">00198</a> <span class="keyword">explicit</span> <a class="code" href="structmrpt_1_1utils_1_1_t_colorf.html#ab97d3dfc6bf44d8336011f3e2684289b">TColorf</a>(<span class="keyword">const</span> <a class="code" href="structmrpt_1_1utils_1_1_t_color.html" title="A RGB color - 8bit.">TColor</a> &<a class="code" href="_block_methods_8h.html#a390f7c534678354959dd587080b82c2c" title="This is the const version of col().">col</a>) : R(col.R*(1.f/255)),G(col.G*(1.f/255)),B(col.B*(1.f/255)),A(col.A*(1.f/255)) { } <a name="l00199"></a><a class="code" href="structmrpt_1_1utils_1_1_t_colorf.html#ac1941d15140c3f22cced86c45050aaef">00199</a> <span class="keywordtype">float</span> <a class="code" href="structmrpt_1_1utils_1_1_t_colorf.html#ac1941d15140c3f22cced86c45050aaef">R</a>,G,B,A; <a name="l00200"></a>00200 }; <a name="l00201"></a>00201 <span class="comment"></span> <a name="l00202"></a>00202 <span class="comment"> /** A pair (x,y) of pixel coordinates (subpixel resolution). */</span> <a name="l00203"></a><a class="code" href="structmrpt_1_1utils_1_1_t_pixel_coordf.html">00203</a> <span class="keyword">struct </span><a class="code" href="base_2include_2mrpt_2base_2link__pragmas_8h.html#a6045fa0129b1a3d6c8bf895470e66574">BASE_IMPEXP</a> <a class="code" href="structmrpt_1_1utils_1_1_t_pixel_coordf.html" title="A pair (x,y) of pixel coordinates (subpixel resolution).">TPixelCoordf</a> <a name="l00204"></a>00204 { <a name="l00205"></a><a class="code" href="structmrpt_1_1utils_1_1_t_pixel_coordf.html#ae09752b582b6f945ae42ce0879e83f95">00205</a> <span class="keywordtype">float</span> x,<a class="code" href="structmrpt_1_1utils_1_1_t_pixel_coordf.html#ae09752b582b6f945ae42ce0879e83f95">y</a>; <a name="l00206"></a>00206 <span class="comment"></span> <a name="l00207"></a>00207 <span class="comment"> /** Default constructor: undefined values of x,y */</span> <a name="l00208"></a><a class="code" href="structmrpt_1_1utils_1_1_t_pixel_coordf.html#abc2c3289e04a092fc4b2b81be55a58a0">00208</a> <a class="code" href="structmrpt_1_1utils_1_1_t_pixel_coordf.html#abc2c3289e04a092fc4b2b81be55a58a0" title="Default constructor: undefined values of x,y.">TPixelCoordf</a>() : x(),<a class="code" href="namespaceinternal.html#a170c9f639220e3eb414362c243c80dee">y</a>() {} <a name="l00209"></a>00209 <span class="comment"></span> <a name="l00210"></a>00210 <span class="comment"> /** Constructor from x,y values */</span> <a name="l00211"></a><a class="code" href="structmrpt_1_1utils_1_1_t_pixel_coordf.html#a876dbc2341b346870746c390a532d21d">00211</a> <a class="code" href="structmrpt_1_1utils_1_1_t_pixel_coordf.html#a876dbc2341b346870746c390a532d21d" title="Constructor from x,y values.">TPixelCoordf</a>(<span class="keyword">const</span> <span class="keywordtype">float</span> _x,<span class="keyword">const</span> <span class="keywordtype">float</span> _y) : x(_x), <a class="code" href="namespaceinternal.html#a170c9f639220e3eb414362c243c80dee">y</a>(_y) { } <a name="l00212"></a>00212 }; <a name="l00213"></a>00213 <a name="l00214"></a>00214 std::ostream <a class="code" href="base_2include_2mrpt_2base_2link__pragmas_8h.html#a6045fa0129b1a3d6c8bf895470e66574">BASE_IMPEXP</a> & <a class="code" href="namespacemrpt_1_1utils.html#a236712f6f41bb81ba414c4b7dd94f5a3">operator <<</a>(std::ostream& o, <span class="keyword">const</span> TPixelCoordf& p); <span class="comment">//!< Prints TPixelCoordf as "(x,y)"</span> <a name="l00215"></a>00215 <span class="comment"></span><span class="comment"></span> <a name="l00216"></a>00216 <span class="comment"> /** A pair (x,y) of pixel coordinates (integer resolution). */</span> <a name="l00217"></a><a class="code" href="structmrpt_1_1utils_1_1_t_pixel_coord.html">00217</a> <span class="keyword">struct </span><a class="code" href="base_2include_2mrpt_2base_2link__pragmas_8h.html#a6045fa0129b1a3d6c8bf895470e66574">BASE_IMPEXP</a> <a class="code" href="structmrpt_1_1utils_1_1_t_pixel_coord.html" title="A pair (x,y) of pixel coordinates (integer resolution).">TPixelCoord</a> <a name="l00218"></a>00218 { <a name="l00219"></a><a class="code" href="structmrpt_1_1utils_1_1_t_pixel_coord.html#ac6825b256c361b527944c1b365dc5df3">00219</a> <a class="code" href="structmrpt_1_1utils_1_1_t_pixel_coord.html#ac6825b256c361b527944c1b365dc5df3">TPixelCoord</a>() : x(0),<a class="code" href="namespaceinternal.html#a170c9f639220e3eb414362c243c80dee">y</a>(0) { } <a name="l00220"></a><a class="code" href="structmrpt_1_1utils_1_1_t_pixel_coord.html#a4f1ef37dc664b644ad3370f38b0acb59">00220</a> <a class="code" href="structmrpt_1_1utils_1_1_t_pixel_coord.html#a4f1ef37dc664b644ad3370f38b0acb59">TPixelCoord</a>(<span class="keyword">const</span> <span class="keywordtype">int</span> _x,<span class="keyword">const</span> <span class="keywordtype">int</span> _y) : x(_x), <a class="code" href="namespaceinternal.html#a170c9f639220e3eb414362c243c80dee">y</a>(_y) { } <a name="l00221"></a>00221 <a name="l00222"></a><a class="code" href="structmrpt_1_1utils_1_1_t_pixel_coord.html#a0e55a012bd260a878fdb5eaa2f874f8a">00222</a> <span class="keywordtype">int</span> x,<a class="code" href="structmrpt_1_1utils_1_1_t_pixel_coord.html#a0e55a012bd260a878fdb5eaa2f874f8a">y</a>; <a name="l00223"></a>00223 }; <a name="l00224"></a>00224 <a name="l00225"></a>00225 std::ostream <a class="code" href="base_2include_2mrpt_2base_2link__pragmas_8h.html#a6045fa0129b1a3d6c8bf895470e66574">BASE_IMPEXP</a> & <a class="code" href="namespacemrpt_1_1utils.html#a236712f6f41bb81ba414c4b7dd94f5a3">operator <<</a>(std::ostream& o, <span class="keyword">const</span> <a class="code" href="structmrpt_1_1utils_1_1_t_pixel_coord.html" title="A pair (x,y) of pixel coordinates (integer resolution).">TPixelCoord</a>& p); <span class="comment">//!< Prints TPixelCoord as "(x,y)"</span> <a name="l00226"></a>00226 <span class="comment"></span> <a name="l00227"></a><a class="code" href="namespacemrpt_1_1utils.html#aad714637162eda7b78d3d4c520e9a379">00227</a> <span class="keyword">typedef</span> <a class="code" href="structmrpt_1_1utils_1_1_t_pixel_coord.html" title="A pair (x,y) of pixel coordinates (integer resolution).">TPixelCoord</a> <a class="code" href="namespacemrpt_1_1utils.html#aad714637162eda7b78d3d4c520e9a379" title="A type for image sizes.">TImageSize</a>; <span class="comment">//!< A type for image sizes.</span> <a name="l00228"></a>00228 <span class="comment"></span><span class="comment"></span> <a name="l00229"></a>00229 <span class="comment"> /** For usage when passing a dynamic number of (numeric) arguments to a function, by name.</span> <a name="l00230"></a>00230 <span class="comment"> * \code</span> <a name="l00231"></a>00231 <span class="comment"> * TParameters<double> p; // or TParametersDouble</span> <a name="l00232"></a>00232 <span class="comment"> * p["v_max"] = 1.0; // Write</span> <a name="l00233"></a>00233 <span class="comment"> * ...</span> <a name="l00234"></a>00234 <span class="comment"> * cout << p["w_max"]; // Read, even if "p" was const.</span> <a name="l00235"></a>00235 <span class="comment"> * \endcode</span> <a name="l00236"></a>00236 <span class="comment"> *</span> <a name="l00237"></a>00237 <span class="comment"> * A default list of parameters can be passed to the constructor as a sequence</span> <a name="l00238"></a>00238 <span class="comment"> * of pairs "name, value", which MUST end in a NULL name string. Names MUST BE "const char*"</span> <a name="l00239"></a>00239 <span class="comment"> * (that is, "old plain strings" are OK), not std::string objects!.</span> <a name="l00240"></a>00240 <span class="comment"> * See this example:</span> <a name="l00241"></a>00241 <span class="comment"> *</span> <a name="l00242"></a>00242 <span class="comment"> * \code</span> <a name="l00243"></a>00243 <span class="comment"> * TParameters<double> p("par1",2.0, "par2",-4.5, "par3",9.0, NULL); // MUST end with a NULL</span> <a name="l00244"></a>00244 <span class="comment"> * \endcode</span> <a name="l00245"></a>00245 <span class="comment"> *</span> <a name="l00246"></a>00246 <span class="comment"> * <b>VERY IMPORTANT:</b> If you use the NULL-ended constructor above, make sure all the values are of the proper</span> <a name="l00247"></a>00247 <span class="comment"> * type or it will crash in runtime. For example, in a TParametersDouble all values must be double's, so</span> <a name="l00248"></a>00248 <span class="comment"> * if you type "10" the compiler will make it an "int". Instead, write "10.0".</span> <a name="l00249"></a>00249 <span class="comment"> *</span> <a name="l00250"></a>00250 <span class="comment"> * \sa the example in MRPT/samples/params-by-name</span> <a name="l00251"></a>00251 <span class="comment"> */</span> <a name="l00252"></a>00252 <span class="keyword">template</span> <<span class="keyword">typename</span> T> <a name="l00253"></a><a class="code" href="structmrpt_1_1utils_1_1_t_parameters.html">00253</a> <span class="keyword">struct </span><a class="code" href="structmrpt_1_1utils_1_1_t_parameters.html" title="For usage when passing a dynamic number of (numeric) arguments to a function, by name.">TParameters</a> : <span class="keyword">public</span> std::map<std::string,T> <a name="l00254"></a>00254 { <a name="l00255"></a><a class="code" href="structmrpt_1_1utils_1_1_t_parameters.html#ae77905fbdcd6b5bf62b4bfabc319bb85">00255</a> <span class="keyword">typedef</span> std::map<std::string,T> <a class="code" href="structmrpt_1_1utils_1_1_t_parameters.html#ae77905fbdcd6b5bf62b4bfabc319bb85">BASE</a>;<span class="comment"></span> <a name="l00256"></a>00256 <span class="comment"> /** Default constructor (initializes empty) */</span> <a name="l00257"></a><a class="code" href="structmrpt_1_1utils_1_1_t_parameters.html#a9cd19be3d507696e34d35556e6d462d2">00257</a> <a class="code" href="structmrpt_1_1utils_1_1_t_parameters.html#a9cd19be3d507696e34d35556e6d462d2" title="Default constructor (initializes empty)">TParameters</a>() : <a class="code" href="structmrpt_1_1utils_1_1_t_parameters.html#ae77905fbdcd6b5bf62b4bfabc319bb85">BASE</a>() { }<span class="comment"></span> <a name="l00258"></a>00258 <span class="comment"> /** Constructor with a list of initial values (see the description and use example in mrpt::utils::TParameters) */</span> <a name="l00259"></a><a class="code" href="structmrpt_1_1utils_1_1_t_parameters.html#a4911b1d91300dae22615bca052ed86d9">00259</a> <a class="code" href="structmrpt_1_1utils_1_1_t_parameters.html#a4911b1d91300dae22615bca052ed86d9" title="Constructor with a list of initial values (see the description and use example in mrpt::utils::TParam...">TParameters</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *nam1,...) : <a class="code" href="structmrpt_1_1utils_1_1_t_parameters.html#ae77905fbdcd6b5bf62b4bfabc319bb85">BASE</a>() { <a name="l00260"></a>00260 <span class="keywordflow">if</span> (!nam1) <span class="keywordflow">return</span>; <span class="comment">// No parameters</span> <a name="l00261"></a>00261 T val; <a name="l00262"></a>00262 va_list args; <a name="l00263"></a>00263 va_start(args,nam1); <a name="l00264"></a>00264 <span class="comment">// 1st one out of the loop:</span> <a name="l00265"></a>00265 val = va_arg(args,T); <a name="l00266"></a>00266 <a class="code" href="structmrpt_1_1utils_1_1_t_parameters.html#ad43e05e78a1681e015c406aadd8ed42e" title="A const version of the [] operator, for usage as read-only.">BASE::operator[]</a>(std::string(nam1)) = val; <a name="l00267"></a>00267 <span class="comment">// Loop until NULL:</span> <a name="l00268"></a>00268 <span class="keyword">const</span> <span class="keywordtype">char</span> *nam; <a name="l00269"></a>00269 <span class="keywordflow">do</span>{ <a name="l00270"></a>00270 nam = va_arg(args,<span class="keyword">const</span> <span class="keywordtype">char</span>*); <a name="l00271"></a>00271 <span class="keywordflow">if</span> (nam) { <a name="l00272"></a>00272 val = va_arg(args,T); <a name="l00273"></a>00273 <a class="code" href="structmrpt_1_1utils_1_1_t_parameters.html#ad43e05e78a1681e015c406aadd8ed42e" title="A const version of the [] operator, for usage as read-only.">BASE::operator[]</a>(std::string(nam)) = val; <a name="l00274"></a>00274 } <a name="l00275"></a>00275 } <span class="keywordflow">while</span> (nam); <a name="l00276"></a>00276 va_end(args); <a name="l00277"></a>00277 } <a name="l00278"></a><a class="code" href="structmrpt_1_1utils_1_1_t_parameters.html#a6d634b49588f355e24522bf9669f93e9">00278</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="structmrpt_1_1utils_1_1_t_parameters.html#a6d634b49588f355e24522bf9669f93e9">has</a>(<span class="keyword">const</span> std::string &s)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="eigen__plugins_8h.html#ade5b39864c905cbb824d0ff6eb0d888c">std::map<std::string,T>::end</a>()!=BASE::find(s); }<span class="comment"></span> <a name="l00279"></a>00279 <span class="comment"> /** A const version of the [] operator, for usage as read-only.</span> <a name="l00280"></a>00280 <span class="comment"> * \exception std::logic_error On parameter not present. Please, check existence with "has" before reading.</span> <a name="l00281"></a>00281 <span class="comment"> */</span> <a name="l00282"></a><a class="code" href="structmrpt_1_1utils_1_1_t_parameters.html#ad43e05e78a1681e015c406aadd8ed42e">00282</a> <span class="keyword">inline</span> T <a class="code" href="structmrpt_1_1utils_1_1_t_parameters.html#ad43e05e78a1681e015c406aadd8ed42e" title="A const version of the [] operator, for usage as read-only.">operator[]</a>(<span class="keyword">const</span> std::string &s)<span class="keyword"> const </span>{ <a name="l00283"></a>00283 <span class="keyword">typename</span> <a class="code" href="eigen__plugins_8h.html#a8dbda719917732693c56cee228465ed9">BASE::const_iterator</a> it =BASE::find(s); <a name="l00284"></a>00284 <span class="keywordflow">if</span> (<a class="code" href="eigen__plugins_8h.html#ade5b39864c905cbb824d0ff6eb0d888c">BASE::end</a>()==it) <a name="l00285"></a>00285 <span class="keywordflow">throw</span> std::logic_error(std::string(<span class="stringliteral">"Parameter '"</span>)+s+std::string(<span class="stringliteral">"' is not present."</span>).c_str()); <a name="l00286"></a>00286 <span class="keywordflow">return</span> it->second; <a name="l00287"></a>00287 }<span class="comment"></span> <a name="l00288"></a>00288 <span class="comment"> /** A const version of the [] operator and with a default value in case the parameter is not set (for usage as read-only).</span> <a name="l00289"></a>00289 <span class="comment"> */</span> <a name="l00290"></a><a class="code" href="structmrpt_1_1utils_1_1_t_parameters.html#a93b22927356ec54f6ccaedb6909eaf8d">00290</a> <span class="keyword">inline</span> T <a class="code" href="structmrpt_1_1utils_1_1_t_parameters.html#a93b22927356ec54f6ccaedb6909eaf8d" title="A const version of the [] operator and with a default value in case the parameter is not set (for usa...">getWithDefaultVal</a>(<span class="keyword">const</span> std::string &s, <span class="keyword">const</span> T& defaultVal)<span class="keyword"> const </span>{ <a name="l00291"></a>00291 <span class="keyword">typename</span> <a class="code" href="eigen__plugins_8h.html#a8dbda719917732693c56cee228465ed9">BASE::const_iterator</a> it =BASE::find(s); <a name="l00292"></a>00292 <span class="keywordflow">if</span> (<a class="code" href="eigen__plugins_8h.html#ade5b39864c905cbb824d0ff6eb0d888c">BASE::end</a>()==it) <a name="l00293"></a>00293 <span class="keywordflow">return</span> defaultVal; <a name="l00294"></a>00294 <span class="keywordflow">else</span> <span class="keywordflow">return</span> it->second; <a name="l00295"></a>00295 }<span class="comment"></span> <a name="l00296"></a>00296 <span class="comment"> /** The write (non-const) version of the [] operator. */</span> <a name="l00297"></a><a class="code" href="structmrpt_1_1utils_1_1_t_parameters.html#a0007ae3f555fa37d9aca4d3af0144480">00297</a> <span class="keyword">inline</span> T & <a class="code" href="structmrpt_1_1utils_1_1_t_parameters.html#a0007ae3f555fa37d9aca4d3af0144480" title="The write (non-const) version of the [] operator.">operator[]</a>(<span class="keyword">const</span> std::string &s) { <span class="keywordflow">return</span> <a class="code" href="structmrpt_1_1utils_1_1_t_parameters.html#ad43e05e78a1681e015c406aadd8ed42e" title="A const version of the [] operator, for usage as read-only.">BASE::operator[]</a>(s); } <a name="l00298"></a>00298 <span class="comment"></span> <a name="l00299"></a>00299 <span class="comment"> /** Dumps to console the output from getAsString() */</span> <a name="l00300"></a><a class="code" href="structmrpt_1_1utils_1_1_t_parameters.html#a25a262998ec394dfa111a35da9c70f4a">00300</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="structmrpt_1_1utils_1_1_t_parameters.html#a25a262998ec394dfa111a35da9c70f4a" title="Dumps to console the output from getAsString()">dumpToConsole</a>()<span class="keyword"> const </span>{ std::cout << <a class="code" href="structmrpt_1_1utils_1_1_t_parameters.html#aafe96ab36981b5e69f1099bba49ff4a5" title="Returns a multi-like string representation of the parameters like : &#39;nam = val = val2...">getAsString</a>(); } <a name="l00301"></a>00301 <span class="comment"></span> <a name="l00302"></a>00302 <span class="comment"> /** Returns a multi-like string representation of the parameters like : 'nam = val\nnam2 = val2...' */</span> <a name="l00303"></a><a class="code" href="structmrpt_1_1utils_1_1_t_parameters.html#aafe96ab36981b5e69f1099bba49ff4a5">00303</a> <span class="keyword">inline</span> std::string <a class="code" href="structmrpt_1_1utils_1_1_t_parameters.html#aafe96ab36981b5e69f1099bba49ff4a5" title="Returns a multi-like string representation of the parameters like : &#39;nam = val = val2...">getAsString</a>()<span class="keyword"> const </span>{ std::string s; <a class="code" href="structmrpt_1_1utils_1_1_t_parameters.html#aafe96ab36981b5e69f1099bba49ff4a5" title="Returns a multi-like string representation of the parameters like : &#39;nam = val = val2...">getAsString</a>(s); <span class="keywordflow">return</span> s; } <a name="l00304"></a>00304 <span class="comment"></span> <a name="l00305"></a>00305 <span class="comment"> /** Returns a multi-like string representation of the parameters like : 'nam = val\nnam2 = val2...' */</span> <a name="l00306"></a><a class="code" href="structmrpt_1_1utils_1_1_t_parameters.html#ae219a349a51992cde5c88bc1b29f8b37">00306</a> <span class="keywordtype">void</span> <a class="code" href="structmrpt_1_1utils_1_1_t_parameters.html#ae219a349a51992cde5c88bc1b29f8b37" title="Returns a multi-like string representation of the parameters like : &#39;nam = val = val2...">getAsString</a>(std::string &s)<span class="keyword"> const </span>{ <a name="l00307"></a>00307 <span class="keywordtype">size_t</span> maxStrLen = 10; <a name="l00308"></a>00308 <span class="keywordflow">for</span> (<span class="keyword">typename</span> <a class="code" href="eigen__plugins_8h.html#a8dbda719917732693c56cee228465ed9">BASE::const_iterator</a> it=<a class="code" href="eigen__plugins_8h.html#ab295fd8164bf1b1acecbcb29520d62b7">BASE::begin</a>();it!=<a class="code" href="eigen__plugins_8h.html#ade5b39864c905cbb824d0ff6eb0d888c">BASE::end</a>();++it) maxStrLen = std::max(maxStrLen, it->first.size() ); <a name="l00309"></a>00309 maxStrLen++; <a name="l00310"></a>00310 std::stringstream str; <a name="l00311"></a>00311 <span class="keywordflow">for</span> (<span class="keyword">typename</span> <a class="code" href="eigen__plugins_8h.html#a8dbda719917732693c56cee228465ed9">BASE::const_iterator</a> it=<a class="code" href="eigen__plugins_8h.html#ab295fd8164bf1b1acecbcb29520d62b7">BASE::begin</a>();it!=<a class="code" href="eigen__plugins_8h.html#ade5b39864c905cbb824d0ff6eb0d888c">BASE::end</a>();++it) <a name="l00312"></a>00312 str << it->first << std::string(maxStrLen-it->first.size(),<span class="charliteral">' '</span>) << <span class="stringliteral">" = "</span> << it->second << std::endl; <a name="l00313"></a>00313 s = str.str(); <a name="l00314"></a>00314 } <a name="l00315"></a>00315 }; <a name="l00316"></a>00316 <a name="l00317"></a><a class="code" href="namespacemrpt_1_1utils.html#a694777f2a3544999baea34e43a42eceb">00317</a> <span class="keyword">typedef</span> <a class="code" href="structmrpt_1_1utils_1_1_t_parameters.html">TParameters<double></a> <a class="code" href="namespacemrpt_1_1utils.html#a694777f2a3544999baea34e43a42eceb" title="See the generic template mrpt::utils::TParameters.">TParametersDouble</a>; <span class="comment">//!< See the generic template mrpt::utils::TParameters</span> <a name="l00318"></a><a class="code" href="namespacemrpt_1_1utils.html#a53d400cb84997624634d404ca456cdb9">00318</a> <span class="comment"></span> <span class="keyword">typedef</span> <a class="code" href="structmrpt_1_1utils_1_1_t_parameters.html" title="For usage when passing a dynamic number of (numeric) arguments to a function, by name.">TParameters<std::string></a> <a class="code" href="namespacemrpt_1_1utils.html#a53d400cb84997624634d404ca456cdb9" title="See the generic template mrpt::utils::TParameters.">TParametersString</a>; <span class="comment">//!< See the generic template mrpt::utils::TParameters</span> <a name="l00319"></a>00319 <span class="comment"></span> <a name="l00320"></a><a class="code" href="namespacemrpt_1_1utils.html#a718b4f99645b7e9f6501c9b7bb2a2fe7">00320</a> <span class="keyword">typedef</span> uint64_t <a class="code" href="namespacemrpt_1_1utils.html#a718b4f99645b7e9f6501c9b7bb2a2fe7" title="The type for node IDs in graphs of different types.">TNodeID</a>; <span class="comment">//!< The type for node IDs in graphs of different types.</span> <a name="l00321"></a><a class="code" href="namespacemrpt_1_1utils.html#aee71d7beb4d61406566af3847410d0e4">00321</a> <span class="comment"></span> <span class="keyword">typedef</span> std::pair<TNodeID,TNodeID> <a class="code" href="namespacemrpt_1_1utils.html#aee71d7beb4d61406566af3847410d0e4" title="A pair of node IDs.">TPairNodeIDs</a>; <span class="comment">//!< A pair of node IDs.</span> <a name="l00322"></a><a class="code" href="base_2include_2mrpt_2utils_2types_8h.html#adc1f75e937273167bcd0a11caf344fce">00322</a> <span class="comment"></span><span class="preprocessor"> #define INVALID_NODEID static_cast<TNodeID>(-1)</span> <a name="l00323"></a>00323 <span class="preprocessor"></span> <a name="l00324"></a>00324 } <span class="comment">// end namespace</span> <a name="l00325"></a>00325 } <a name="l00326"></a>00326 <a name="l00327"></a>00327 <span class="preprocessor">#endif</span> <a name="l00328"></a>00328 <span class="preprocessor"></span> </pre></div></div> </div> <br><hr><br> <table border="0" width="100%"> <tr> <td> Page generated by <a href="http://www.doxygen.org" target="_blank">Doxygen 1.7.2</a> for MRPT 0.9.4 SVN: at Mon Jan 10 22:30:30 UTC 2011</td><td></td> <td width="100"> </td> <td width="150"> </td></tr> </table> </body></html>