--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\r
+<head>\r
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />\r
+ <meta http-equiv="X-UA-Compatible" content="IE=9" />\r
+ <link rel="stylesheet" type="text/css" href="../../css/styles.css" />\r
+ <link rel="stylesheet" type="text/css" href="../../css/snippet.css" />\r
+ <script type="text/javascript" src="../../scripts/snippet.js"></script> \r
+ <script type="text/javascript" src="../../scripts/jquery.util.js" charset="utf-8"></script>\r
+ <script type="text/javascript" src="../../scripts/common.js" charset="utf-8"></script>\r
+ <script type="text/javascript" src="../../scripts/core.js" charset="utf-8"></script>\r
+ <script type="text/javascript" src="../../scripts/search.js" charset="utf-8"></script>\r
+\r
+ <title>Background Knowledge: Using DALi More Effectively</title> \r
+</head>\r
+\r
+<body onload="prettyPrint()" style="overflow: auto;">\r
+\r
+<div id="toc-navigation">\r
+ <div id="profile">\r
+ <p><img alt="Mobile native" src="../../images/mn_icon.png"/> <img alt="Wearable native" src="../../images/wn_icon.png"/></p>\r
+ </div>\r
+ <div id="toc_border"><div id="toc">\r
+ <p class="toc-title">Content</p>\r
+ <ul class="toc">\r
+ <li><a href="#handle">Handle/Body Pattern</a></li>\r
+ <li><a href="#property">Properties</a></li>\r
+ <li><a href="#thread">DALi Thread Model</a></li>\r
+ </ul>\r
+ <p class="toc-title">Related Info</p>\r
+ <ul class="toc">\r
+ <li><a href="../../../../org.tizen.native.mobile.apireference/classDali_1_1Actor.html">Dali::Actor API for Mobile Native</a></li>\r
+ <li><a href="../../../../org.tizen.native.mobile.apireference/classDali_1_1Stage.html">Dali::Stage API for Mobile Native</a></li>\r
+ <li><a href="../../../../org.tizen.native.wearable.apireference/classDali_1_1Actor.html">Dali::Actor API for Wearable Native</a></li>\r
+ <li><a href="../../../../org.tizen.native.wearable.apireference/classDali_1_1Stage.html">Dali::Stage API for Wearable Native</a></li> \r
+ </ul>\r
+ </div></div>\r
+</div> \r
+\r
+<div id="container"><div id="contents"><div class="content">\r
+<h1>Background Knowledge: Using DALi More Effectively</h1>\r
+\r
+<p>This section describes useful background knowledge that enables you to use DALi more effectively.\r
+\r
+<h2 id="handle" name="handle">Handle/Body Pattern</h2>\r
+\r
+<p>DALi widely adopts the handle/body pattern (a.k.a. pimpl pattern) which seperates implementation details (the body class) from its interface (the handle class). In DALi, <span style="font-family: Courier New,Courier,monospace;">Dali::Handle</span> represents the interface part and hides internal implementation classes. It additionally provides smart-pointer semantics which manages internal objects with reference counts.\r
+</p>\r
+\r
+<p>This structure is benificial for both users and developers of DALi:</p>\r
+<ul>\r
+ <li><strong>Easier memory management</strong>\r
+ <p>Each internal <span style="font-family: Courier New,Courier,monospace;">Dali::Object</span> class (the body class) contains a single reference count object which can be intitialized with the static "New" methods in the DALi public API. This means that C++ new/delete operators do not have to be used in the user code.</p>\r
+ </li>\r
+ <li><strong>Better encapsulation</strong>\r
+ <p>The danger of API/ABI breaks is reduced since the implementation of a class can be changed without modifying the public API, thus without recompiling code using the public API. This also can reduce the build time.</p>\r
+ </li>\r
+</ul>\r
+\r
+<h3 id="usage" name="usage">Guide for Handles</h2>\r
+\r
+<ul>\r
+\r
+<li> No need to call destructors\r
+<pre class="prettyprint">\r
+class HandleTest\r
+{\r
+ HandleTest()\r
+ {\r
+ mActor = Actor::New();\r
+ }\r
+\r
+ ~HandleTest() {} // Actor object is destroyed automatically\r
+\r
+ Actor mActor;\r
+};\r
+</pre>\r
+</li>\r
+\r
+<li> Can be stored in STL containers\r
+<pre class="prettyprint">\r
+class HandleTest\r
+{\r
+ HandleTest()\r
+ {\r
+ mActors.push_back( Actor::New() );\r
+ mActors.push_back( Actor::New() );\r
+ ...\r
+ }\r
+\r
+ ~HandleTest() {} // Actors are destroyed automatically\r
+\r
+ std::vector<Actor> mActors;\r
+};\r
+</pre>\r
+</li>\r
+\r
+<li> Passing by value is encouraged\r
+<pre class="prettyprint">\r
+void SomeFunction( Actor actor )\r
+{\r
+ if( actor )\r
+ {\r
+ actor.SomeMethod();\r
+ }\r
+}\r
+</pre>\r
+</li>\r
+\r
+<li> Validity check\r
+<pre class="prettyprint">\r
+{\r
+ ...\r
+ Actor actor; // Create a NULL object\r
+\r
+ // At this stage we cannot call any of the Actor methods\r
+ if( !actor ) // This test is will pass, since the actor is NULL\r
+ {\r
+ actor = Actor::New();\r
+ ...\r
+ }\r
+ ...\r
+}\r
+</pre>\r
+</li>\r
+\r
+<li> Equality operators\r
+<pre class="prettyprint">\r
+{\r
+ Actor handle1;\r
+ Actor handle2;\r
+ cout << handle1 == handle2 << endl; // "true", both handles are empty\r
+\r
+ handle2 = Actor::New();\r
+ cout << handle1 == handle2 << endl; // "false", one handle is empty\r
+\r
+ handle1 = Actor::New();\r
+ cout << handle1 == handle2 << endl; // "false", handles to different objects\r
+\r
+ handle1 = handle2;\r
+ cout << handle1 == handle2 << endl; // "true", handles to same object\r
+}\r
+</pre>\r
+</li>\r
+\r
+<li> Reference counting examples\r
+<pre class="prettyprint">\r
+class AnimationTest\r
+{\r
+...\r
+private:\r
+ Animation mAnimation; // animation handle\r
+};\r
+void AnimationTest::Initialize ()\r
+{\r
+ mAnimation = Animation::New( 10.0f ); // reference count will be 1, animation object stays alive when method returns\r
+ ...\r
+}\r
+void AnimationTest::SetAnimation( Animation anim )\r
+{\r
+ mAnimation = anim; // reference count of original animation decreased, 'anim' is referenced instead\r
+ // if nobody else had a reference on the initial animation, the object is destroyed\r
+}\r
+</pre>\r
+\r
+<pre class="prettyprint">\r
+// At this point we own a Dali::Actor named "container"\r
+// Enter a code block\r
+{\r
+ // Create an text label\r
+ TextLabel actor = TextLabel::New("test");\r
+ // Add the text label to a container\r
+ container.Add(actor);\r
+}\r
+// Exit the code block\r
+// At this stage the text label is still alive\r
+// We don't keep the handle to the text label, but it can be retrieved from the container\r
+</pre>\r
+\r
+</ul>\r
+\r
+\r
+ \r
+<script type="text/javascript" src="../../scripts/jquery.zclip.min.js"></script>\r
+<script type="text/javascript" src="../../scripts/showhide.js"></script>\r
+</div></div></div>\r
+\r
+<a class="top sms" href="#"><img src="../../images/btn_top.gif" alt="Go to top" /></a>\r
+\r
+<div id="footer">\r
+<p class="footer">Except as noted, this content - excluding the Code Examples - is licensed under <a href="http://creativecommons.org/licenses/by/3.0/legalcode" target="_blank">Creative Commons Attribution 3.0</a> and all of the Code Examples contained herein are licensed under <a href="https://www.tizen.org/bsd-3-clause-license" target="_blank">BSD-3-Clause</a>.<br/>For details, see the <a href="https://www.tizen.org/content-license" target="_blank">Content License</a>.</p>\r
+</div>\r
+\r
+<script type="text/javascript">\r
+var _gaq = _gaq || [];\r
+_gaq.push(['_setAccount', 'UA-25976949-1']);\r
+_gaq.push(['_trackPageview']);\r
+(function() {\r
+var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\r
+ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\r
+var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\r
+})();\r
+</script>\r
+\r
+</body>\r
+</html>\r
+\r