ewol/ewol_tutorial_object_config.html

194 lines
15 KiB
HTML

<!-- HTML header for doxygen 1.8.8-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- For Mobile Devices -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta name="generator" content="Doxygen 1.8.12"/>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<title>Ewol: Ewol Widget in OpenGl: EWOL: Object config</title>
<!--<link href="tabs.css" rel="stylesheet" type="text/css"/>-->
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="customdoxygen.css" rel="stylesheet" type="text/css"/>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<script type="text/javascript" src="doxy-boot.js"></script>
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand">Ewol: Ewol Widget in OpenGl 0.10.0</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="index.html">Main&nbsp;Page</a></li>
<li><a href="pages.html">Related&nbsp;Pages</a></li>
<li><a href="namespaces.html">Namespaces</a></li>
<li><a href="annotated.html">Classes</a></li>
<li><a href="files.html">Files</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
Link-libs<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="http://HeeroYui.github.io/lutin">lutin</a></li>
<li><a href="http://atria-soft.github.io/ewol">ewol</a></li>
<li><a href="http://atria-soft.github.io/echrono">echrono</a></li>
<li><a href="http://atria-soft.github.io/etk">etk</a></li>
<li><a href="http://atria-soft.github.io/ejson">ejson</a></li>
<li><a href="http://atria-soft.github.io/exml">exml</a></li>
<li><a href="http://atria-soft.github.io/esvg">esvg</a></li>
<li><a href="http://atria-soft.github.io/egami">egami</a></li>
<li><a href="http://atria-soft.github.io/gale">gale</a></li>
<li><a href="http://atria-soft.github.io/ege">ege</a></li>
<li><a href="http://atria-soft.github.io/elog">elog</a></li>
<li><a href="http://atria-soft.github.io/ememory">ememory</a></li>
<li><a href="http://atria-soft.github.io/enet">enet</a></li>
<li><a href="http://atria-soft.github.io/eproperty">eproperty</a></li>
<li><a href="http://atria-soft.github.io/esignal">esignal</a></li>
<li><a href="http://atria-soft.github.io/etranslate">etranslate</a></li>
<li><a href="http://atria-soft.github.io/zeus">zeus</a></li>
<li><a href="http://musicdsp.github.io/audio-ess">audio-ess</a></li>
<li><a href="http://musicdsp.github.io/audio">audio</a></li>
<li><a href="http://musicdsp.github.io/audio-drain">audio-drain</a></li>
<li><a href="http://musicdsp.github.io/audio-orchestra">audio-orchestra</a></li>
<li><a href="http://musicdsp.github.io/audio-river">audio-river</a></li>
</ul>
</li>
</ul>
<div id="search-box" class="input-group">
<div class="input-group-btn">
<button aria-expanded="false" type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<span class="glyphicon glyphicon-search"></span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a href="#">All</a></li>
<li><a href="#">Classes</a></li>
<li><a href="#">Namespaces</a></li>
<li><a href="#">Files</a></li>
<li><a href="#">Functions</a></li>
<li><a href="#">Variables</a></li>
<li><a href="#">Typedefs</a></li>
<li><a href="#">Enumerations</a></li>
<li><a href="#">Enumerator</a></li>
<li><a href="#">Friends</a></li>
<li><a href="#">Macros</a></li>
<li><a href="#">Pages</a></li>
</ul>
</div>
<button id="search-close" type="button" class="close" aria-label="Close">
<span aria-hidden="true"></span>
</button>
<input id="search-field" class="form-control" accesskey="S" onkeydown="searchBox.OnSearchFieldChange(event);" placeholder="Search ..." type="text">
</div>
</div><!--/.nav-collapse -->
</div>
</nav>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div class="content" id="content">
<div class="container">
<div class="row">
<div class="col-sm-12 panel panel-default" style="padding-bottom: 15px;">
<div style="margin-bottom: 15px;margin-top: 60px;">
<!-- end header part -->
<!-- Generated by Doxygen 1.8.12 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle">
<div class="title">EWOL: Object config </div> </div>
</div><!--header-->
<div class="contents">
<div class="toc"><h3>Table of Contents</h3>
<ul><li class="level1"><a href="#ewol_tutorial_object_config_objectives">Objectifs: </a></li>
<li class="level1"><a href="#ewol_tutorial_object_configusing">Configuration using </a><ul><li class="level2"><a href="#ewol_tutorial_object_config_prop">Set a Parameter/Property </a></li>
<li class="level2"><a href="#ewol_tutorial_object_config_param">Get Parameter </a></li>
</ul>
</li>
<li class="level1"><a href="#ewol_tutorial_object_config_impl">Implement configuration </a></li>
</ul>
</div>
<div class="textblock"><p>Constructor MyObj(void) : propertyValue(this, "value", false, "Value of the parameter (descrition string)", &amp;appl::MyObj::onChangeParameterValue) { // nothing to do.. } void <a class="elRef" doxygen="/home/heero/dev/perso/out/doc/release/etk.tag:http://atria-soft.github.io/etk/" href="http://atria-soft.github.io/etk/namespaceetk.html#aa87d94d7a27bd41c9982fe0ba83d6f88">init()</a> { ewol::Object::init(); // do some stuff with the init value } public: //!</p>
<h1><a class="anchor" id="ewol_tutorial_object_config_objectives"></a>
Objectifs: </h1>
<ul>
<li>Understand base of <a href="http://atria-soft.github.io/eproperty">e-property</a> configuration parameter</li>
<li>Create an configurable object</li>
</ul>
<h1><a class="anchor" id="ewol_tutorial_object_configusing"></a>
Configuration using </h1>
<p>All <a class="el" href="classewol_1_1_object.html" title="Basic message classes for ewol system this class mermit at every Object to communicate between them...">ewol::Object</a> have a configuration of parameters (the object name is a parameter), then we need to set get and use xml to update parameters.</p>
<h2><a class="anchor" id="ewol_tutorial_object_config_prop"></a>
Set a Parameter/Property </h2>
<p><b>Note:</b></p>
<div class="fragment"><div class="line">Parameter is managed by the [e-property](http://atria-soft.github.io/eproperty)</div></div><!-- fragment --><p>With a string configuration </p><hr/>
<div class="fragment"><div class="line"><span class="keywordflow">if</span> (tmpObject-&gt;properties.set(<span class="stringliteral">&quot;name&quot;</span>, <span class="stringliteral">&quot;new name of object&quot;</span>) == <span class="keyword">false</span>) {</div><div class="line"> APPL_ERROR(<span class="stringliteral">&quot;Can not set object parameter&quot;</span>);</div><div class="line">}</div></div><!-- fragment --><p>whith the object name </p><hr/>
<div class="fragment"><div class="line"><span class="keywordflow">if</span> (ewol::propertySetOnObjectNamed(<span class="stringliteral">&quot;objectName&quot;</span>, <span class="stringliteral">&quot;value&quot;</span>, <span class="stringliteral">&quot;16.2&quot;</span>) == <span class="keyword">false</span>) {</div><div class="line"> APPL_ERROR(<span class="stringliteral">&quot;Can not set object parameter&quot;</span>);</div><div class="line">}</div></div><!-- fragment --><h2><a class="anchor" id="ewol_tutorial_object_config_param"></a>
Get Parameter </h2>
<div class="fragment"><div class="line">std::string val = tmpObject-&gt;properties.<a class="codeRef" doxygen="/home/heero/dev/perso/out/doc/release/ememory.tag:http://atria-soft.github.io/ememory/" href="http://atria-soft.github.io/ememory/classememory_1_1_shared_ptr.html#ad4b7eb0326a1d4aac87d2699eb6902cb">get</a>(<span class="stringliteral">&quot;name&quot;</span>);</div><div class="line">APPL_INFO(<span class="stringliteral">&quot;Get Object property: name=&#39;&quot;</span> &lt;&lt; val &lt;&lt; <span class="stringliteral">&quot;&#39;&quot;</span>);</div></div><!-- fragment --><h1><a class="anchor" id="ewol_tutorial_object_config_impl"></a>
Implement configuration </h1>
<div class="fragment"><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="_object_8hpp.html">ewol/object/Object.hpp</a>&gt;</span></div><div class="line"><span class="keyword">namespace </span>appl {</div><div class="line"> <span class="keyword">class </span>MyObj : <span class="keyword">public</span> <a class="code" href="classewol_1_1_object.html">ewol::Object</a> {</div><div class="line"> <span class="keyword">public</span>:</div><div class="line"> <a class="codeRef" doxygen="/home/heero/dev/perso/out/doc/release/eproperty.tag:http://atria-soft.github.io/eproperty/" href="http://atria-soft.github.io/eproperty/classeproperty_1_1_value.html">eproperty::Value&lt;bool&gt;</a> propertyValue; </div><div class="line"> <span class="keyword">protected</span>:</div><div class="line"> <span class="keyword">virtual</span> ~MyObj(<span class="keywordtype">void</span>) { }</div><div class="line"> DECLARE_FACTORY(MyObj);</div><div class="line"> <span class="keyword">public</span>:</div><div class="line"> <span class="keywordtype">void</span> onChangeParameterValue() {</div><div class="line"> APPL_DEBUG(<span class="stringliteral">&quot;The internal value has change, new value is : &#39;&quot;</span> &lt;&lt; *m_value &lt;&lt; <span class="stringliteral">&quot;&#39;&quot;</span>);</div><div class="line"> }</div><div class="line"> }</div><div class="line">}</div></div><!-- fragment --><p>In the contructor we need to add: </p><div class="fragment"><div class="line">propertyValue(<span class="keyword">this</span>,</div><div class="line"> <span class="stringliteral">&quot;value&quot;</span>,</div><div class="line"> <span class="keyword">false</span>,</div><div class="line"> <span class="stringliteral">&quot;Value of the parameter (descrition string)&quot;</span>,</div><div class="line"> &amp;appl::MyObj::onChangeParameterValue)</div></div><!-- fragment --><ul>
<li>**'this':** Pointer the main class to call it chen value change.</li>
<li>**"value":** Is the name of the parameter.</li>
<li><b>false:</b> The default value.</li>
<li>**"....."** Description of the parameter (optionnal).</li>
<li>**&amp;appl::MyObj::onChangeParameterValue** The callback when the value change (optionnal).</li>
</ul>
<p>The last point is that the <code>*propertyValue</code> same as <code><a class="el" href="namespaceewol_1_1translate.html#a72a97866a6d77d74fa17cbecd7341172" title="Translate a specific text (if not find, it will be retured the same text). ">propertyValue.get()</a></code> are inline fuction then it take no more CPU cycle to access the value than normal variable.</p>
<p>Some other parameter are availlable :</p><ul>
<li>eproperty::Value&lt;T&gt; Basic parameter.</li>
<li>eproperty::Range&lt;T&gt; For numeric parameter that range value are check befor setting new value.</li>
<li>eproperty::List&lt;T&gt; For List of parameter values.</li>
</ul>
<p>For more information see <a href="http://atria-soft.github.io/eproperty">e-property</a> </p>
</div></div><!-- contents -->
<!-- HTML footer for doxygen 1.8.8-->
<!-- start footer part -->
</div>
</div>
</div>
</div>
</div>
<hr class="footer"/><address class="footer"><small>
Generated on Mon Oct 24 2016 15:35:52 for Ewol: Ewol Widget in OpenGl by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.12
</small></address>
</body>
</html>