<li>Understand ewol basic <aclass="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></li>
<li>Use <aclass="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> correctly</li>
<p>An object in Ewol is a simple class: <aclass="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> This object is the basis of all element in the ewol system. This is designed to manage many common things:</p>
<ul>
<li>Unique ID</li>
<li>Name</li>
<li>Parameters</li>
<li>Signal generation</li>
<li>Xml configuration</li>
<li>Removing</li>
</ul>
<p><b>Note:</b></p>
<divclass="fragment"><divclass="line">Please do not compare with the gObject basic class...</div></div><!-- fragment --><h1><aclass="anchor"id="ewol_tutorial_object_model_create"></a>
Create an Object: </h1>
<p>Creating an object is really simple:</p>
<divclass="fragment"><divclass="line"><aclass="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">ewol::widget::ButtonShared</a> tmpButon = ewol::widget::Button::create();</div><divclass="line">APPL_INFO(<spanclass="stringliteral">"We just create a button widget with unique ID="</span><< tmpButon-><aclass="code"href="classewol_1_1_object.html#ae11b9bed4b94f3edbb724c8b416a90d4">getId</a>() <<<spanclass="stringliteral">" name='"</span><< tmpButon-><aclass="code"href="classewol_1_1_object.html#a61eacd4d36c9cb0d108c2dbcddbdd4dc">propertyName</a>.<aclass="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_property_type.html#aaf54e7f327af57ae5b735c4df8e92d1c">get</a>() <<<spanclass="stringliteral">"'"</span>);</div></div><!-- fragment --><p>Note that all object created are <aclass="elRef"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">ememory::SharedPtr</a> base for the current version on std::shared_ptr. We wrapped it because the current inplementation of std::shared_ptr is not thread safe, and we want use a thread-safe version of it.</p>
<p><b>Note:</b></p>
<divclass="fragment"><divclass="line">The widget is not stored in a ememory::SharedPtr<ewol::widget::Button> but in a ewol::widget::ButtonShared to simplify the using of the pointer.</div><divclass="line">You have also: ememory::WeakPtr<ewol::widget::Button> = ewol::widget::ButtonWeak</div></div><!-- fragment --><p>Set the name of the object:</p>
<divclass="fragment"><divclass="line">tmpButon-><aclass="code"href="classewol_1_1_object.html#a61eacd4d36c9cb0d108c2dbcddbdd4dc">propertyName</a>.<aclass="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_property_type.html#a29dd42486e15d92b9ea94d30e99854e1">set</a>(<spanclass="stringliteral">"my widget name"</span>);</div><divclass="line">APPL_INFO(<spanclass="stringliteral">"We just create an Object with ID="</span><< tmpButon-><aclass="code"href="classewol_1_1_object.html#ae11b9bed4b94f3edbb724c8b416a90d4">getId</a>() <<<spanclass="stringliteral">" name='"</span><< tmpButon-><aclass="code"href="classewol_1_1_object.html#a61eacd4d36c9cb0d108c2dbcddbdd4dc">propertyName</a>.<aclass="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_property_type.html#aaf54e7f327af57ae5b735c4df8e92d1c">get</a>() <<<spanclass="stringliteral">"'"</span>);</div></div><!-- fragment --><h1><aclass="anchor"id="ewol_tutorial_object_model_remove"></a>
Remove an Object: </h1>
<p>Simply use the function: </p><divclass="fragment"><divclass="line">tmpButon-><aclass="code"href="classewol_1_1_object.html#a17820bb66bee9d140d0571f9f966f025">destroy</a>();</div></div><!-- fragment --><p>This function request his parrent to remove the <aclass="elRef"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">ememory::SharedPtr</a> it keep on it. And when all <aclass="elRef"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">ememory::SharedPtr</a> is removed the object will be really removed.</p>
<p>At his point we can think an object is alive all the time someone keep a reference on it, then when you are not a parrent of the object, do not keep a <aclass="elRef"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">ememory::SharedPtr</a> but a <aclass="elRef"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_weak_ptr.html">ememory::WeakPtr</a>.</p>
<p><b>Note:</b></p>
<divclass="fragment"><divclass="line">If some Object is not removed when you close the application, the system inform you with displaying all object alive.</div></div><!-- fragment --><h1><aclass="anchor"id="ewol_tutorial_object_model_find"></a>
Retrieve an Object: </h1>
<p>In Ewol this is possible to get a object with his name.</p>
<h2>Find a global Object (ouside an Object) </h2>
<divclass="fragment"><divclass="line"><spanclass="preprocessor">#include <<aclass="code"href="_context_8hpp.html">ewol/context/Context.hpp</a>></span></div><divclass="line"></div><divclass="line"><aclass="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">ewol::ObjectShared</a> tmpObject = <aclass="code"href="_context_8hpp.html#a32db0d1e16baf02f1edf72bebd3b90e0">ewol::getContext</a>().getEObjectManager().<aclass="code"href="classewol_1_1object_1_1_manager.html#ab22e6735a8dbac7c8f1323c18623f319">getObjectNamed</a>(<spanclass="stringliteral">"obj Name"</span>);</div><divclass="line"><spanclass="keywordflow">if</span> (tmpObject == <spanclass="keyword">nullptr</span>) {</div><divclass="line"> APPL_ERROR(<spanclass="stringliteral">"The Object does not exist"</span>);</div><divclass="line">}</div></div><!-- fragment --><h2>Find a global Object (inside an Object) </h2>
<divclass="fragment"><divclass="line"><aclass="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">ewol::ObjectShared</a> tmpObject = getObjectNamed(<spanclass="stringliteral">"obj Name"</span>);</div><divclass="line"><spanclass="keywordflow">if</span> (tmpObject == <spanclass="keyword">nullptr</span>) {</div><divclass="line"> APPL_ERROR(<spanclass="stringliteral">"The Object does not exist"</span>);</div><divclass="line">}</div></div><!-- fragment --><h2>Find a sub-object </h2>
<divclass="fragment"><divclass="line"><aclass="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">ewol::ObjectShared</a> tmpObject = getSubObjectNamed(<spanclass="stringliteral">"obj Name"</span>);</div><divclass="line"><spanclass="keywordflow">if</span> (tmpObject == NULL) {</div><divclass="line"> APPL_ERROR(<spanclass="stringliteral">"The Object does not exist"</span>);</div><divclass="line">}</div></div><!-- fragment --><h2>retriving your object type </h2>
<p>It could be really interesting to retrive your own instance:</p>
<divclass="fragment"><divclass="line"><aclass="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">ewol::ObjectShared</a> tmpObject ...;</div><divclass="line"></div><divclass="line">appl::MyOwnObjectShared myObject = std::dynamic_pointer_cast<appl::MyOwnObject>(tmpObject);</div></div><!-- fragment --></div></div><!-- contents -->