Sophie

Sophie

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

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: 5 minute Tutorial</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">5 minute Tutorial </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>This shortcut tutorial will show you all basic information to use RTTR.</p>
<h2>Class declaration </h2>
<p>Suppose you have a class called <code>node</code> which you want to introspect with RTTR. </p><div class="fragment"><div class="line"><span class="comment">// node.h</span></div><div class="line"><span class="preprocessor">#include &lt;rttr/type&gt;</span></div><div class="line"></div><div class="line"><span class="keyword">namespace </span>ns_3d</div><div class="line">{</div><div class="line"><span class="keyword">class </span>node</div><div class="line">{</div><div class="line"><span class="keyword">public</span>:</div><div class="line">    node(std::string name, node* parent = <span class="keyword">nullptr</span>);</div><div class="line">    <span class="keyword">virtual</span> ~node();</div><div class="line"></div><div class="line">    <span class="keywordtype">void</span> set_name(<span class="keyword">const</span> std::string&amp; name);</div><div class="line">    <span class="keyword">const</span> std::string&amp; get_name() <span class="keyword">const</span>;</div><div class="line"></div><div class="line">    std::vector&lt;node*&gt; get_children() <span class="keyword">const</span>;</div><div class="line">    </div><div class="line">    <span class="keywordtype">void</span> set_visible(<span class="keywordtype">bool</span> visible, <span class="keywordtype">bool</span> cascade = <span class="keyword">true</span>);</div><div class="line"></div><div class="line">    <span class="keyword">virtual</span> <span class="keywordtype">void</span> render();</div><div class="line"></div><div class="line"><span class="keyword">private</span>:</div><div class="line">    node*               m_parent;</div><div class="line">    std::string         m_name;</div><div class="line">    std::vector&lt;node*&gt;  m_children;</div><div class="line"></div><div class="line">    <a class="code" href="rttr__enable_8h.html#a848bcae21d3a54e07ca6450689820a59">RTTR_ENABLE</a>()</div><div class="line">    <a class="code" href="registration_8h.html#a307051b21da56e1ec8a63f0aa943797e">RTTR_REGISTRATION_FRIEND</a></div><div class="line">};</div><div class="line">}</div></div><!-- fragment --><p> The standard include file of rttr is: <code>&lt;rttr/type&gt;</code><br />
 Remark the two added macros: <a class="el" href="rttr__enable_8h.html#a848bcae21d3a54e07ca6450689820a59">RTTR_ENABLE()</a> and <a class="el" href="registration__friend_8h.html#a307051b21da56e1ec8a63f0aa943797e">RTTR_REGISTRATION_FRIEND</a>. They are optional.<br />
 However, when you use class hierarchies you should add to every class: <a class="el" href="rttr__enable_8h.html#a848bcae21d3a54e07ca6450689820a59">RTTR_ENABLE()</a>.<br />
 When you want to reflect private data of a class, add: <a class="el" href="registration__friend_8h.html#a307051b21da56e1ec8a63f0aa943797e">RTTR_REGISTRATION_FRIEND</a>.</p>
<h2>Registration </h2>
<p>Now comes the registration part, this is usually done in the corresponding source file.</p>
<div class="fragment"><div class="line"><span class="comment">// node.cpp</span></div><div class="line"><span class="preprocessor">#include &lt;rttr/registration&gt;</span></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">    <span class="keyword">using namespace </span>ns_3d;</div><div class="line">    </div><div class="line">    <a class="code" href="classrttr_1_1registration_1_1class__.html">registration::class_&lt;node&gt;</a>(<span class="stringliteral">&quot;ns_3d::node&quot;</span>)</div><div class="line">        .<a class="code" href="classrttr_1_1registration_1_1class__.html#a92925cd9adc8c53c6c2df6e5f7f86e8a">constructor</a>&lt;std::string, node*&gt;()</div><div class="line">        (</div><div class="line">            <a class="code" href="structrttr_1_1policy_1_1ctor.html#a40f2a2ef8f270cad3deabf1b83e8764c">policy::ctor::as_std_shared_ptr</a>, <span class="comment">// should create an instance of the class as shared_ptr&lt;ns_3d::node&gt;</span></div><div class="line">            <a class="code" href="namespacerttr.html#afdaed4515c436b34b8e24af714a09c64">default_arguments</a>(<span class="keyword">nullptr</span>)       <span class="comment">// second argument is optional, so we provide the default value for it</span></div><div class="line">        )</div><div class="line">        .<a class="code" href="classrttr_1_1property.html">property</a>(<span class="stringliteral">&quot;name&quot;</span>, &amp;node::get_name, &amp;node::set_name)</div><div class="line">        (</div><div class="line">            <a class="code" href="namespacerttr.html#a2cd2b848b4d218241a8b6e8f7cdbeb93">metadata</a>(<span class="stringliteral">&quot;TOOL_TIP&quot;</span>, <span class="stringliteral">&quot;Set the name of node.&quot;</span>)  <span class="comment">// stores metadata associated with this property</span></div><div class="line">        )</div><div class="line">        <span class="comment">// register directly a member object pointer; mark it as &#39;private&#39;</span></div><div class="line">        .<a class="code" href="classrttr_1_1property.html">property</a>(<span class="stringliteral">&quot;parent&quot;</span>, &amp;ns_3d::node::m_parent, <a class="code" href="classrttr_1_1registration.html#a8920352ec53e1cd44bdec18ef5e89568">registration::private_access</a>)</div><div class="line">        .property_readonly(<span class="stringliteral">&quot;children&quot;</span>, &amp;node::get_children) <span class="comment">// a read-only property; so not set possible</span></div><div class="line">        .method(<span class="stringliteral">&quot;set_visible&quot;</span>, &amp;node::set_visible)</div><div class="line">        (</div><div class="line">            <a class="code" href="namespacerttr.html#afdaed4515c436b34b8e24af714a09c64">default_arguments</a>(<span class="keyword">true</span>),              <span class="comment">// the default value for &#39;cascade&#39;</span></div><div class="line">            <a class="code" href="namespacerttr.html#ab708b3893cbd5a10e8782f3825052ea6">parameter_names</a>(<span class="stringliteral">&quot;visible&quot;</span>, <span class="stringliteral">&quot;cascade&quot;</span>) <span class="comment">// provide the names of the parameter; optional, but might be useful for clients</span></div><div class="line">        )</div><div class="line">        .<a class="code" href="classrttr_1_1method.html">method</a>(<span class="stringliteral">&quot;render&quot;</span>, &amp;node::render)</div><div class="line">        ;</div><div class="line">}</div></div><!-- fragment --><p> The standard include file for registration types in rttr is: <code>&lt;rttr/registration&gt;</code><br />
Include this file only when you want to register something. The <a class="el" href="classrttr_1_1registration.html">registration</a> class is here the entry point. This registration process creates internally wrapper classes, which store for example function pointers or object pointers of the specific class. For these pointers you have to provide the data manually.</p>
<p>Yeah, and that's it. Now you can use RTTR to retrieve this information.</p>
<h2>Basic usage </h2>
<div class="fragment"><div class="line"><span class="preprocessor">#include &lt;rttr/type&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;iostream&gt;</span></div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])</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"></div><div class="line">    <a class="code" href="classrttr_1_1type.html">type</a> t = <a class="code" href="classrttr_1_1type.html#a7ba79b9f4916c30db74fe65508dca033">type::get_by_name</a>(<span class="stringliteral">&quot;ns_3d::node&quot;</span>);</div><div class="line">    <span class="comment">// will create an instance of ns_3d::node as std::shared_ptr&lt;ns_3d::node&gt;</span></div><div class="line">    <a class="code" href="classrttr_1_1variant.html">variant</a> var = t.<a class="code" href="classrttr_1_1type.html#ad44572a03514d83035580f516ebaf4e1">create</a>({std::string(<span class="stringliteral">&quot;MyNode&quot;</span>)});</div><div class="line">    std::cout &lt;&lt; var.<a class="code" href="classrttr_1_1variant.html#a7a72579286ed164225c5be882ab6ea81">get_type</a>().<a class="code" href="classrttr_1_1type.html#a16d519457c68429ef2316067d1cf6700">get_name</a>() &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div><div class="line"></div><div class="line">    <span class="comment">// sets/gets a property</span></div><div class="line">    <span class="keyword">property</span> prop = t.<a class="code" href="classrttr_1_1type.html#ae53c4df812c270f3f74b77210bc6a926">get_property</a>(<span class="stringliteral">&quot;name&quot;</span>);</div><div class="line">    <span class="comment">// remark: you can also set a member, although the instance is of type: &#39;std::shared_ptr&lt;T&gt;&#39;</span></div><div class="line">    prop.<a class="code" href="classrttr_1_1property.html#a1bb74b1d1910edf6cabec250df8da021">set_value</a>(var, std::string(<span class="stringliteral">&quot;A New Name&quot;</span>));</div><div class="line">    std::cout &lt;&lt; prop.get_value(var).to_string() &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div><div class="line">    <span class="comment">// retrieve the stored meta data of the property</span></div><div class="line">    std::cout &lt;&lt; <span class="stringliteral">&quot;MetaData TOOL_TIP: &quot;</span> &lt;&lt; prop.get_metadata(<span class="stringliteral">&quot;TOOL_TIP&quot;</span>).to_string() &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div><div class="line"></div><div class="line">    <span class="comment">// invoke a method</span></div><div class="line">    <a class="code" href="classrttr_1_1method.html">method</a> meth = t.<a class="code" href="classrttr_1_1type.html#a4d31b84c050f5b22509c16d0379fe0c7">get_method</a>(<span class="stringliteral">&quot;set_visible&quot;</span>);</div><div class="line">    <span class="comment">// remark: the 2nd argument will be provided automatically, because it has a default argument</span></div><div class="line">    <a class="code" href="classrttr_1_1variant.html">variant</a> ret = meth.<a class="code" href="classrttr_1_1method.html#aea4351075b4cbe6f2f2b6500cf226f20">invoke</a>(var, <span class="keyword">true</span>);</div><div class="line">    <span class="comment">// a valid return value indicates a successful invoke</span></div><div class="line">    std::cout &lt;&lt; std::boolalpha &lt;&lt; <span class="stringliteral">&quot;invoke of method &#39;set_visible&#39; was successfully: &quot;</span> &lt;&lt; ret.<a class="code" href="classrttr_1_1variant.html#aed6e6a2e29b4d1ac51a09b7d9037dd44">is_valid</a>() &lt;&lt; <span class="stringliteral">&quot;\n\n&quot;</span>;</div><div class="line"></div><div class="line">    <span class="comment">// retrieve all properties</span></div><div class="line">    std::cout &lt;&lt; <span class="stringliteral">&quot;&#39;node&#39; properties:&quot;</span> &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div><div class="line">    <span class="keywordflow">for</span> (<span class="keyword">auto</span>&amp; prop : t.<a class="code" href="classrttr_1_1type.html#af4d2837c650a639b9aab9bd6e580dc8a">get_properties</a>())</div><div class="line">    {</div><div class="line">        std::cout &lt;&lt; <span class="stringliteral">&quot;  name: &quot;</span> &lt;&lt; prop.get_name() &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div><div class="line">        std::cout &lt;&lt; <span class="stringliteral">&quot;    type: &quot;</span> &lt;&lt; prop.get_type().get_name() &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div><div class="line">    }</div><div class="line">    std::cout &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div><div class="line">    <span class="comment">// retrieve all methods</span></div><div class="line">    std::cout &lt;&lt; <span class="stringliteral">&quot;&#39;node&#39; methods:&quot;</span> &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div><div class="line">    <span class="keywordflow">for</span> (<span class="keyword">auto</span>&amp; meth : t.<a class="code" href="classrttr_1_1type.html#a67ffced2826ff08f2a761acbeb133ae9">get_methods</a>())</div><div class="line">    {</div><div class="line">        std::cout &lt;&lt; <span class="stringliteral">&quot;  name: &quot;</span> &lt;&lt; meth.<a class="code" href="classrttr_1_1method.html#a4175378b2b01539f7803462685229421">get_name</a>();</div><div class="line">        std::cout &lt;&lt; <span class="stringliteral">&quot;  signature: &quot;</span> &lt;&lt; meth.<a class="code" href="classrttr_1_1method.html#a76c25c087fd4398a164b5ecdc8657828">get_signature</a>() &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div><div class="line">        <span class="keywordflow">for</span> (<span class="keyword">auto</span>&amp; info : meth.<a class="code" href="classrttr_1_1method.html#a5e28213d7e723f90a601029e5e06041b">get_parameter_infos</a>())</div><div class="line">        {</div><div class="line">            std::cout &lt;&lt; <span class="stringliteral">&quot;    param &quot;</span> &lt;&lt; info.get_index() &lt;&lt; <span class="stringliteral">&quot;: name: &quot;</span>&lt;&lt; info.get_name() &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div><div class="line">        }</div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="keywordflow">return</span> 0;</div><div class="line">}</div></div><!-- fragment --><p> Remark, that there is actual no include of <code>node.h</code>. See the output below: </p><h3>Output</h3>
<pre class="fragment">class std::shared_ptr&lt;class ns_3d::node&gt;
A New Name
MetaData TOOL_TIP: Set the name of node.
invoke of method 'set_visible' was successfully: true

'node' properties:
  name: name
    type: std::string
  name: parent
    type: ns_3d::node*
  name: children
    type: class std::vector&lt;class ns_3d::node *,class std::allocator&lt;class ns_3d::node *&gt; &gt;

'node' methods:
  name: set_visible  signature: set_visible( bool, bool )
    param 0: name: visible
    param 1: name: cascade
  name: render  signature: render( )
</pre><h2>Derived classes </h2>
<p>Suppose you create now from <code>node</code> a derived class called <code>mesh</code>. </p><div class="fragment"><div class="line"><span class="comment">// mesh.h</span></div><div class="line"><span class="preprocessor">#include &lt;rttr/type&gt;</span></div><div class="line"></div><div class="line"><span class="keyword">class </span>mesh : <span class="keyword">public</span> node</div><div class="line">{</div><div class="line"><span class="keyword">public</span>:</div><div class="line">    <span class="keyword">static</span> std::shared_ptr&lt;mesh&gt; create_mesh(std::string file_name);</div><div class="line"></div><div class="line">    <span class="keyword">virtual</span> <span class="keywordtype">void</span> render();</div><div class="line"></div><div class="line">    <span class="keyword">enum class</span> render_mode</div><div class="line">    {</div><div class="line">        POINTS,</div><div class="line">        WIREFRAME,</div><div class="line">        SOLID</div><div class="line">    };</div><div class="line"></div><div class="line">    <span class="keywordtype">void</span> set_render_mode(render_mode mode);</div><div class="line">    render_mode get_render_mode() <span class="keyword">const</span>;</div><div class="line"></div><div class="line"><span class="keyword">private</span>:</div><div class="line">    mesh(std::string name, node* parent = <span class="keyword">nullptr</span>);</div><div class="line"></div><div class="line">    <a class="code" href="rttr__enable_8h.html#a848bcae21d3a54e07ca6450689820a59">RTTR_ENABLE</a>(node) <span class="comment">// include the names of all direct base classes</span></div><div class="line">};</div></div><!-- fragment --><p> Now you put in <a class="el" href="rttr__enable_8h.html#a848bcae21d3a54e07ca6450689820a59">RTTR_ENABLE()</a> the name of the base class, in this case: <code>node</code>.</p>
<h2>Registration part </h2>
<div class="fragment"><div class="line"><span class="comment">// mesh.cpp</span></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>ns_3d;</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_1_1class__.html">registration::class_&lt;mesh&gt;</a>(<span class="stringliteral">&quot;ns_3d::mesh&quot;</span>)</div><div class="line">        .<a class="code" href="classrttr_1_1registration_1_1class__.html#a92925cd9adc8c53c6c2df6e5f7f86e8a">constructor</a>(&amp;mesh::create_mesh)</div><div class="line">        .property(<span class="stringliteral">&quot;render_mode&quot;</span>, &amp;mesh::get_render_mode, &amp;mesh::set_render_mode)</div><div class="line">        .enumeration&lt;mesh::render_mode&gt;(<span class="stringliteral">&quot;ns_3d::render_mode&quot;</span>)</div><div class="line">        (</div><div class="line">            <a class="code" href="namespacerttr.html#a54ecd8bad715cbc451e7aa8491667d4a">value</a>(<span class="stringliteral">&quot;POINTS&quot;</span>,     mesh::render_mode::POINTS),</div><div class="line">            <a class="code" href="namespacerttr.html#a54ecd8bad715cbc451e7aa8491667d4a">value</a>(<span class="stringliteral">&quot;WIREFRAME&quot;</span>,  mesh::render_mode::WIREFRAME),</div><div class="line">            <a class="code" href="namespacerttr.html#a54ecd8bad715cbc451e7aa8491667d4a">value</a>(<span class="stringliteral">&quot;SOLID&quot;</span>,      mesh::render_mode::SOLID)</div><div class="line">        );</div><div class="line">}</div></div><!-- fragment --><p> Remark that it is not necessary to register again the <code>render()</code> method.</p>
<h2>Basic Usage </h2>
<div class="fragment"><div class="line"><span class="preprocessor">#include &lt;rttr/type&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;iostream&gt;</span></div><div class="line"><span class="preprocessor">#include &quot;mesh.h&quot;</span></div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])</div><div class="line">{</div><div class="line">    std::shared_ptr&lt;ns_3d::node&gt; obj = ns_3d::mesh::create_mesh(<span class="stringliteral">&quot;House.obj&quot;</span>);</div><div class="line">    </div><div class="line">    std::cout &lt;&lt; type::get(obj).get_name() &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;                     <span class="comment">// prints &#39;std::shared_ptr&lt;ns_3d::node&gt;&#39;</span></div><div class="line">    std::cout &lt;&lt; type::get(obj).get_wrapped_type().get_name() &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;  <span class="comment">// prints &#39;ns_3d::node*&#39;</span></div><div class="line">    std::cout &lt;&lt; type::get(*obj.get()).get_name() &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;              <span class="comment">// prints &#39;ns_3d::mesh&#39;</span></div><div class="line"></div><div class="line">    <span class="comment">// for glvalue expressions the most derived type is returned, in this case: &#39;ns_3d::mesh&#39;; like typeid()</span></div><div class="line">    type t = type::get(*obj.get());</div><div class="line">    </div><div class="line">    std::cout &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div><div class="line"></div><div class="line">    std::cout &lt;&lt; <span class="stringliteral">&quot;&#39;mesh&#39; properties:&quot;</span> &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div><div class="line">    <span class="keywordflow">for</span> (<span class="keyword">auto</span>&amp; prop : t.get_properties())</div><div class="line">    {</div><div class="line">        std::cout &lt;&lt; <span class="stringliteral">&quot;  name: &quot;</span> &lt;&lt; prop.<a class="code" href="classrttr_1_1type.html#a16d519457c68429ef2316067d1cf6700">get_name</a>() &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div><div class="line">        std::cout &lt;&lt; <span class="stringliteral">&quot;    type: &quot;</span> &lt;&lt; prop.get_type().get_name() &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div><div class="line">    }</div><div class="line">    </div><div class="line">    <span class="keyword">property</span> prop = t.get_property(<span class="stringliteral">&quot;render_mode&quot;</span>);</div><div class="line">    <span class="comment">// set the property of the derived type, although we hold only a shared_ptr of the base class</span></div><div class="line">    <span class="keywordtype">bool</span> ret = prop.set_value(obj, ns_3d::mesh::render_mode::SOLID); <span class="comment">// yields to &#39;true&#39;; when set was possible</span></div><div class="line"></div><div class="line">    std::cout &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div><div class="line"></div><div class="line">    method meth = t.get_method(<span class="stringliteral">&quot;render&quot;</span>);</div><div class="line">    std::cout &lt;&lt; meth.<a class="code" href="classrttr_1_1method.html#a745efaefdfb89779773cccce3919379d">get_declaring_type</a>(). get_name() &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>; <span class="comment">// prints &#39;ns_3d::node&#39;</span></div><div class="line"></div><div class="line">    std::shared_ptr&lt;ns_3d::mesh&gt; obj_derived = std::dynamic_pointer_cast&lt;ns_3d::mesh&gt;(obj);</div><div class="line">    <span class="comment">// invoke the method, although we have the most derived type now</span></div><div class="line">    variant var = meth.invoke(obj_derived);</div><div class="line">    std::cout &lt;&lt; std::boolalpha &lt;&lt; <span class="stringliteral">&quot;invoke of method &#39;render&#39; was successfully: &quot;</span> &lt;&lt; var.<a class="code" href="classrttr_1_1variant.html#aed6e6a2e29b4d1ac51a09b7d9037dd44">is_valid</a>() &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div><div class="line">}</div></div><!-- fragment --><p>See the output below: </p><h3>Output</h3>
<pre class="fragment">class std::shared_ptr&lt;class ns_3d::node&gt;
ns_3d::node*
ns_3d::mesh

'mesh' properties:
  name: name
    type: std::string
  name: parent
    type: ns_3d::node*
  name: children
    type: class std::vector&lt;class ns_3d::node *,class std::allocator&lt;class ns_3d::node *&gt; &gt;
  name: render_mode
    type: ns_3d::render_mode

ns_3d::node
invoke of method 'render' was successfully: true
</pre><p>That's it.</p>
<p>However, in order to see all the possibilities of RTTR, it is recommend to go through the in-depth tutorial: <a class="el" href="rttr_type_get_page.html">Start Tutorial</a></p>
<hr/>
<div class="btn btn-default doxy-button"><a class="el" href="tutorial_page.html">back</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>