<html>
<head>
<title>OGRE: OgreProperty.h File Reference - OGRE Documentation</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
<link type="text/css" rel="stylesheet" href="doxygen.css">
<link type="text/css" rel="stylesheet" href="tabs.css">
</head>

<body>
<!-- Generated by Doxygen 1.6.2 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
  <div class="navpath"><a class="el" href="dir_0b8281b69943ad565aee8137b1bafaf9.html">Components</a>&nbsp;&raquo;&nbsp;<a class="el" href="dir_2ea5e14f44ca0532a19372d0108d4e30.html">Property</a>&nbsp;&raquo;&nbsp;<a class="el" href="dir_d0b811453e63f36c97352e3f2c575189.html">include</a>
  </div>
</div>
<div class="contents">
<h1>OgreProperty.h File Reference</h1>
<p>OGRE's property system allows you to associate values of arbitrary type with names, and have those values exposed via a self-describing interface.  
<a href="#_details">More...</a></p>
<code>#include &quot;<a class="el" href="OgrePropertyPrerequisites_8h_source.html">OgrePropertyPrerequisites.h</a>&quot;</code><br/>
<code>#include &quot;<a class="el" href="OgreAny_8h_source.html">OgreAny.h</a>&quot;</code><br/>
<code>#include &quot;<a class="el" href="OgreIteratorWrappers_8h_source.html">OgreIteratorWrappers.h</a>&quot;</code><br/>
<code>#include &quot;<a class="el" href="OgreString_8h_source.html">OgreString.h</a>&quot;</code><br/>
<code>#include &quot;<a class="el" href="OgreException_8h_source.html">OgreException.h</a>&quot;</code><br/>
<code>#include &quot;<a class="el" href="OgreVector2_8h_source.html">OgreVector2.h</a>&quot;</code><br/>
<code>#include &quot;<a class="el" href="OgreVector3_8h_source.html">OgreVector3.h</a>&quot;</code><br/>
<code>#include &quot;<a class="el" href="OgreVector4_8h_source.html">OgreVector4.h</a>&quot;</code><br/>
<code>#include &quot;<a class="el" href="OgreColourValue_8h_source.html">OgreColourValue.h</a>&quot;</code><br/>
<code>#include &quot;<a class="el" href="OgreQuaternion_8h_source.html">OgreQuaternion.h</a>&quot;</code><br/>
<code>#include &quot;<a class="el" href="OgreMatrix3_8h_source.html">OgreMatrix3.h</a>&quot;</code><br/>
<code>#include &quot;<a class="el" href="OgreMatrix4_8h_source.html">OgreMatrix4.h</a>&quot;</code><br/>
<code>#include &lt;boost/bind.hpp&gt;</code><br/>
<code>#include &lt;boost/function.hpp&gt;</code><br/>

<p><a href="OgreProperty_8h_source.html">Go to the source code of this file.</a></p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td colspan="2"><h2>Classes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">class &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classOgre_1_1PropertyDef.html">Ogre::PropertyDef</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Definition of a property of an object.  <a href="classOgre_1_1PropertyDef.html#_details">More...</a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">class &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classOgre_1_1PropertyBase.html">Ogre::PropertyBase</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Base interface for an instance of a property.  <a href="classOgre_1_1PropertyBase.html#_details">More...</a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">class &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classOgre_1_1Property.html">Ogre::Property&lt; T &gt;</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><a class="el" href="classOgre_1_1Property.html" title="Property instance with passthrough calls to a given object.">Property</a> instance with passthrough calls to a given object.  <a href="classOgre_1_1Property.html#_details">More...</a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="structOgre_1_1PropertyValue.html">Ogre::PropertyValue</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">A simple structure designed just as a holder of property values between the instances of objects they might target.  <a href="structOgre_1_1PropertyValue.html#_details">More...</a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">class &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classOgre_1_1PropertySet.html">Ogre::PropertySet</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Defines a complete set of properties for a single object instance.  <a href="classOgre_1_1PropertySet.html#_details">More...</a><br/></td></tr>
<tr><td colspan="2"><h2>Namespaces</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">namespace &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespaceOgre.html">Ogre</a></td></tr>

<p><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><p>----------------------------------------------------------------------------- This source file is part of OGRE (Object-oriented Graphics Rendering Engine) For the latest info, see <a href="http://www.ogre3d.org/">http://www.ogre3d.org/</a> </p>
<br/></td></tr>
</p>
<tr><td colspan="2"><h2>Typedefs</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">typedef map&lt; String, <br class="typebreak"/>
PropertyDef &gt;::type&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Property.html#gaa2af9dd0402adef0e54243e3ee3dc86e">Ogre::PropertyDefMap</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Map from property name to shared definition.  <a href="group__Property.html#gaa2af9dd0402adef0e54243e3ee3dc86e"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">typedef map&lt; String, <br class="typebreak"/>
PropertyValue &gt;::type&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Property.html#gac473fdb476888c7a1a0a4a857948cc5c">Ogre::PropertyValueMap</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Defines a transferable map of properties using wrapped value types (<a class="el" href="classOgre_1_1Any.html" title="Variant type that can hold Any other type.">Ogre::Any</a>).  <a href="group__Property.html#gac473fdb476888c7a1a0a4a857948cc5c"></a><br/></td></tr>
<tr><td colspan="2"><h2>Enumerations</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">enum &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Property.html#ga0883a5af9197151407965df0bacc4f3a">Ogre::PropertyType</a> { <br/>
&nbsp;&nbsp;<a class="el" href="group__Property.html#gga0883a5af9197151407965df0bacc4f3aa19d90ad1680589279aafec448c4e75d3">Ogre::PROP_SHORT</a> =  0, 
<a class="el" href="group__Property.html#gga0883a5af9197151407965df0bacc4f3aa8807d302197c648340522a66196f46f1">Ogre::PROP_UNSIGNED_SHORT</a> =  1, 
<a class="el" href="group__Property.html#gga0883a5af9197151407965df0bacc4f3aa93d4b54300df506764ebb8af6bf4d5c8">Ogre::PROP_INT</a> =  2, 
<a class="el" href="group__Property.html#gga0883a5af9197151407965df0bacc4f3aa9fb3644ad2ce148f77291a0d3eaea6a1">Ogre::PROP_UNSIGNED_INT</a> =  3, 
<br/>
&nbsp;&nbsp;<a class="el" href="group__Property.html#gga0883a5af9197151407965df0bacc4f3aa3d3a41849ca836ff178c8f2618629794">Ogre::PROP_LONG</a> =  4, 
<a class="el" href="group__Property.html#gga0883a5af9197151407965df0bacc4f3aabb2c30d9d8af27d83d4aafed018aa84d">Ogre::PROP_UNSIGNED_LONG</a> =  5, 
<a class="el" href="group__Property.html#gga0883a5af9197151407965df0bacc4f3aa269350183053663ed0e36a69b72dc4c8">Ogre::PROP_REAL</a> =  6, 
<a class="el" href="group__Property.html#gga0883a5af9197151407965df0bacc4f3aa7964244e71bea1a0b721d42e6fa4ae53">Ogre::PROP_STRING</a> =  7, 
<br/>
&nbsp;&nbsp;<a class="el" href="group__Property.html#gga0883a5af9197151407965df0bacc4f3aa5f081dc286c25333c43e8467d6c7c8b6">Ogre::PROP_VECTOR2</a> =  8, 
<a class="el" href="group__Property.html#gga0883a5af9197151407965df0bacc4f3aacd225d4bbfbd47f0473b7d56f834f3b6">Ogre::PROP_VECTOR3</a> =  9, 
<a class="el" href="group__Property.html#gga0883a5af9197151407965df0bacc4f3aaa5b410ea31e3954eeba233240dfb67ec">Ogre::PROP_VECTOR4</a> =  10, 
<a class="el" href="group__Property.html#gga0883a5af9197151407965df0bacc4f3aa4dbf2ba96cd6b8774fc4cd98b0bfca01">Ogre::PROP_COLOUR</a> =  11, 
<br/>
&nbsp;&nbsp;<a class="el" href="group__Property.html#gga0883a5af9197151407965df0bacc4f3aa4811d3c1f6bce61a13fedbcfa19e1b32">Ogre::PROP_BOOL</a> =  12, 
<a class="el" href="group__Property.html#gga0883a5af9197151407965df0bacc4f3aa161aabceab220d04e7aa8704ff8e5293">Ogre::PROP_QUATERNION</a> =  13, 
<a class="el" href="group__Property.html#gga0883a5af9197151407965df0bacc4f3aa1a10d1f71eb0804ab6ec20a598a1ac93">Ogre::PROP_MATRIX3</a> =  14, 
<a class="el" href="group__Property.html#gga0883a5af9197151407965df0bacc4f3aad1ccdd4ffa8de819d5f96bac1a405a32">Ogre::PROP_MATRIX4</a> =  15, 
<br/>
&nbsp;&nbsp;<a class="el" href="group__Property.html#gga0883a5af9197151407965df0bacc4f3aa593a0408d46ccf3061cb27c372b25e8d">Ogre::PROP_UNKNOWN</a> =  999
<br/>
 }</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><p>The type of a property. </p>
 <a href="group__Property.html#ga0883a5af9197151407965df0bacc4f3a">More...</a><br/></td></tr>
</table>
<hr/><a name="_details"></a><h2>Detailed Description</h2>
<p>OGRE's property system allows you to associate values of arbitrary type with names, and have those values exposed via a self-describing interface. </p>
<p>Unlike <a class="el" href="classOgre_1_1StringInterface.html" title="Class defining the common interface which classes can use to present a reflection-style...">Ogre::StringInterface</a>, the values are passed as their native types without needing conversion to or from strings; they are simply wrapped in an <a class="el" href="classOgre_1_1Any.html" title="Variant type that can hold Any other type.">Ogre::Any</a> and casts are performed to access them. </p>
<dl class="user"><dt><b></b></dt><dd>Property values are actually not stored in this system; instead the property definitions reference getter &amp; setter methods which provide the 'backing' for the property. This means you can directly expose features of your classes as properties without any duplication. </dd></dl>
<dl class="user"><dt><b></b></dt><dd>There are two aspects to exposing a property on your class. One is exposing the definition of the property (PropertyDef), which should be shared between all instances and probably stored in a static PropertyDefMap somewhere. The second is the instance 'wiring' which ensures that a call to set a property calls a method on this particular instance of the class; this is formed by a number of Property instances, contained in a PropertySet. Each Property has an explicit binding to getter and setter instance methods. </dd></dl>
<dl class="user"><dt><b></b></dt><dd>So, here's an example of setting up properties on an instance:</dd></dl>
<div class="fragment"><pre class="fragment">    <span class="comment">// Make sure the property definition is created </span>
    <span class="comment">// propertyDefs is a variable of type PropertyDefMap, shared between instances</span>
    PropertyDefMap::iterator defi = propertyDefs.find(<span class="stringliteral">&quot;name&quot;</span>);
    <span class="keywordflow">if</span> (defi == propertyDefs.end())
    {
        defi = propertyDefs.insert(PropertyDefMap::value_type(<span class="stringliteral">&quot;name&quot;</span>, 
            PropertyDef(<span class="stringliteral">&quot;name&quot;</span>, 
                <span class="stringliteral">&quot;The name of the object.&quot;</span>, <a class="code" href="group__Property.html#gga0883a5af9197151407965df0bacc4f3aa7964244e71bea1a0b721d42e6fa4ae53">PROP_STRING</a>))).first;
    }
    <span class="comment">// This has established the property definition, and its description.</span>
    <span class="comment">// Now, we need to &#39;wire&#39; a property instance for this object instance</span>
    <span class="comment">// We assume the class is called &#39;Foo&#39; and the instance is pointed to by a variable called &#39;inst&#39;</span>
    <span class="comment">// &#39;props&#39; is a PropertySet, specific to the instance</span>
    props.addProperty(
        <a class="code" href="group__Memory.html#gab5fc1358fd5a889de0a06d07e45df1ff">OGRE_NEW</a> Property&lt;String&gt;(&amp;(defi-&gt;second),
            boost::bind(&amp;Foo::getName, inst), 
            boost::bind(&amp;Foo::setName, inst, _1)));
</pre></div> 
<p>Definition in file <a class="el" href="OgreProperty_8h_source.html">OgreProperty.h</a>.</p>
</div>
<hr>
<p>
Copyright &copy; 2012 Torus Knot Software Ltd<br />
<!--Creative Commons License--><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.<br/>
		<!--/Creative Commons License--><!-- <rdf:RDF xmlns="http://web.resource.org/cc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
		<Work rdf:about="">
			<license rdf:resource="http://creativecommons.org/licenses/by-sa/2.5/" />
	<dc:type rdf:resource="http://purl.org/dc/dcmitype/Text" />
		</Work>
		<License rdf:about="http://creativecommons.org/licenses/by-sa/2.5/"><permits rdf:resource="http://web.resource.org/cc/Reproduction"/><permits rdf:resource="http://web.resource.org/cc/Distribution"/><requires rdf:resource="http://web.resource.org/cc/Notice"/><requires rdf:resource="http://web.resource.org/cc/Attribution"/><permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/><requires rdf:resource="http://web.resource.org/cc/ShareAlike"/></License></rdf:RDF> -->

Last modified Sun Sep 2 08:16:13 2012
</p>
</body>
</html>
