Sophie

Sophie

distrib > Fedora > 16 > i386 > by-pkgid > 4bc66056a634db26a1f4d0845dc41ca6 > files > 920

mrpt-doc-0.9.5-0.1.20110925svn2670.fc16.i686.rpm

<!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>CMHPropertiesValuesList.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> &gt; <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.5 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;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>
        <div id="MSearchBox" class="MSearchBoxInactive">
          <div 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>
          </div><div class="right"></div>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">CMHPropertiesValuesList.h</div>  </div>
</div>
<div class="contents">
<a href="_c_m_h_properties_values_list_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://www.mrpt.org/                                |</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  &lt;jlblanco@ctima.uma.es&gt;                     |</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 &lt;http://www.gnu.org/licenses/&gt;.         |</span>
<a name="l00026"></a>00026 <span class="comment">   |                                                                           |</span>
<a name="l00027"></a>00027 <span class="comment">   +---------------------------------------------------------------------------+ */</span>
<a name="l00028"></a>00028 <span class="preprocessor">#ifndef  CMHPropertiesValuesList_H</span>
<a name="l00029"></a>00029 <span class="preprocessor"></span><span class="preprocessor">#define  CMHPropertiesValuesList_H</span>
<a name="l00030"></a>00030 <span class="preprocessor"></span>
<a name="l00031"></a>00031 <span class="preprocessor">#include &lt;<a class="code" href="_c_serializable_8h.html">mrpt/utils/CSerializable.h</a>&gt;</span>
<a name="l00032"></a>00032 <span class="preprocessor">#include &lt;<a class="code" href="_c_memory_chunk_8h.html">mrpt/utils/CMemoryChunk.h</a>&gt;</span>
<a name="l00033"></a>00033 <span class="preprocessor">#include &lt;<a class="code" href="os_8h.html">mrpt/system/os.h</a>&gt;</span>
<a name="l00034"></a>00034 
<a name="l00035"></a>00035 <span class="comment">/*---------------------------------------------------------------</span>
<a name="l00036"></a>00036 <span class="comment">        Class</span>
<a name="l00037"></a>00037 <span class="comment">  ---------------------------------------------------------------*/</span>
<a name="l00038"></a>00038 <span class="keyword">namespace </span>mrpt
<a name="l00039"></a>00039 {
<a name="l00040"></a>00040     <span class="keyword">namespace </span>utils
<a name="l00041"></a>00041     {
<a name="l00042"></a>00042         <span class="keyword">using namespace </span>mrpt;
<a name="l00043"></a>00043 
<a name="l00044"></a>00044         <span class="comment">// This must be added to any CSerializable derived class:</span>
<a name="l00045"></a><a class="code" href="structmrpt_1_1utils_1_1_c_m_h_properties_values_list_ptr.html#a09c1427365bebba3d2dc7285d70cd92d">00045</a>                 <a class="code" href="_c_serializable_8h.html#ab89b7a3de0a1baf5a5af4454add7d0f8" title="This declaration must be inserted in all CSerializable classes definition, before the class declarati...">DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE</a>( <a class="code" href="classmrpt_1_1utils_1_1_c_m_h_properties_values_list.html" title="An arbitrary list of &quot;annotations&quot;, or named attributes, each being an instance of any CSerializable ...">CMHPropertiesValuesList</a>, <a class="code" href="classmrpt_1_1utils_1_1_c_serializable.html" title="The virtual base class which provides a unified interface for all persistent objects in MRPT...">mrpt::utils::CSerializable</a> )
<a name="l00046"></a>00046 
<a name="l00047"></a>00047 
<a name="l00048"></a>00048         <span class="comment">/** Internal triplet for each property in utils::CMHPropertiesValuesList */</span>
<a name="l00049"></a>00049         struct <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_property_value_i_d_triplet.html" title="Internal triplet for each property in utils::CMHPropertiesValuesList.">TPropertyValueIDTriplet</a>
<a name="l00050"></a>00050         {
<a name="l00051"></a><a class="code" href="structmrpt_1_1utils_1_1_t_property_value_i_d_triplet.html#a38a0684f448a2cf8d8fcd6fe34db348d">00051</a>             TPropertyValueIDTriplet() : name(), value(NULL),ID(0)
<a name="l00052"></a>00052             {}
<a name="l00053"></a>00053 
<a name="l00054"></a><a class="code" href="structmrpt_1_1utils_1_1_t_property_value_i_d_triplet.html#a6ae0ef7c01c526afc1ade0e6f6e82cd3">00054</a>             std<a class="code" href="classstd_1_1string.html" title="STL class.">::string</a>                 <a class="code" href="structmrpt_1_1utils_1_1_t_property_value_i_d_triplet.html#a6ae0ef7c01c526afc1ade0e6f6e82cd3">name</a>;
<a name="l00055"></a><a class="code" href="structmrpt_1_1utils_1_1_t_property_value_i_d_triplet.html#a3a26b7790a7849fd53bec46e18201f92">00055</a>             <a class="code" href="structmrpt_1_1utils_1_1_c_serializable_ptr.html">CSerializablePtr</a>    <a class="code" href="structmrpt_1_1utils_1_1_t_property_value_i_d_triplet.html#a3a26b7790a7849fd53bec46e18201f92">value</a>;
<a name="l00056"></a><a class="code" href="structmrpt_1_1utils_1_1_t_property_value_i_d_triplet.html#a1995ecead7e0cc57da05468b92126395">00056</a>             int64_t                             <a class="code" href="structmrpt_1_1utils_1_1_t_property_value_i_d_triplet.html#a1995ecead7e0cc57da05468b92126395">ID</a>;
<a name="l00057"></a>00057         };
<a name="l00058"></a>00058 <span class="comment"></span>
<a name="l00059"></a>00059 <span class="comment">        /** An arbitrary list of &quot;annotations&quot;, or named attributes, each being an instance of any CSerializable object (Multi-hypotheses version).</span>
<a name="l00060"></a>00060 <span class="comment">         *   For each named annotation (or attribute), several values may exist, each associated to a given hypothesis ID.</span>
<a name="l00061"></a>00061 <span class="comment">         * A non multi-hypotheses version exists in CPropertiesValuesList.</span>
<a name="l00062"></a>00062 <span class="comment">         * \sa CSerializable, CPropertiesValuesList</span>
<a name="l00063"></a>00063 <span class="comment">         * \ingroup mrpt_base_grp</span>
<a name="l00064"></a>00064 <span class="comment">         */</span>
<a name="l00065"></a>00065         <span class="keyword">class </span><a class="code" href="base_2include_2mrpt_2base_2link__pragmas_8h.html#a6045fa0129b1a3d6c8bf895470e66574">BASE_IMPEXP</a> <a class="code" href="classmrpt_1_1utils_1_1_c_m_h_properties_values_list.html" title="An arbitrary list of &quot;annotations&quot;, or named attributes, each being an instance of any CSerializable ...">CMHPropertiesValuesList</a> : <span class="keyword">public</span> mrpt::utils::<a class="code" href="classmrpt_1_1utils_1_1_c_serializable.html" title="The virtual base class which provides a unified interface for all persistent objects in MRPT...">CSerializable</a>
<a name="l00066"></a>00066         {
<a name="l00067"></a>00067             <span class="comment">// This must be added to any CSerializable derived class:</span>
<a name="l00068"></a><a class="code" href="classmrpt_1_1utils_1_1_c_m_h_properties_values_list.html#aa284669270095cf6143bf3439a363eae">00068</a>             <a class="code" href="_c_serializable_8h.html#a72ab55bf7ae009c89b75715cfa21e84d" title="This declaration must be inserted in all CSerializable classes definition, within the class declarati...">DEFINE_SERIALIZABLE</a>( <a class="code" href="classmrpt_1_1utils_1_1_c_m_h_properties_values_list.html" title="An arbitrary list of &quot;annotations&quot;, or named attributes, each being an instance of any CSerializable ...">CMHPropertiesValuesList</a> )
<a name="l00069"></a>00069 
<a name="l00070"></a>00070                 private:
<a name="l00071"></a><a class="code" href="classmrpt_1_1utils_1_1_c_m_h_properties_values_list.html#ab807a04d43f66ac257d65a3bcc9df957">00071</a>                         std::<a class="code" href="classstd_1_1vector.html" title="STL class.">vector</a>&lt;<a class="code" href="structmrpt_1_1utils_1_1_t_property_value_i_d_triplet.html" title="Internal triplet for each property in utils::CMHPropertiesValuesList.">TPropertyValueIDTriplet</a>&gt;    m_properties;
<a name="l00072"></a>00072 
<a name="l00073"></a>00073         public:<span class="comment"></span>
<a name="l00074"></a>00074 <span class="comment">            /** Default constructor</span>
<a name="l00075"></a>00075 <span class="comment">              */</span>
<a name="l00076"></a>00076             <a class="code" href="classmrpt_1_1utils_1_1_c_m_h_properties_values_list.html" title="An arbitrary list of &quot;annotations&quot;, or named attributes, each being an instance of any CSerializable ...">CMHPropertiesValuesList</a>();
<a name="l00077"></a>00077 <span class="comment"></span>
<a name="l00078"></a>00078 <span class="comment">            /** Copy constructor</span>
<a name="l00079"></a>00079 <span class="comment">              */</span>
<a name="l00080"></a>00080             CMHPropertiesValuesList( const CMHPropertiesValuesList&amp; o );
<a name="l00081"></a>00081 <span class="comment"></span>
<a name="l00082"></a>00082 <span class="comment">            /** Copy operator</span>
<a name="l00083"></a>00083 <span class="comment">              */</span>
<a name="l00084"></a>00084             CMHPropertiesValuesList &amp; operator =( const CMHPropertiesValuesList&amp; o );
<a name="l00085"></a>00085 <span class="comment"></span>
<a name="l00086"></a>00086 <span class="comment">            /** Destructor</span>
<a name="l00087"></a>00087 <span class="comment">              */</span>
<a name="l00088"></a>00088             virtual ~CMHPropertiesValuesList();
<a name="l00089"></a>00089 <span class="comment"></span>
<a name="l00090"></a>00090 <span class="comment">            /** Clears the list and frees all object&#39;s memory.</span>
<a name="l00091"></a>00091 <span class="comment">              */</span>
<a name="l00092"></a>00092             <span class="keywordtype">void</span>  clear();
<a name="l00093"></a>00093 <span class="comment"></span>
<a name="l00094"></a>00094 <span class="comment">            /** Returns the value of the property (case insensitive) for some given hypothesis ID, or a NULL smart pointer if it does not exist.</span>
<a name="l00095"></a>00095 <span class="comment">              */</span>
<a name="l00096"></a>00096             <a class="code" href="structmrpt_1_1utils_1_1_c_serializable_ptr.html">CSerializablePtr</a>  get(const <span class="keywordtype">char</span> *propertyName, const int64_t &amp; hypothesis_ID ) const;
<a name="l00097"></a>00097 <span class="comment"></span>
<a name="l00098"></a>00098 <span class="comment">            /** Returns the value of the property (case insensitive) for some given hypothesis ID checking its class in runtime, or a NULL smart pointer if it does not exist.</span>
<a name="l00099"></a>00099 <span class="comment">              */</span>
<a name="l00100"></a>00100                         template &lt;typename T&gt;
<a name="l00101"></a><a class="code" href="classmrpt_1_1utils_1_1_c_m_h_properties_values_list.html#a13edcf3c5d4e925087f5d9d5949d3858">00101</a>             typename T::<a class="code" href="structmrpt_1_1utils_1_1_c_m_h_properties_values_list_ptr.html">SmartPtr</a> <a class="code" href="namespacemrpt_1_1utils.html#ab0d63216ed1169b8456c0291d7dfcfc8" title="Utility to get a cast&#39;ed pointer from a smart pointer.">getAs</a>(const <span class="keywordtype">char</span> *propertyName, const int64_t &amp; hypothesis_ID, <span class="keywordtype">bool</span> allowNullPointer = true)<span class="keyword"> const</span>
<a name="l00102"></a>00102 <span class="keyword">                        </span>{
<a name="l00103"></a>00103                                 <a class="code" href="mrpt__macros_8h.html#a45b840af519f33816311acdbb28d7c10">MRPT_START</a>
<a name="l00104"></a>00104                                 <a class="code" href="structmrpt_1_1utils_1_1_c_serializable_ptr.html">CSerializablePtr</a> obj = <span class="keyword">get</span>(propertyName,hypothesis_ID);
<a name="l00105"></a>00105                                 <span class="keywordflow">if</span> (!obj) 
<a name="l00106"></a>00106                                 {
<a name="l00107"></a>00107                                         <span class="keywordflow">if</span> (allowNullPointer)
<a name="l00108"></a>00108                                                         <span class="keywordflow">return</span> <span class="keyword">typename</span> T::SmartPtr();
<a name="l00109"></a>00109                                         <span class="keywordflow">else</span>    <a class="code" href="mrpt__macros_8h.html#aaa3f404ea85a6575a7139f8d101370ba">THROW_EXCEPTION</a>(<span class="stringliteral">&quot;Null pointer&quot;</span>)
<a name="l00110"></a>00110                                 }
<a name="l00111"></a>00111                                 <span class="keyword">const</span> mrpt<a class="code" href="structmrpt_1_1utils_1_1_t_runtime_class_id.html" title="A structure that holds runtime class type information.">::utils::TRuntimeClassId</a>*     class_ID = T::classinfo;
<a name="l00112"></a>00112                                 <a class="code" href="mrpt__macros_8h.html#a47eb5a445c2bf3d9190396510ea9683e">ASSERT_</a>( class_ID == obj-&gt;GetRuntimeClass() );
<a name="l00113"></a>00113                                 <span class="keywordflow">return</span> <span class="keyword">typename</span> T::SmartPtr( obj );
<a name="l00114"></a>00114                                 <a class="code" href="mrpt__macros_8h.html#a88a917260793b56abd83ad2a0d849eb1">MRPT_END</a>
<a name="l00115"></a>00115                         }
<a name="l00116"></a>00116 
<a name="l00117"></a>00117                         <span class="comment"></span>
<a name="l00118"></a>00118 <span class="comment">                        /** Returns the value of the property (case insensitive) for the first hypothesis ID found, or NULL if it does not exist.</span>
<a name="l00119"></a>00119 <span class="comment">              */</span>
<a name="l00120"></a>00120             <a class="code" href="structmrpt_1_1utils_1_1_c_serializable_ptr.html">CSerializablePtr</a>  getAnyHypothesis(<span class="keyword">const</span> <span class="keywordtype">char</span> *propertyName) <span class="keyword">const</span>;
<a name="l00121"></a>00121 <span class="comment"></span>
<a name="l00122"></a>00122 <span class="comment">            /** Sets/change the value of the property (case insensitive) for the given hypothesis ID, making a copy of the object (or setting it to NULL if it is the passed value)</span>
<a name="l00123"></a>00123 <span class="comment">              * \sa setMemoryReference</span>
<a name="l00124"></a>00124 <span class="comment">              */</span>
<a name="l00125"></a>00125             <span class="keywordtype">void</span>  <span class="keyword">set</span>(<span class="keyword">const</span> <span class="keywordtype">char</span> *propertyName, <span class="keyword">const</span> <a class="code" href="structmrpt_1_1utils_1_1_c_serializable_ptr.html">CSerializablePtr</a> &amp;obj, <span class="keyword">const</span> int64_t &amp; hypothesis_ID);
<a name="l00126"></a>00126 <span class="comment"></span>
<a name="l00127"></a>00127 <span class="comment">            /** Sets/change the value of the property (case insensitive) for the given hypothesis ID, directly replacing the pointer instead of making a copy of the object.</span>
<a name="l00128"></a>00128 <span class="comment">              * \sa set</span>
<a name="l00129"></a>00129 <span class="comment">              */</span>
<a name="l00130"></a>00130             <span class="keywordtype">void</span>  setMemoryReference(<span class="keyword">const</span> <span class="keywordtype">char</span> *propertyName, <span class="keyword">const</span> <a class="code" href="structmrpt_1_1utils_1_1_c_serializable_ptr.html">CSerializablePtr</a>&amp; obj, <span class="keyword">const</span> int64_t &amp; hypothesis_ID);
<a name="l00131"></a>00131 <span class="comment"></span>
<a name="l00132"></a>00132 <span class="comment">            /** Remove a given property, if it exists.</span>
<a name="l00133"></a>00133 <span class="comment">              */</span>
<a name="l00134"></a>00134             <span class="keywordtype">void</span>  <span class="keyword">remove</span>(<span class="keyword">const</span> <span class="keywordtype">char</span> *propertyName, <span class="keyword">const</span> int64_t &amp; hypothesis_ID);
<a name="l00135"></a>00135 <span class="comment"></span>
<a name="l00136"></a>00136 <span class="comment">            /** Remove all the properties for the given hypothesis.</span>
<a name="l00137"></a>00137 <span class="comment">              */</span>
<a name="l00138"></a>00138             <span class="keywordtype">void</span>  removeAll(<span class="keyword">const</span> int64_t &amp; hypothesis_ID);
<a name="l00139"></a>00139 <span class="comment"></span>
<a name="l00140"></a>00140 <span class="comment">            /** Sets/change the value of a property (case insensitive) for the given hypothesis ID, from an elemental data type.</span>
<a name="l00141"></a>00141 <span class="comment">              */</span>
<a name="l00142"></a>00142             <span class="keyword">template</span> &lt;<span class="keyword">class</span> T&gt;
<a name="l00143"></a><a class="code" href="classmrpt_1_1utils_1_1_c_m_h_properties_values_list.html#a93582a65770d0758ad6ba3bfb1c7e582">00143</a>             <span class="keywordtype">void</span>  setElemental(<span class="keyword">const</span> <span class="keywordtype">char</span> *propertyName, <span class="keyword">const</span> T &amp;data, <span class="keyword">const</span> int64_t &amp; hypothesis_ID)
<a name="l00144"></a>00144             {
<a name="l00145"></a>00145                 <a class="code" href="mrpt__macros_8h.html#a45b840af519f33816311acdbb28d7c10">MRPT_START</a>
<a name="l00146"></a>00146 
<a name="l00147"></a>00147                 <a class="code" href="structmrpt_1_1utils_1_1_c_memory_chunk_ptr.html">CMemoryChunkPtr</a> memChunk = <a class="code" href="structmrpt_1_1utils_1_1_c_memory_chunk_ptr.html">CMemoryChunkPtr</a>( <span class="keyword">new</span> <a class="code" href="classmrpt_1_1utils_1_1_c_memory_chunk.html" title="A memory buffer (implements CStream) which can be itself serialized.">CMemoryChunk</a>() );
<a name="l00148"></a>00148                                 memChunk-&gt;setAllocBlockSize(10);
<a name="l00149"></a>00149                 (*memChunk) &lt;&lt; data;
<a name="l00150"></a>00150 
<a name="l00151"></a>00151                 <span class="keywordflow">for</span> (<a class="code" href="classstd_1_1vector_1_1iterator.html" title="STL iterator class.">std::vector&lt;TPropertyValueIDTriplet&gt;::iterator</a> it=m_properties.begin();it!=m_properties.end();++it)
<a name="l00152"></a>00152                 {
<a name="l00153"></a>00153                     <span class="keywordflow">if</span> ( it-&gt;ID == hypothesis_ID &amp;&amp; !<a class="code" href="group__mrpt__system__os.html#ga0b3d8b9d83ae1b217d30f59589a1be3f" title="An OS-independent version of strcmpi.">system::os::_strcmpi</a>(propertyName,it-&gt;name.c_str()) )
<a name="l00154"></a>00154                     {
<a name="l00155"></a>00155                         <span class="comment">// Delete current contents &amp;</span>
<a name="l00156"></a>00156                         <span class="comment">// Copy new value:</span>
<a name="l00157"></a>00157                         it-&gt;value = memChunk;
<a name="l00158"></a>00158                         <span class="keywordflow">return</span>;
<a name="l00159"></a>00159                     }
<a name="l00160"></a>00160                 }
<a name="l00161"></a>00161 
<a name="l00162"></a>00162                 <span class="comment">// Insert as new:</span>
<a name="l00163"></a>00163                 <a class="code" href="structmrpt_1_1utils_1_1_t_property_value_i_d_triplet.html" title="Internal triplet for each property in utils::CMHPropertiesValuesList.">TPropertyValueIDTriplet</a> newPair;
<a name="l00164"></a>00164                 newPair.<a class="code" href="structmrpt_1_1utils_1_1_t_property_value_i_d_triplet.html#a6ae0ef7c01c526afc1ade0e6f6e82cd3">name</a> = <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>(propertyName);
<a name="l00165"></a>00165                 newPair.<a class="code" href="structmrpt_1_1utils_1_1_t_property_value_i_d_triplet.html#a3a26b7790a7849fd53bec46e18201f92">value</a> = memChunk;
<a name="l00166"></a>00166                 newPair.<a class="code" href="structmrpt_1_1utils_1_1_t_property_value_i_d_triplet.html#a1995ecead7e0cc57da05468b92126395">ID</a>    = hypothesis_ID;
<a name="l00167"></a>00167                 m_properties.push_back(newPair);
<a name="l00168"></a>00168 
<a name="l00169"></a>00169                 <a class="code" href="mrpt__macros_8h.html#aa4441d1a566657479542cee0ffb0a124">MRPT_END_WITH_CLEAN_UP</a>( \
<a name="l00170"></a>00170                     printf(<span class="stringliteral">&quot;Exception while setting annotation &#39;%s&#39;&quot;</span>,propertyName); \
<a name="l00171"></a>00171                     );
<a name="l00172"></a>00172             }
<a name="l00173"></a>00173 <span class="comment"></span>
<a name="l00174"></a>00174 <span class="comment">            /** Gets the value of a property (case insensitive) for the given hypothesis ID, retrieves it as an elemental data type (types must coincide, basic size check is performed).</span>
<a name="l00175"></a>00175 <span class="comment">              * \return false if the property does not exist for the given hypothesis.</span>
<a name="l00176"></a>00176 <span class="comment">              */</span>
<a name="l00177"></a>00177             <span class="keyword">template</span> &lt;<span class="keyword">class</span> T&gt;
<a name="l00178"></a><a class="code" href="classmrpt_1_1utils_1_1_c_m_h_properties_values_list.html#a3b8ff9d6bc0f2e122a3e335b9c5b047c">00178</a>             <span class="keywordtype">bool</span> getElemental(<span class="keyword">const</span> <span class="keywordtype">char</span> *propertyName, T &amp;out_data, <span class="keyword">const</span> int64_t &amp; hypothesis_ID, <span class="keywordtype">bool</span> raiseExceptionIfNotFound = <span class="keyword">false</span>)<span class="keyword"> const</span>
<a name="l00179"></a>00179 <span class="keyword">            </span>{
<a name="l00180"></a>00180                 <a class="code" href="mrpt__macros_8h.html#a45b840af519f33816311acdbb28d7c10">MRPT_START</a>
<a name="l00181"></a>00181                 <span class="keywordflow">for</span> (<a class="code" href="classstd_1_1vector_1_1const__iterator.html" title="STL iterator class.">std::vector&lt;TPropertyValueIDTriplet&gt;::const_iterator</a> it=m_properties.begin();it!=m_properties.end();++it)
<a name="l00182"></a>00182                 {
<a name="l00183"></a>00183                     <span class="keywordflow">if</span> (!<a class="code" href="group__mrpt__system__os.html#ga0b3d8b9d83ae1b217d30f59589a1be3f" title="An OS-independent version of strcmpi.">system::os::_strcmpi</a>(propertyName,it-&gt;name.c_str()) &amp;&amp; it-&gt;ID == hypothesis_ID )
<a name="l00184"></a>00184                     {
<a name="l00185"></a>00185                         <a class="code" href="structmrpt_1_1utils_1_1_c_memory_chunk_ptr.html">CMemoryChunkPtr</a> memChunk = <a class="code" href="structmrpt_1_1utils_1_1_c_memory_chunk_ptr.html">CMemoryChunkPtr</a>(it-&gt;value);
<a name="l00186"></a>00186                         <a class="code" href="mrpt__macros_8h.html#a47eb5a445c2bf3d9190396510ea9683e">ASSERT_</a>(memChunk)
<a name="l00187"></a>00187                         <span class="keywordflow">if</span> (memChunk-&gt;getTotalBytesCount()!=<span class="keyword">sizeof</span>(out_data)) <a class="code" href="mrpt__macros_8h.html#aaa3f404ea85a6575a7139f8d101370ba">THROW_EXCEPTION</a>(<span class="stringliteral">&quot;Data sizes do not match.&quot;</span>);
<a name="l00188"></a>00188                         out_data = *<span class="keyword">static_cast&lt;</span>T*<span class="keyword">&gt;</span>( memChunk-&gt;getRawBufferData() );
<a name="l00189"></a>00189                         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00190"></a>00190                     }
<a name="l00191"></a>00191                 }
<a name="l00192"></a>00192                 <span class="comment">// Not found:</span>
<a name="l00193"></a>00193                 <span class="keywordflow">if</span> (raiseExceptionIfNotFound)
<a name="l00194"></a>00194                     <a class="code" href="mrpt__macros_8h.html#a61a8d46146210ee20fa1ff423257a5ec">THROW_EXCEPTION_CUSTOM_MSG1</a>(<span class="stringliteral">&quot;Property &#39;%s&#39; not found&quot;</span>, propertyName );
<a name="l00195"></a>00195                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00196"></a>00196                 <a class="code" href="mrpt__macros_8h.html#a88a917260793b56abd83ad2a0d849eb1">MRPT_END</a>
<a name="l00197"></a>00197             }
<a name="l00198"></a>00198 <span class="comment"></span>
<a name="l00199"></a>00199 <span class="comment">            /** Returns the name of all properties in the list</span>
<a name="l00200"></a>00200 <span class="comment">              */</span>
<a name="l00201"></a>00201             std<a class="code" href="classstd_1_1vector.html">::vector&lt;std::string&gt;</a>  getPropertyNames() <span class="keyword">const</span>;
<a name="l00202"></a>00202 
<a name="l00203"></a>00203 
<a name="l00204"></a><a class="code" href="classmrpt_1_1utils_1_1_c_m_h_properties_values_list.html#ac88d3181660e1630f65c1c6f5d9a13f5">00204</a>                         <span class="keyword">typedef</span> std<a class="code" href="classstd_1_1vector_1_1iterator.html" title="STL iterator class.">::vector&lt;TPropertyValueIDTriplet&gt;::iterator</a> <a class="code" href="classmrpt_1_1utils_1_1_c_m_h_properties_values_list.html#ac88d3181660e1630f65c1c6f5d9a13f5">iterator</a>;
<a name="l00205"></a><a class="code" href="classmrpt_1_1utils_1_1_c_m_h_properties_values_list.html#af16448dc46235d6d840f154d88d85dd7">00205</a>                         <span class="keyword">typedef</span> std<a class="code" href="classstd_1_1vector_1_1const__iterator.html" title="STL iterator class.">::vector&lt;TPropertyValueIDTriplet&gt;::const_iterator</a> <a class="code" href="classmrpt_1_1utils_1_1_c_m_h_properties_values_list.html#af16448dc46235d6d840f154d88d85dd7">const_iterator</a>;
<a name="l00206"></a>00206 
<a name="l00207"></a><a class="code" href="classmrpt_1_1utils_1_1_c_m_h_properties_values_list.html#a4e7896bb06e7ccd294c2c32ee03e5660">00207</a>                         <a class="code" href="classstd_1_1vector_1_1iterator.html" title="STL iterator class.">iterator</a> <a class="code" href="classmrpt_1_1utils_1_1_c_m_h_properties_values_list.html#a4e7896bb06e7ccd294c2c32ee03e5660">begin</a>() { <span class="keywordflow">return</span> m_properties.begin(); }
<a name="l00208"></a><a class="code" href="classmrpt_1_1utils_1_1_c_m_h_properties_values_list.html#a5ec13646b6f664432f41517ceaee0eb7">00208</a>                         <a class="code" href="classstd_1_1vector_1_1const__iterator.html" title="STL iterator class.">const_iterator</a> <a class="code" href="classmrpt_1_1utils_1_1_c_m_h_properties_values_list.html#a5ec13646b6f664432f41517ceaee0eb7">begin</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> m_properties.begin(); }
<a name="l00209"></a><a class="code" href="classmrpt_1_1utils_1_1_c_m_h_properties_values_list.html#adbeae11c34ad372e39cd5ddec6db8831">00209</a>                         <a class="code" href="classstd_1_1vector_1_1iterator.html" title="STL iterator class.">iterator</a> <a class="code" href="classmrpt_1_1utils_1_1_c_m_h_properties_values_list.html#adbeae11c34ad372e39cd5ddec6db8831">end</a>() { <span class="keywordflow">return</span> m_properties.end(); }
<a name="l00210"></a><a class="code" href="classmrpt_1_1utils_1_1_c_m_h_properties_values_list.html#a599130dd0404de75dfde721dfbaa2551">00210</a>                         <a class="code" href="classstd_1_1vector_1_1const__iterator.html" title="STL iterator class.">const_iterator</a> <a class="code" href="classmrpt_1_1utils_1_1_c_m_h_properties_values_list.html#a599130dd0404de75dfde721dfbaa2551">end</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> m_properties.end(); }
<a name="l00211"></a>00211 
<a name="l00212"></a><a class="code" href="classmrpt_1_1utils_1_1_c_m_h_properties_values_list.html#ab31231f920dcee6fc7c2a924e8da5582">00212</a>                         <span class="keywordtype">size_t</span> <a class="code" href="classmrpt_1_1utils_1_1_c_m_h_properties_values_list.html#ab31231f920dcee6fc7c2a924e8da5582">size</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> m_properties.size(); }
<a name="l00213"></a>00213 
<a name="l00214"></a>00214         }; <span class="comment">// End of class def.</span>
<a name="l00215"></a>00215 
<a name="l00216"></a>00216 
<a name="l00217"></a>00217         } <span class="comment">// End of namespace</span>
<a name="l00218"></a>00218 } <span class="comment">// end of namespace</span>
<a name="l00219"></a>00219 <span class="preprocessor">#endif</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.5</a> for MRPT 0.9.5 SVN: at Sun Sep 25 17:20:18 UTC 2011</td><td></td> <td width="100"> </td> <td width="150">  </td></tr> </table>  </body></html>