Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-release > by-pkgid > d8d30ad953f2dbe7e871721325480315 > files > 362

librttr-devel-0.9.6-1.mga7.armv7hl.rpm

<!-- 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.15"/>
        <script type="text/javascript" src="jquery.min.js"></script>
        <title>rttr: Properties</title>
        <!--<link href="tabs.css" rel="stylesheet" type="text/css"/>-->
        <script type="text/javascript" src="dynsections.js"></script>
        <link rel = "shortcut icon" type = "image/x-icon" href = "favicon.ico">
        <link rel = "stylesheet" href = "fonts/ptsans_regular_macroman/stylesheet.css">
        <link rel = "stylesheet" href = "fonts/source_code_pro_regular/stylesheet.css">
        <link href="doxygen.css" rel="stylesheet" type="text/css" />
        <link href="custom-doxygen.css" rel="stylesheet" type="text/css"/>
        <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
        <link rel="stylesheet" href="custom-bootstrap.css">
        <script src="bootstrap/js/bootstrap.min.js"></script>
        <script type="text/javascript" src="doxy-boot.js"></script>
    </head>
    <body>
     <!--
        <nav class="navbar navbar-default" role="navigation">
            <div class="container">
                <div class="navbar-header">
                    <a class="navbar-brand">rttr 0.9.6</a>
                </div>
            </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;">
<!-- end header part -->
<!-- Generated by Doxygen 1.8.15 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',false,false,'search.php','Search');
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div class="PageDoc"><div class="header">
  <div class="headertitle">
<div class="title">Properties </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>For registration of a property to RTTR you can use following functions: <a class="el" href="classrttr_1_1registration.html#a3331d6ccc45422da21e36937edcce4e0">registration::property()</a> and <a class="el" href="classrttr_1_1registration.html#a8d3550e713fe724b02528dbc08b5fcbc">registration::property_readonly()</a>.</p>
<p>They have following synopsis: </p><div class="fragment"><div class="line"><span class="keyword">template</span>&lt;<span class="keyword">typename</span> A&gt;</div><div class="line">registration <a class="code" href="classrttr_1_1registration.html#a3331d6ccc45422da21e36937edcce4e0">rttr::registration::property</a>( <a class="code" href="namespacerttr.html#a61265f69675ac438ecfa23b084adaa56">string_view</a> name, A accessor );</div><div class="line"></div><div class="line"><span class="keyword">template</span>&lt;<span class="keyword">typename</span> A&gt;</div><div class="line">registration <a class="code" href="classrttr_1_1registration.html#a8d3550e713fe724b02528dbc08b5fcbc">rttr::registration::property_readonly</a>(<a class="code" href="namespacerttr.html#a61265f69675ac438ecfa23b084adaa56">string_view</a> name, A accessor);</div></div><!-- fragment --><ul>
<li><code>name</code> is the name of the property</li>
<li><code>A</code> is the pointer to the property</li>
</ul>
<p>It is also possible to use function pointers for the property as getter and setter functions. Therefore the <a class="el" href="classrttr_1_1registration.html#a8e6d6936540f3d650292f2bb40e9b9d8">property()</a> function is overloaded.</p>
<p>It has following synopsis: </p><div class="fragment"><div class="line"><span class="keyword">template</span>&lt;<span class="keyword">typename</span> A1, <span class="keyword">typename</span> A2&gt;</div><div class="line">registration <a class="code" href="classrttr_1_1registration.html#a3331d6ccc45422da21e36937edcce4e0">rttr::registration::property</a>( <a class="code" href="namespacerttr.html#a61265f69675ac438ecfa23b084adaa56">string_view</a> name, A1 getter, A2 setter );</div></div><!-- fragment --><ul>
<li><code>name</code> is the name of the property</li>
<li><code>A1</code> is the function pointer to the getter and A2 is the function pointer to the setter of the property</li>
</ul>
<p>The following example shows how to use these register functions: </p><div class="fragment"><div class="line"><span class="preprocessor">#include &lt;rttr/registration&gt;</span></div><div class="line"><span class="keyword">using namespace </span><a class="code" href="namespacerttr.html">rttr</a>;</div><div class="line"></div><div class="line"><span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">double</span> pi = 3.14259;</div><div class="line"><span class="keyword">static</span> std::string global_text;</div><div class="line"><span class="keywordtype">void</span> set_text(<span class="keyword">const</span> std::string&amp; text) { global_text = text; }</div><div class="line"><span class="keyword">const</span> std::string&amp; get_text() { <span class="keywordflow">return</span> global_text; }</div><div class="line"></div><div class="line"><a class="code" href="registration_8h.html#ac6326400f16225ee15b52eabcaae8130">RTTR_REGISTRATION</a></div><div class="line">{</div><div class="line">    <span class="keyword">using namespace </span><a class="code" href="namespacerttr.html">rttr</a>;</div><div class="line">    <a class="code" href="classrttr_1_1registration.html#a8d3550e713fe724b02528dbc08b5fcbc">registration::property_readonly</a>(<span class="stringliteral">&quot;PI&quot;</span>, &amp;pi);</div><div class="line">    <a class="code" href="classrttr_1_1registration.html#a3331d6ccc45422da21e36937edcce4e0">registration::property</a>(<span class="stringliteral">&quot;global_text&quot;</span>, &amp;get_text, &amp;set_text);</div><div class="line">}</div></div><!-- fragment --><p>There can be not two global properties with the same name. The later registered property with an already existing name will be discarded.</p>
<h2>Invoke properties </h2>
<p>For setting and getting a property you have two options like with methods:</p><ul>
<li>calling <a class="el" href="classrttr_1_1type.html#a0748930ab0ca3b8254f1bf85322f3612">type::set_property_value()</a> and <a class="el" href="classrttr_1_1type.html#a148b6cb7890fcd53b7d6559a2fb610fe">type::get_property_value()</a> from the <a class="el" href="classrttr_1_1type.html">type</a> class or</li>
<li>retrieving a <a class="el" href="classrttr_1_1property.html">property</a> object from <a class="el" href="classrttr_1_1type.html#a9b754b6b0cccc39632323e3ee37f778e">type::get_global_property()</a> and then calling <a class="el" href="classrttr_1_1property.html#a1bb74b1d1910edf6cabec250df8da021">property::set_value()</a> and <a class="el" href="classrttr_1_1property.html#a324d3c3065ebe9db99c3962a9fe0a41b">property::get_value()</a></li>
</ul>
<div class="fragment"><div class="line"><span class="keyword">using namespace </span><a class="code" href="namespacerttr.html">rttr</a>;</div><div class="line"><span class="keywordtype">int</span> main()</div><div class="line">{</div><div class="line">    <span class="comment">// option 1, via type</span></div><div class="line">    <a class="code" href="classrttr_1_1variant.html">variant</a> <a class="code" href="namespacerttr.html#a54ecd8bad715cbc451e7aa8491667d4a">value</a> = <a class="code" href="classrttr_1_1type.html#a3010aa9577570ea86078b2ce2b2f8677">type::get_property_value</a>(<span class="stringliteral">&quot;PI&quot;</span>); <span class="comment">// remark the capitalization of &quot;PI&quot;</span></div><div class="line">    <span class="keywordflow">if</span> (<a class="code" href="namespacerttr.html#a54ecd8bad715cbc451e7aa8491667d4a">value</a> &amp;&amp; <a class="code" href="namespacerttr.html#a54ecd8bad715cbc451e7aa8491667d4a">value</a>.is_type&lt;<span class="keywordtype">double</span>&gt;())</div><div class="line">        std::cout &lt;&lt; <a class="code" href="namespacerttr.html#a54ecd8bad715cbc451e7aa8491667d4a">value</a>.get_value&lt;<span class="keywordtype">double</span>&gt;() &lt;&lt; std::endl; <span class="comment">// outputs: &quot;3.14259&quot;</span></div><div class="line">    <span class="comment">// option 2, via property class</span></div><div class="line">    <span class="keyword">property</span> prop = <a class="code" href="classrttr_1_1type.html#a9b754b6b0cccc39632323e3ee37f778e">type::get_global_property</a>(<span class="stringliteral">&quot;PI&quot;</span>);</div><div class="line">    <span class="keywordflow">if</span> (prop)</div><div class="line">    {</div><div class="line">        <a class="code" href="namespacerttr.html#a54ecd8bad715cbc451e7aa8491667d4a">value</a> = prop.get_value(<a class="code" href="classrttr_1_1instance.html">instance</a>());</div><div class="line">        <span class="keywordflow">if</span> (<a class="code" href="namespacerttr.html#a54ecd8bad715cbc451e7aa8491667d4a">value</a>.is_valid() &amp;&amp; <a class="code" href="namespacerttr.html#a54ecd8bad715cbc451e7aa8491667d4a">value</a>.is_type&lt;<span class="keywordtype">double</span>&gt;())</div><div class="line">            std::cout &lt;&lt; <a class="code" href="namespacerttr.html#a54ecd8bad715cbc451e7aa8491667d4a">value</a>.get_value&lt;<span class="keywordtype">double</span>&gt;() &lt;&lt; std::endl; <span class="comment">// outputs: &quot;3.14259&quot;</span></div><div class="line">    }</div><div class="line">}</div></div><!-- fragment --><p>The static <a class="el" href="classrttr_1_1type.html#a0748930ab0ca3b8254f1bf85322f3612">type::set_property_value()</a> function calls directly a global property with the given name. This function has a bool value as return value, indicating whether the property was invoked or not. For retrieving a property value use the static function <a class="el" href="classrttr_1_1type.html#a148b6cb7890fcd53b7d6559a2fb610fe">type::get_property_value()</a>. The returned <a class="el" href="classrttr_1_1variant.html">variant</a> object contains the property value and also indicates whether the call to retrieve the property was successful or not. When the variant is <a class="el" href="classrttr_1_1variant.html#aed6e6a2e29b4d1ac51a09b7d9037dd44">not valid</a> then the call could not be done.</p>
<p>Another option is to retrieve a handle to the property via <a class="el" href="classrttr_1_1type.html#a9b754b6b0cccc39632323e3ee37f778e">type::get_global_property()</a>. This is the preferred option, because then you directly set/get the value without searching every time for the property. The property object is very lightweight and can be simply copied around different locations. The object stays valid till end of the <code>main()</code> function.</p>
<hr/>
<div type="button" class="btn btn-default doxy-button"><a class="el" href="register_methods_page.html">previous</a></div><div class="btn btn-default doxy-button"><a class="el" href="register_enums_page.html">next</a></div> </div></div><!-- PageDoc -->
</div><!-- contents -->
<!-- HTML footer for doxygen 1.8.9.1-->
<!-- start footer part -->
<hr class="footer"/>
<address class="footer">
<small>
Generated on Thu Apr 11 2019 20:05:57 for rttr - 0.9.6 by 
<a href="http://www.doxygen.org/index.html">doxygen</a>.
</small>
</address>
</body>
</html>