<p><ahref="http://utilite.googlecode.com">UtiLite</a> is a simple library to create small cross-platform applications using <b>threads</b>, <b>events-based communication</b> and a powerful <b>logger</b>. The first three sections show the core classes of the library, then last sections show some useful functions added through time.</p>
<p>UtiLite provides a utility application called <aclass="el"href="uResourceGeneratorPage.html">uResourceGenerator</a> to generate resources to include in an executable. For example: </p><divclass="fragment"><divclass="line">$ <aclass="code hl_namespace"href="namespacertabmap.html">rtabmap</a>-res_tool DatabaseSchema.sql</div>
</div><!-- fragment --><p> This will generate a HEX file "DatabaseSchema_sql.h" which can be included in source files. Data of the file is global and can be accessed by the generated const char * DATABASESCHEMA_SQL. </p><divclass="fragment"><divclass="line"><spanclass="preprocessor">#include "DatabaseSchema_sql.h"</span></div>
</div><!-- fragment --><h1><aclass="anchor"id="logger"></a>
ULogger</h1>
<p>The <aclass="el"href="classULogger.html">ULogger</a> can be used anywhere in the application to log messages (formated like a printf). The logger can be set (<aclass="el"href="classULogger.html#a0fe73ce7c193ff399bca16b8d4d4cabb">ULogger::setType()</a>) to print in a file or in the console (with colors depending on the severity). Convenient macros are given, working like a printf(), as <aclass="el"href="ULogger_8h.html#a9104cb408bf9019db2a2c4476835db4a">UDEBUG()</a>, <aclass="el"href="ULogger_8h.html#a5b63c9a1441181723754c0c6084231a8">UINFO()</a>, <aclass="el"href="ULogger_8h.html#ab5a739ad9340455e46eaa570f8223d9a">UWARN()</a>, <aclass="el"href="ULogger_8h.html#a1249ddbc4c9cc43be53048c08dda129b">UERROR()</a>, <aclass="el"href="ULogger_8h.html#aabc10368a622911d56a4dd5a4b461385">UFATAL()</a>, <aclass="el"href="ULogger_8h.html#ab3436168e27946669bbd4c76e4c4007e">UASSERT()</a>. Small example: </p><divclass="fragment"><divclass="line">...</div>
<divclass="line">UINFO(<spanclass="stringliteral">"A simple message with number %d"</span>, 42);</div>
</div><!-- fragment --><p> This will print: [Severity] (Time) File:Line:Function() "The message" </p><divclass="fragment"><divclass="line">[ INFO] (2010-09-25 18:08:20) main.cpp:18::main() A simple message with number 42</div>
<divclass="line">[DEBUG] (2010-09-25 18:08:20) main.cpp:18::main() A debug message</div>
</div><!-- fragment --><h1><aclass="anchor"id="eventsmanager"></a>
UEventsManager, UEventsHandler, UEvent</h1>
<p>The events-based communication framework helps to communicate between objects/threads. The <aclass="el"href="classUEventsManager.html">UEventsManager</a> is a singleton with which we can post events anywhere in the application by calling <aclass="el"href="classUEventsManager.html#a956353a8006abe2edb0be2e1fc1846cb">UEventsManager::post()</a>. All <aclass="el"href="classUEventsHandler.html">UEventsHandler</a> will then receive the event with their protected function <aclass="el"href="classUEventsHandler.html#a0d43b582c19f01196a513f66d3618d8d">UEventsHandler::handleEvent()</a>. Handlers are added to <aclass="el"href="classUEventsManager.html">UEventsManager</a> by calling <aclass="el"href="classUEventsManager.html#a3bb033062e4a0eb59efdf5f84d170388">UEventsManager::addHandler()</a>. The <aclass="el"href="classUEvent.html">UEvent</a> provides an abstract class to implement any event implementations. The only requirement is that the event must implements <aclass="el"href="classUEvent.html#a2c7d278240ad4b7d88a2c534cc5f47b4">UEvent::getClassName()</a> to know the event's type. </p><divclass="fragment"><divclass="line">...</div>
<divclass="line">MyHandler handler; <spanclass="comment">// MyHandler is an implementation of UEventsHandler</span></div>
<divclass="line"><aclass="code hl_function"href="classUEventsManager.html#a956353a8006abe2edb0be2e1fc1846cb">UEventsManager::post</a>(<spanclass="keyword">new</span> MyEvent()); <spanclass="comment">// MyEvent is an implementation of UEvent</span></div>
<divclass="line"><spanclass="comment">// The UEventsHandler::handleEvent() of "handler" will then be called by the UEventsManager's events dispatching thread.</span></div>
</div><!-- fragment --><p> Look at the <b>full example</b> in page of <aclass="el"href="classUEventsHandler.html">UEventsHandler</a> on how communication works with threads (<aclass="el"href="classUThread.html">UThread</a>).</p>
<h1><aclass="anchor"id="thread"></a>
UThread, UMutex, USemaphore</h1>
<p>The multi-threading framework use a <aclass="el"href="classUThread.html">UThread</a> as an abstract class to implement a thread in object-style. Reimplement UThread::mainLoop() then call <aclass="el"href="classUThread.html#a051e9adcf24f92b9c8e31acd06bad88c">UThread::start()</a> to start the main loop of the thread. Threads can be joined by calling <aclass="el"href="classUThread.html#acf33c0e4b656af76da100e7d4f69ed1d">UThread::join()</a> and killed by calling <aclass="el"href="classUThread.html#a8dfefcfd68b453da08ddba9836f35965">UThread::kill()</a>. Classes <aclass="el"href="classUMutex.html">UMutex</a> and <aclass="el"href="classUSemaphore.html">USemaphore</a> provide blocking mechanisms to protect data between threads. </p><divclass="fragment"><divclass="line">...</div>
<divclass="line">MyThread t; <spanclass="comment">// MyThread is an implementation of UThread</span></div>
<divclass="line">t.start();</div>
<divclass="line">t.join(); <spanclass="comment">// Wait the thread to finish</span></div>
<divclass="line">...</div>
</div><!-- fragment --><h1><aclass="anchor"id="timer"></a>
UTimer</h1>
<p>A useful class to compute processing time:</p><ul>
<p>The library provides some simple wrappers of the STL like:</p><ul>
<li><aclass="el"href="UStl_8h.html#a62335030b4c0d80f80e7c4a21721c05e">uUniqueKeys()</a> to get unique keys from a std::multimap,</li>
<li><aclass="el"href="UStl_8h.html#aa67c880cc8f27c9270c7bd4bdce62ca7">uKeys()</a> to get all keys of a std::multimap or std::map,</li>
<li><aclass="el"href="UStl_8h.html#a745b929c605a3d6b0014dff0c9c2a314">uValues()</a> to get all values of a std::multimap or std::map,</li>
<li><aclass="el"href="UStl_8h.html#a155cd26667d2f88ee05dd3d819ae8182">uValue()</a> to get the value of a key (with a default argument if the key is not found),</li>
<li><aclass="el"href="UStl_8h.html#a6242bd5879bd7f06b8de6498650aa3b7">uTake()</a> to take the value of a key (with a default argument if the key is not found),</li>
<li><aclass="el"href="UStl_8h.html#aa8bd447989a2ac6dbd4537cabdb9b8a2">uIteratorAt()</a> to get iterator at a specified position in a std::list,</li>
<li><aclass="el"href="UStl_8h.html#a27a0f94be07c53df9827b082eb107337">uValueAt()</a> to get value at a specified position in a std::list,</li>
<li><aclass="el"href="UStl_8h.html#a4cad7064de642559152c873f2ca9a471">uContains()</a> to know if a key/value exists in a std::multimap, std::map, std::list,</li>
<li><aclass="el"href="UStl_8h.html#ac9c9d1520c7facb601ae56cab3762b41">uInsert()</a> to insert a value in a std::map and overwriting the value if the key already exists,</li>
<li><aclass="el"href="UStl_8h.html#a472c2e123cd6eb04165b2d3461a634d3">uAppend()</a> to append a list to another list,</li>
<li><aclass="el"href="UStl_8h.html#ad3918a32500de71ba8bb7aab99dccf46">uIndexOf()</a> to get index of a value in a std::list,</li>
<li><aclass="el"href="UStl_8h.html#ab1862437019327ce8419569e3c2ea90f">uSplit()</a> to split a string into a std::list of strings on the specified separator.</li>
</ul>
<h1><aclass="anchor"id="math"></a>
Basic mathematic operations</h1>
<p>A library of basic array manipulations:</p><ul>
<p>This class can be used to get the process memory usage: <aclass="el"href="classUProcessInfo.html#a8a494e68cdea348a4788b8d54fd7de40"title="Get the memory used by the current process.">UProcessInfo::getMemoryUsage()</a>. </p>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<divid="nav-path"class="navpath"><!-- id is needed for treeview function! -->
<ul>
<liclass="footer">Generated by <ahref="https://www.doxygen.org/index.html"><imgclass="footer"src="doxygen.svg"width="104"height="31"alt="doxygen"/></a> 1.9.8 </li>