Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > media > main-release > by-pkgid > ea24284f03fd4a8a4b64047514d93f64 > files > 166

lib64kdegames1-devel-3.5.9-2mdv2008.1.x86_64.rpm

<?xml version="1.0" encoding="UTF-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" lang="en_US" xml:lang="en_US">

<head>
  <title>libkdegames: KGameProperty&lt; type &gt; Class Template Reference (libkdegames)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

  <meta http-equiv="Content-Style-Type" content="text/css" />

  <meta http-equiv="pics-label" content='(pics-1.1 "http://www.icra.org/ratingsv02.html" comment "ICRAonline DE v2.0" l gen true for "http://www.kde.org"  r (nz 1 vz 1 lz 1 oz 1 cb 1) "http://www.rsac.org/ratingsv01.html" l gen true for "http://www.kde.org"  r (n 0 s 0 v 0 l 0))' />

  <meta name="trademark" content="KDE e.V." />
  <meta name="description" content="K Desktop Environment Homepage, KDE.org" />
  <meta name="MSSmartTagsPreventParsing" content="true" />
  <meta name="robots" content="all" />

  <link rel="shortcut icon" href="../../favicon.ico" />

<link rel="stylesheet" media="screen" type="text/css" title="APIDOX" href="doxygen.css" />



</head>

<body>

<div id="nav_header_top" align="right">
  <a href="#content" class="doNotDisplay" accesskey="2">Skip to main content ::</a>

  <a href="../.."><img id="nav_header_logo" alt="Home" align="left" src="../../kde_gear_64.png" border="0" /></a>
  <span class="doNotDisplay">::</span>

  <div id="nav_header_title" align="left">KDE API Reference</div>


</div>

<div id="nav_header_bottom" align="right">
  <span class="doNotDisplay">:: <a href="#navigation" accesskey="5">Skip to Link Menu</a><br/></span>
  <div id="nav_header_bottom_right" style="text-align: left;">
/ <a href="../..">API Reference</a>
 / <a href=".">libkdegames</a>
  </div>
</div>


<table id="main" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
      <td valign="top" class="menuheader" height="0"></td>

  <td id="contentcolumn" valign="top" rowspan="2" >
    <div id="content" style="padding-top: 0px;"><div style="width:100%; margin: 0px; padding: 0px;">
    <a name="content"></a>


<!-- Generated by Doxygen 1.5.5 -->
<div class="contents">
<h1>KGameProperty&lt; type &gt; Class Template Reference</h1><!-- doxytag: class="KGameProperty" --><!-- doxytag: inherits="KGamePropertyBase" --><code>#include &lt;<a class="el" href="kgameproperty_8h-source.html">kgameproperty.h</a>&gt;</code>
<p>
<div class="dynheader">
Inheritance diagram for KGameProperty&lt; type &gt;:</div>
<div class="dynsection">

<p><center><img src="classKGameProperty.png" usemap="#KGameProperty< type >_map" border="0" alt=""></center>
<map name="KGameProperty< type >_map">
<area href="classKGamePropertyBase.html" alt="KGamePropertyBase" shape="rect" coords="0,0,149,24">
</map>
</div>

<p>
<a href="classKGameProperty-members.html">List of all members.</a><hr><a name="_details"></a><h2>Detailed Description</h2>
<h3>template&lt;class type&gt;<br>
 class KGameProperty&lt; type &gt;</h3>

A class for network transparent games. 
<p>
Note: The entire API documentation is obsolete!<p>
The class <a class="el" href="classKGameProperty.html" title="A class for network transparent games.">KGameProperty</a> can store any form of data and will transmit it via network whenver you call send. This makes network transparent games very easy. You first have to register the data to a <a class="el" href="classKGamePropertyHandler.html" title="A collection class for KGameProperty objects.">KGamePropertyHandler</a> using <a class="el" href="classKGamePropertyBase.html#185d99416b87cc55d14a80a67ef9d9aa" title="You have to register a KGamePropertyBase before you can use it.">KGamePropertyBase::registerData</a> (which is called by the constructor). For the <a class="el" href="classKGamePropertyHandler.html" title="A collection class for KGameProperty objects.">KGamePropertyHandler</a> you can use <a class="el" href="classKGame.html#dcf7c99aac7741d624225e6d815e8885" title="Returns a pointer to the KGame property handler.">KGame::dataHandler</a> or <a class="el" href="classKPlayer.html#ed04a331c2abc244028d0b864bb4e443">KPlayer::dataHandler</a> but you can also create your own data handler.<p>
There are several concepts you can follow when writing network games. These concepts differ completely from the way how data is transferred so you should decide which one to use. You can also mix these concepts for a single property but we do not recommend this. The concepts: <ul>
<li>
Always Consistent (clean) </li>
<li>
Not Always Consistent (dirty) </li>
<li>
A Mixture (very dirty) </li>
</ul>
I repeat: we do <em>not</em> recommend the third option ("a mixture"). Unless you have a good reason for this you will probably introduce some hard to find (and to fix) bugs.<h2><a class="anchor" name="Always">
consistent (clean):</a></h2>
This "policy" is default. Whenever you create a <a class="el" href="classKGameProperty.html" title="A class for network transparent games.">KGameProperty</a> it is always consistent. This means that consistency is the most important thing for the property. This is achieved by using send to change the value of the property. send needs a running <a class="el" href="classKMessageServer.html" title="A server for message sending and broadcasting, using TCP/IP connections.">KMessageServer</a> and therefore <em>MUST</em> be plugged into a <a class="el" href="classKGamePropertyHandler.html" title="A collection class for KGameProperty objects.">KGamePropertyHandler</a> using either registerData or the constructor. The parent of the dataHandler must be able to send messages (see above: the message server must be running). If you use send to change the value of a property you won't see the effect immediately: The new value is first transferred to the message server which queues the message. As soon as <em>all</em> messages in the message server which are before the changed property have been transferred the message server delivers the new value of the <a class="el" href="classKGameProperty.html" title="A class for network transparent games.">KGameProperty</a> to all clients. A QTimer::singleShot is used to queue the messages inside the <a class="el" href="classKMessageServer.html" title="A server for message sending and broadcasting, using TCP/IP connections.">KMessageServer</a>.<p>
This means that if you do the following: <div class="fragment"><pre class="fragment"> <a class="code" href="classKGameProperty.html">KGamePropertyInt</a> myProperty(<span class="keywordtype">id</span>, dataHandler());
 myProperty.initData(0);
 myProperty = 10;
 <span class="keywordtype">int</span> <a class="code" href="classKGameProperty.html#13c8d6333e09c220e9a327edeb79e074">value</a> = myProperty.value();
</pre></div> then "value" will be "0". initData is used to initialize the property (e.g. when the <a class="el" href="classKMessageServer.html" title="A server for message sending and broadcasting, using TCP/IP connections.">KMessageServer</a> is not yet running or can not yet be reached). This is because "myProperty = 10" or "myProperty.send(10)" send a message to the <a class="el" href="classKMessageServer.html" title="A server for message sending and broadcasting, using TCP/IP connections.">KMessageServer</a> which uses QTimer::singleShot to queue the message. The game first has to go back into the event loop where the message is received. The <a class="el" href="classKGamePropertyHandler.html" title="A collection class for KGameProperty objects.">KGamePropertyHandler</a> receives the new value sets the property. So if you need the new value you need to store it in a different variable (see setLocal which creates one for you until the message is received). The <a class="el" href="classKGamePropertyHandler.html" title="A collection class for KGameProperty objects.">KGamePropertyHandler</a> emits a signal (unless you called setEmitSignal with false) when the new value is received: <a class="el" href="classKGamePropertyHandler.html#d3a4e8f0a9155b9ff29284a9453bd554" title="This is emitted by a property.">KGamePropertyHandler::signalPropertyChanged</a>. You can use this to react to a changed property.<p>
This may look quite confusing but it has a <em>big</em> advantage: all <a class="el" href="classKGameProperty.html" title="A class for network transparent games.">KGameProperty</a> objects are ensured to have the same value on all clients in the game at every time. This way you will save you a lot of trouble as debugging can be very difficult if the value of a property changes immediately on client A but only after one or two additianal messages (function calls, status changes, ...) on client B.<p>
The only disadvantage of this (clean) concept is that you cannot use a changed variable immediately but have to wait for the <a class="el" href="classKMessageServer.html" title="A server for message sending and broadcasting, using TCP/IP connections.">KMessageServer</a> to change it. You probably want to use <a class="el" href="classKGamePropertyHandler.html#d3a4e8f0a9155b9ff29284a9453bd554" title="This is emitted by a property.">KGamePropertyHandler::signalPropertyChanged</a> for this.<h2><a class="anchor" name="Not">
Always Consistent (dirty):</a></h2>
There are a lot of people who don't want to use the (sometimes quite complex) "clean" way. You can use setAlwaysConsistent to change the default behaviour of the <a class="el" href="classKGameProperty.html" title="A class for network transparent games.">KGameProperty</a>. If a property is not always consistent it will use changeValue to send the property. changeValue also uses send to send the new value over network but it also uses setLocal to create a local copy of the property. This copy is created dynamically and is deleted again as soon as the next message from the network is received. To use the example above again: <div class="fragment"><pre class="fragment"> <a class="code" href="classKGameProperty.html">KGamePropertyInt</a> myProperty(<span class="keywordtype">id</span>, dataHandler());
 myProperty.setAlwaysConsistent(<span class="keyword">false</span>);
 myProperty.initData(0);
 myProperty = 10;
 <span class="keywordtype">int</span> value = myProperty.value();
</pre></div> Now this example will "work" so value now is 10. Additionally the <a class="el" href="classKMessageServer.html" title="A server for message sending and broadcasting, using TCP/IP connections.">KMessageServer</a> receives a message from the local client (just as explained above in "Always Consistent"). As soon as the message returns to the local client again the local value is deleted, as the "network value" has the same value as the local one. So you won't lose the ability to use the always consistent "clean" value of the property if you use the "dirty" way. Just use networkValue to access the value which is consistent among all clients.<p>
The advantage of this concept is clear: you can use a <a class="el" href="classKGameProperty.html" title="A class for network transparent games.">KGameProperty</a> as every other variable as the changes value takes immediate effect. Additionally you can be sure that the value is transferred to all clients. You will usually not experience serious bugs just because you use the "dirty" way. Several events have to happen at once to get these "strange errors" which result in inconsistent properties (like "game running" on client A but "game ended/paused" on client B). But note that there is a very good reason for the existence of these different concepts of <a class="el" href="classKGameProperty.html" title="A class for network transparent games.">KGameProperty</a>. I have myself experienced such a "strange error" and it took me several days to find the reason until I could fix it. So I personally recommend the "clean" way. On the other hand if you want to port a non-network game to a network game you will probably start with "dirty" properties as it is you will not have to change that much code...<h2><a class="anchor" name="A">
Mixture (very dirty):</a></h2>
You can also mix the concepts above. Note that we really don't recommend this. With a mixture I mean something like this: <div class="fragment"><pre class="fragment"> <a class="code" href="classKGameProperty.html">KGamePropertyInt</a> myProperty(<span class="keywordtype">id</span>, dataHandler());
 myProperty.setAlwaysConsistent(<span class="keyword">false</span>);
 myProperty.initData(0);
 myProperty = 10;
 myProperty.setAlwaysConsistent(<span class="keyword">true</span>);
 myProperty = 20;
</pre></div> (totally senseless example, btw) I.e. I am speaking of mixing both concepts for a single property. Things like <div class="fragment"><pre class="fragment"> <a class="code" href="classKGameProperty.html">KGamePropertyInt</a> myProperty1(id1, dataHandler());
 <a class="code" href="classKGameProperty.html">KGamePropertyInt</a> myProperty2(id2, dataHandler());
 myProperty1.initData(0);
 myProperty2.initData(0);
 myProperty1.setAlwaysConsistent(<span class="keyword">false</span>);
 myProperty2.setAlwaysConsistent(<span class="keyword">true</span>);
 myProperty1 = 10;
 myProperty2 = 20;
</pre></div> are ok. But mixing the concepts for a single property will make it nearly impossible to you to debug your game.<p>
So the right thing to do(tm) is to decide in the constructor whether you want a "clean" or "dirty" property.<p>
Even if you have decided for one of the concepts you still can manually follow another concept than the "policy" of your property. So if you use an always consistent <a class="el" href="classKGameProperty.html" title="A class for network transparent games.">KGameProperty</a> you still can manually call changeValue as if it was not always consistent. Note that although this is also kind of a "mixture" as described above this is very useful sometimes. In contrast to the "mixture" above you don't have the problem that you don't exactly know which concept you are currently following because you used the function of the other concept only once.<h2><a class="anchor" name="Custom">
classes:</a></h2>
If you want to use a custum class with <a class="el" href="classKGameProperty.html" title="A class for network transparent games.">KGameProperty</a> you have to implement the operators &lt;&lt; and &gt;&gt; for QDataStream: <div class="fragment"><pre class="fragment"> <span class="keyword">class </span>Card
 {
 <span class="keyword">public</span>:
 <span class="keywordtype">int</span> type;
 <span class="keywordtype">int</span> suite;
 };
 QDataStream&amp; operator&lt;&lt;(QDataStream&amp; stream, Card&amp; card)
 {
 Q_INT16 type = card.type;
 Q_INT16 suite = card.suite;
 s &lt;&lt; type;
 s &lt;&lt; suite;
 <span class="keywordflow">return</span> s;
 }
 QDataStream&amp; operator&gt;&gt;(QDataStream&amp; stream, Card&amp; card)
 {
 Q_INT16 type;
 Q_INT16 suite;
 s &gt;&gt; type;
 s &gt;&gt; suite;
 card.type = (int)type;
 card.suite = (int)suite;
 <span class="keywordflow">return</span> s;
 }

 <span class="keyword">class </span>Player : <a class="code" href="classKPlayer.html" title="Base class for a game player.">KPlayer</a>
 {
 [...]
 <a class="code" href="classKGameProperty.html" title="A class for network transparent games.">KGameProperty&lt;Card&gt;</a> mCards;
 };
</pre></div><p>
Note: unlike most QT classes <a class="el" href="classKGameProperty.html" title="A class for network transparent games.">KGameProperty</a> objects are *not* deleted automatically! So if you create an object using e.g. <a class="el" href="classKGameProperty.html">KGameProperty&lt;int&gt;</a>* data = new <a class="el" href="classKGameProperty.html" title="A class for network transparent games.">KGameProperty</a>(id, dataHandler()) you have to put a delete data into your destructor!<p>
<dl class="author" compact><dt><b>Author:</b></dt><dd>Andreas Beckermann &lt;<a href="mailto:b_mann@gmx.de">b_mann@gmx.de</a>&gt; </dd></dl>

<p>Definition at line <a class="el" href="kgameproperty_8h-source.html#l00581">581</a> of file <a class="el" href="kgameproperty_8h-source.html">kgameproperty.h</a>.</p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKGameProperty.html#ffa5ef05e76b069508028a0039dc5625">KGameProperty</a> (int id, <a class="el" href="classKGamePropertyHandler.html">KGamePropertyHandler</a> *owner)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKGameProperty.html#4788af0f44a62054248f377cdeabdb02">KGameProperty</a> ()</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKGameProperty.html#dbf2c949b391600d83b73d2ff9dff6e8">setValue</a> (type v)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKGameProperty.html#33713f6ce7c4c801a3fbd7a3e1d27993">send</a> (type v)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKGameProperty.html#fd47964f181f5980af9b1adec5d24fb1">setLocal</a> (type v)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKGameProperty.html#e82b8f80aae034aabea58cb95063f0c5">changeValue</a> (type v)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKGameProperty.html#a4194d022619c74a632bc03166a474f0">save</a> (QDataStream &amp;stream)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">const type &amp;&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKGameProperty.html#13c8d6333e09c220e9a327edeb79e074">value</a> () const </td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKGameProperty.html#7330f32ea354c068ce21293b14e60dbe">load</a> (QDataStream &amp;s)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">const type &amp;&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKGameProperty.html#9b803fd7aa57ac9747ae953732aa5511">operator=</a> (const type &amp;t)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">const type &amp;&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKGameProperty.html#9661dbb23b731cd1db1195a871fb53d7">operator=</a> (const <a class="el" href="classKGameProperty.html">KGameProperty</a> &amp;property)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKGameProperty.html#6f85e9c088ef4f9cbe290aea6268e151">operator type</a> () const </td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual const type_info *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKGameProperty.html#8cb9c0dbdca1b166dbc080734438ee49">typeinfo</a> ()</td></tr>

</table>
<hr><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" name="ffa5ef05e76b069508028a0039dc5625"></a><!-- doxytag: member="KGameProperty::KGameProperty" ref="ffa5ef05e76b069508028a0039dc5625" args="(int id, KGamePropertyHandler *owner)" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class type&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classKGameProperty.html">KGameProperty</a>&lt; type &gt;::<a class="el" href="classKGameProperty.html">KGameProperty</a>           </td>
          <td>(</td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>id</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classKGamePropertyHandler.html">KGamePropertyHandler</a> *&nbsp;</td>
          <td class="paramname"> <em>owner</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Constructs a <a class="el" href="classKGameProperty.html" title="A class for network transparent games.">KGameProperty</a> object. 
<p>
A <a class="el" href="classKGameProperty.html" title="A class for network transparent games.">KGameProperty</a> object will transmit any changes to the <a class="el" href="classKMessageServer.html" title="A server for message sending and broadcasting, using TCP/IP connections.">KMessageServer</a> and then to all clients in the game (including the one that has sent the new value) <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>id</em>&nbsp;</td><td>The id of this property. <em>MUST be UNIQUE</em>! Used to send and receive changes in the property of the playere automatically via network. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>owner</em>&nbsp;</td><td>The parent of the object. Must be a <a class="el" href="classKGame.html" title="The main KDE game object.">KGame</a> which manages the changes made to this object, i.e. which will send the new data. Note that in contrast to most KDE/QT classes <a class="el" href="classKGameProperty.html" title="A class for network transparent games.">KGameProperty</a> objects are <em>not</em> deleted automatically! </td></tr>
  </table>
</dl>

<p>Definition at line <a class="el" href="kgameproperty_8h-source.html#l00597">597</a> of file <a class="el" href="kgameproperty_8h-source.html">kgameproperty.h</a>.</p>

</div>
</div><p>
<a class="anchor" name="4788af0f44a62054248f377cdeabdb02"></a><!-- doxytag: member="KGameProperty::KGameProperty" ref="4788af0f44a62054248f377cdeabdb02" args="()" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class type&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classKGameProperty.html">KGameProperty</a>&lt; type &gt;::<a class="el" href="classKGameProperty.html">KGameProperty</a>           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
This constructor does nothing. 
<p>
You have to call <a class="el" href="classKGamePropertyBase.html#185d99416b87cc55d14a80a67ef9d9aa" title="You have to register a KGamePropertyBase before you can use it.">KGamePropertyBase::registerData</a> yourself before using the <a class="el" href="classKGameProperty.html" title="A class for network transparent games.">KGameProperty</a> object. 
<p>Definition at line <a class="el" href="kgameproperty_8h-source.html#l00604">604</a> of file <a class="el" href="kgameproperty_8h-source.html">kgameproperty.h</a>.</p>

</div>
</div><p>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="dbf2c949b391600d83b73d2ff9dff6e8"></a><!-- doxytag: member="KGameProperty::setValue" ref="dbf2c949b391600d83b73d2ff9dff6e8" args="(type v)" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class type&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="classKGameProperty.html">KGameProperty</a>&lt; type &gt;::setValue           </td>
          <td>(</td>
          <td class="paramtype">type&nbsp;</td>
          <td class="paramname"> <em>v</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Set the value depending on the current policy (see setConsistent). 
<p>
By default <a class="el" href="classKGameProperty.html" title="A class for network transparent games.">KGameProperty</a> just uses send to set the value of a property. This behaviour can be changed by using setConsistent. <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>v</em>&nbsp;</td><td>The new value of the property </td></tr>
  </table>
</dl>

<p>Definition at line <a class="el" href="kgameproperty_8h-source.html#l00615">615</a> of file <a class="el" href="kgameproperty_8h-source.html">kgameproperty.h</a>.</p>

</div>
</div><p>
<a class="anchor" name="33713f6ce7c4c801a3fbd7a3e1d27993"></a><!-- doxytag: member="KGameProperty::send" ref="33713f6ce7c4c801a3fbd7a3e1d27993" args="(type v)" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class type&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">bool <a class="el" href="classKGameProperty.html">KGameProperty</a>&lt; type &gt;::send           </td>
          <td>(</td>
          <td class="paramtype">type&nbsp;</td>
          <td class="paramname"> <em>v</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
This function sends a new value over network. 
<p>
Note that the value DOES NOT change when you call this function. This function saves the value into a QDataStream and calls sendProperty where it gets forwarded to the owner and finally the value is sent over network. The <a class="el" href="classKMessageServer.html" title="A server for message sending and broadcasting, using TCP/IP connections.">KMessageServer</a> now sends the value to ALL clients - even the one who called this function. As soon as the value from the message server is received load is called and _then_ the value of the <a class="el" href="classKGameProperty.html" title="A class for network transparent games.">KGameProperty</a> has been set.<p>
This ensures that a <a class="el" href="classKGameProperty.html" title="A class for network transparent games.">KGameProperty</a> has _always_ the same value on _every_ client in the network. Note that this means you can NOT do something like <div class="fragment"><pre class="fragment"> myProperty.send(1);
 doSomething(myProperty);
</pre></div> as myProperty has not yet been set when doSomething is being called.<p>
You are informed about a value change by a singal from the parent of the property which can be deactivated by setEmittingSignal because of performance (you probably don't have to deactivate it - except you want to write a real-time game like Command&amp;Conquer with a lot of acitvity). See emitSignal<p>
Note that if there is no <a class="el" href="classKMessageServer.html" title="A server for message sending and broadcasting, using TCP/IP connections.">KMessageServer</a> accessible - before the property has been registered to the <a class="el" href="classKGamePropertyHandler.html" title="A collection class for KGameProperty objects.">KGamePropertyHandler</a> (as it is the case e.g. before a <a class="el" href="classKPlayer.html" title="Base class for a game player.">KPlayer</a> has been plugged into the <a class="el" href="classKGame.html" title="The main KDE game object.">KGame</a> object) the property is *not* sent but set *locally* (see setLocal)!<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>v</em>&nbsp;</td><td>The new value of the property </td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>whether the property could be sent successfully </dd></dl>
<dl class="see" compact><dt><b>See also:</b></dt><dd><a class="el" href="classKGameProperty.html#dbf2c949b391600d83b73d2ff9dff6e8" title="Set the value depending on the current policy (see setConsistent).">setValue</a> <a class="el" href="classKGameProperty.html#fd47964f181f5980af9b1adec5d24fb1" title="This function sets the value of the property directly, i.e.">setLocal</a> <a class="el" href="classKGameProperty.html#e82b8f80aae034aabea58cb95063f0c5" title="This function does both, change the local value and change the network value.">changeValue</a> <a class="el" href="classKGameProperty.html#13c8d6333e09c220e9a327edeb79e074">value</a> </dd></dl>

<p>Definition at line <a class="el" href="kgameproperty_8h-source.html#l00670">670</a> of file <a class="el" href="kgameproperty_8h-source.html">kgameproperty.h</a>.</p>

</div>
</div><p>
<a class="anchor" name="fd47964f181f5980af9b1adec5d24fb1"></a><!-- doxytag: member="KGameProperty::setLocal" ref="fd47964f181f5980af9b1adec5d24fb1" args="(type v)" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class type&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">bool <a class="el" href="classKGameProperty.html">KGameProperty</a>&lt; type &gt;::setLocal           </td>
          <td>(</td>
          <td class="paramtype">type&nbsp;</td>
          <td class="paramname"> <em>v</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
This function sets the value of the property directly, i.e. 
<p>
it doesn't send it to the network.<p>
Int contrast to <dl class="see" compact><dt><b>See also:</b></dt><dd>you change _only_ the local <a class="el" href="classKGameProperty.html#13c8d6333e09c220e9a327edeb79e074">value</a> when using this function. You do _not_ change the <a class="el" href="classKGameProperty.html#13c8d6333e09c220e9a327edeb79e074">value</a> of any other client. You probably don't want to use this if you are using a dedicated server (which is the only "client" which is allowed to change a <a class="el" href="classKGameProperty.html#13c8d6333e09c220e9a327edeb79e074">value</a>) but rather want to use <a class="el" href="classKGameProperty.html#33713f6ce7c4c801a3fbd7a3e1d27993" title="This function sends a new value over network.">send()</a>.</dd></dl>
But if you use your clients as servers (i.e. all clients receive a players turn and then calculate the reaction of the game theirselves) then you probably want to use setLocal as you can do things like <div class="fragment"><pre class="fragment"> myProperty.setLocal(1);
 doSomething(myProperty);
</pre></div> on every client.<p>
If you want to set the value locally AND send it over network you want to call changeValue!<p>
You can also use setPolicy to set the default policy to PolicyLocal.<p>
<dl class="see" compact><dt><b>See also:</b></dt><dd><a class="el" href="classKGameProperty.html#dbf2c949b391600d83b73d2ff9dff6e8" title="Set the value depending on the current policy (see setConsistent).">setValue</a> <a class="el" href="classKGameProperty.html#33713f6ce7c4c801a3fbd7a3e1d27993" title="This function sends a new value over network.">send</a> <a class="el" href="classKGameProperty.html#e82b8f80aae034aabea58cb95063f0c5" title="This function does both, change the local value and change the network value.">changeValue</a> <a class="el" href="classKGameProperty.html#13c8d6333e09c220e9a327edeb79e074">value</a> </dd></dl>

<p>Definition at line <a class="el" href="kgameproperty_8h-source.html#l00715">715</a> of file <a class="el" href="kgameproperty_8h-source.html">kgameproperty.h</a>.</p>

</div>
</div><p>
<a class="anchor" name="e82b8f80aae034aabea58cb95063f0c5"></a><!-- doxytag: member="KGameProperty::changeValue" ref="e82b8f80aae034aabea58cb95063f0c5" args="(type v)" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class type&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="classKGameProperty.html">KGameProperty</a>&lt; type &gt;::changeValue           </td>
          <td>(</td>
          <td class="paramtype">type&nbsp;</td>
          <td class="paramname"> <em>v</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
This function does both, change the local value and change the network value. 
<p>
The value is sent over network first, then changed locally.<p>
This function is a convenience function and just calls send followed by setLocal<p>
Note that emitSignal is also called twice: once after setLocal and once when the value from send is received<p>
<dl class="see" compact><dt><b>See also:</b></dt><dd><a class="el" href="classKGameProperty.html#33713f6ce7c4c801a3fbd7a3e1d27993" title="This function sends a new value over network.">send</a> <a class="el" href="classKGameProperty.html#fd47964f181f5980af9b1adec5d24fb1" title="This function sets the value of the property directly, i.e.">setLocal</a> <a class="el" href="classKGameProperty.html#dbf2c949b391600d83b73d2ff9dff6e8" title="Set the value depending on the current policy (see setConsistent).">setValue</a> <a class="el" href="classKGameProperty.html#13c8d6333e09c220e9a327edeb79e074">value</a> </dd></dl>

<p>Definition at line <a class="el" href="kgameproperty_8h-source.html#l00744">744</a> of file <a class="el" href="kgameproperty_8h-source.html">kgameproperty.h</a>.</p>

</div>
</div><p>
<a class="anchor" name="a4194d022619c74a632bc03166a474f0"></a><!-- doxytag: member="KGameProperty::save" ref="a4194d022619c74a632bc03166a474f0" args="(QDataStream &amp;stream)" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class type&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">virtual void <a class="el" href="classKGameProperty.html">KGameProperty</a>&lt; type &gt;::save           </td>
          <td>(</td>
          <td class="paramtype">QDataStream &amp;&nbsp;</td>
          <td class="paramname"> <em>stream</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [inline, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Saves the object to a stream. 
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>stream</em>&nbsp;</td><td>The stream to save to </td></tr>
  </table>
</dl>

<p>Implements <a class="el" href="classKGamePropertyBase.html#603b627316f0f379e5c93e1f70100a62">KGamePropertyBase</a>.</p>

<p>Definition at line <a class="el" href="kgameproperty_8h-source.html#l00754">754</a> of file <a class="el" href="kgameproperty_8h-source.html">kgameproperty.h</a>.</p>

</div>
</div><p>
<a class="anchor" name="13c8d6333e09c220e9a327edeb79e074"></a><!-- doxytag: member="KGameProperty::value" ref="13c8d6333e09c220e9a327edeb79e074" args="() const " -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class type&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">const type&amp; <a class="el" href="classKGameProperty.html">KGameProperty</a>&lt; type &gt;::value           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"> const<code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>The local value (see setLocal) if it is existing, otherwise the network value which is always consistent on every client. </dd></dl>

<p>Definition at line <a class="el" href="kgameproperty_8h-source.html#l00764">764</a> of file <a class="el" href="kgameproperty_8h-source.html">kgameproperty.h</a>.</p>

</div>
</div><p>
<a class="anchor" name="7330f32ea354c068ce21293b14e60dbe"></a><!-- doxytag: member="KGameProperty::load" ref="7330f32ea354c068ce21293b14e60dbe" args="(QDataStream &amp;s)" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class type&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">virtual void <a class="el" href="classKGameProperty.html">KGameProperty</a>&lt; type &gt;::load           </td>
          <td>(</td>
          <td class="paramtype">QDataStream &amp;&nbsp;</td>
          <td class="paramname"> <em>s</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [inline, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Reads from a stream and assigns the read value to this object. 
<p>
This function is called automatically when a new value is received over network (i.e. it has been sent using send on this or any other client) or when a game is loaded (and maybe on some other events).<p>
Also calls emitSignal if isEmittingSignal is TRUE. <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>s</em>&nbsp;</td><td>The stream to read from </td></tr>
  </table>
</dl>

<p>Implements <a class="el" href="classKGamePropertyBase.html#5a0c456be1dc1afb9b34d8e565a44bef">KGamePropertyBase</a>.</p>

<p>Definition at line <a class="el" href="kgameproperty_8h-source.html#l00780">780</a> of file <a class="el" href="kgameproperty_8h-source.html">kgameproperty.h</a>.</p>

</div>
</div><p>
<a class="anchor" name="9b803fd7aa57ac9747ae953732aa5511"></a><!-- doxytag: member="KGameProperty::operator=" ref="9b803fd7aa57ac9747ae953732aa5511" args="(const type &amp;t)" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class type&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">const type&amp; <a class="el" href="classKGameProperty.html">KGameProperty</a>&lt; type &gt;::operator=           </td>
          <td>(</td>
          <td class="paramtype">const type &amp;&nbsp;</td>
          <td class="paramname"> <em>t</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
This calls setValue to change the value of the property. 
<p>
Note that depending on the policy (see setAlwaysConsistent) the returned value might be different from the assigned value!!<p>
So if you use setPolicy(PolicyClean): <div class="fragment"><pre class="fragment"> <span class="keywordtype">int</span> a, b = 10;
 myProperty = b;
 a = myProperty.value();
</pre></div> Here a and b would differ! The value is actually set as soon as it is received from the <a class="el" href="classKMessageServer.html" title="A server for message sending and broadcasting, using TCP/IP connections.">KMessageServer</a> which forwards it to ALL clients in the network.<p>
If you use a clean policy (see setPolicy) then the returned value is the assigned value 
<p>Definition at line <a class="el" href="kgameproperty_8h-source.html#l00807">807</a> of file <a class="el" href="kgameproperty_8h-source.html">kgameproperty.h</a>.</p>

</div>
</div><p>
<a class="anchor" name="9661dbb23b731cd1db1195a871fb53d7"></a><!-- doxytag: member="KGameProperty::operator=" ref="9661dbb23b731cd1db1195a871fb53d7" args="(const KGameProperty &amp;property)" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class type&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">const type&amp; <a class="el" href="classKGameProperty.html">KGameProperty</a>&lt; type &gt;::operator=           </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classKGameProperty.html">KGameProperty</a>&lt; type &gt; &amp;&nbsp;</td>
          <td class="paramname"> <em>property</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
This copies the data of property to the <a class="el" href="classKGameProperty.html" title="A class for network transparent games.">KGameProperty</a> object. 
<p>
Equivalent to setValue(property.value()); 
<p>Definition at line <a class="el" href="kgameproperty_8h-source.html#l00818">818</a> of file <a class="el" href="kgameproperty_8h-source.html">kgameproperty.h</a>.</p>

</div>
</div><p>
<a class="anchor" name="6f85e9c088ef4f9cbe290aea6268e151"></a><!-- doxytag: member="KGameProperty::operator type" ref="6f85e9c088ef4f9cbe290aea6268e151" args="() const " -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class type&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classKGameProperty.html">KGameProperty</a>&lt; type &gt;::operator type           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"> const<code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Yeah, you can do it! 
<p>
<div class="fragment"><pre class="fragment">    <span class="keywordtype">int</span> a = myGamePropertyInt;
</pre></div> If you don't see it: you don't have to use integerData.value() 
<p>Definition at line <a class="el" href="kgameproperty_8h-source.html#l00831">831</a> of file <a class="el" href="kgameproperty_8h-source.html">kgameproperty.h</a>.</p>

</div>
</div><p>
<a class="anchor" name="8cb9c0dbdca1b166dbc080734438ee49"></a><!-- doxytag: member="KGameProperty::typeinfo" ref="8cb9c0dbdca1b166dbc080734438ee49" args="()" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class type&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">virtual const type_info* <a class="el" href="classKGameProperty.html">KGameProperty</a>&lt; type &gt;::typeinfo           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [inline, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>a type_info of the data this property contains. This is used e.g. by KGameDebugDialog </dd></dl>

<p>Reimplemented from <a class="el" href="classKGamePropertyBase.html#1e9a0ba7673ae71c7962663ee8802cd9">KGamePropertyBase</a>.</p>

<p>Definition at line <a class="el" href="kgameproperty_8h-source.html#l00833">833</a> of file <a class="el" href="kgameproperty_8h-source.html">kgameproperty.h</a>.</p>

</div>
</div><p>
<hr>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="kgameproperty_8h-source.html">kgameproperty.h</a></ul>
</div>
    </div></div>


      </td>
  </tr>
  <tr>
    <td valign="top" id="leftmenu" width="25%">
      <a name="navigation"></a>
      <div class="menu_box"><h2>libkdegames</h2>
<div class="nav_list">
<ul><li><a href="index.html">Main Page</a></li><li><a href="hierarchy.html">Class Hierarchy</a></li><li><a href="classes.html">Alphabetical List</a></li><li><a href="annotated.html">Class List</a></li><li><a href="files.html">File List</a></li><li><a href="functions.html">Class Members</a></li><li><a href="pages.html">Related Pages</a></li></ul>
<!--
<h2>Class Picker</h2>
<div style="text-align: center;">
<form name="guideform">
<select name="guidelinks" style="width:100%;" onChange="window.location=document.guideform.guidelinks.options[document.guideform.guidelinks.selectedIndex].value">
<option value="annotated.html">-- Choose --</option>
  <option value="classKCanvasRootPixmap.html">kcanvasrootpixmap</option>,  <option value="classKCardDialog.html">kcarddialog</option>,  <option value="classKChat.html">kchat</option>,  <option value="classKChatBase.html">kchatbase</option>,  <option value="classKChatBaseText.html">kchatbasetext</option>,  <option value="classKExtHighscore_1_1Item.html">kexthighscore::item</option>,  <option value="classKExtHighscore_1_1ItemArray.html">kexthighscore::itemarray</option>,  <option value="classKExtHighscore_1_1Manager.html">kexthighscore::manager</option>,  <option value="classKExtHighscore_1_1MultiplayerScores.html">kexthighscore::multiplayerscores</option>,  <option value="classKExtHighscore_1_1Score.html">kexthighscore::score</option>,  <option value="classKGame.html">kgame</option>,  <option value="classKGameChat.html">kgamechat</option>,  <option value="classKGameComputerIO.html">kgamecomputerio</option>,  <option value="classKGameConnectDialog.html">kgameconnectdialog</option>,  <option value="classKGameDialog.html">kgamedialog</option>,  <option value="classKGameDialogChatConfig.html">kgamedialogchatconfig</option>,  <option value="classKGameDialogConfig.html">kgamedialogconfig</option>,  <option value="classKGameErrorDialog.html">kgameerrordialog</option>,  <option value="classKGameErrorMessageDialog.html">kgameerrormessagedialog</option>,  <option value="classKGameIO.html">kgameio</option>,  <option value="classKGameKeyIO.html">kgamekeyio</option>,  <option value="classKGameLCD.html">kgamelcd</option>,  <option value="classKGameLCDClock.html">kgamelcdclock</option>,  <option value="classKGameLCDList.html">kgamelcdlist</option>,  <option value="classKGameMisc.html">kgamemisc</option>,  <option value="classKGameMouseIO.html">kgamemouseio</option>,  <option value="classKGameNetwork.html">kgamenetwork</option>,  <option value="classKGameProcess.html">kgameprocess</option>,  <option value="classKGameProcessIO.html">kgameprocessio</option>,  <option value="classKGameProgress.html">kgameprogress</option>,  <option value="classKGameProperty.html">kgameproperty</option>,  <option value="classKGamePropertyBase.html">kgamepropertybase</option>,  <option value="classKGamePropertyHandler.html">kgamepropertyhandler</option>,  <option value="classKGameSequence.html">kgamesequence</option>,  <option value="classKGrid2D_1_1Generic.html">kgrid2d::generic</option>,  <option value="classKGrid2D_1_1Hexagonal.html">kgrid2d::hexagonal</option>,  <option value="classKGrid2D_1_1HexagonalBase.html">kgrid2d::hexagonalbase</option>,  <option value="classKGrid2D_1_1Square.html">kgrid2d::square</option>,  <option value="classKGrid2D_1_1SquareBase.html">kgrid2d::squarebase</option>,  <option value="classKHighscore.html">khighscore</option>,  <option value="classKMessageClient.html">kmessageclient</option>,  <option value="classKMessageDirect.html">kmessagedirect</option>,  <option value="classKMessageIO.html">kmessageio</option>,  <option value="classKMessageServer.html">kmessageserver</option>,  <option value="classKMessageServerSocket.html">kmessageserversocket</option>,  <option value="classKMessageSocket.html">kmessagesocket</option>,  <option value="classKPlayer.html">kplayer</option>,  <option value="classKScoreDialog.html">kscoredialog</option>,  <option value="classKStdGameAction.html">kstdgameaction</option>,
</select>
</form>
</div>
-->
</div></div>
<div class="menu_box"><h2>API Dox</h2>
<div class="nav_list">
<ul>
<li><a href="../../libkdegames/html/index.html">libkdegames</a></li>
</ul></div></div>


        </td>
</tr>
</table>

<span class="doNotDisplay">
  <a href="http://www.kde.org/" accesskey="8">KDE Home</a> |
  <a href="http://accessibility.kde.org/" accesskey="9">KDE Accessibility Home</a> |
  <a href="http://www.kde.org/media/accesskeys.php" accesskey="0">Description of Access Keys</a>
</span>


<div style="height: 8px"></div>

<div id="footer">
  <div id="footer_left">
    Maintained by <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;groo&#116;&#64;kde&#46;or&#x67;">Adriaan de Groot</a>
and
<a href="&#109;a&#105;&#108;&#116;&#111;&#58;w&#105;nter&#64;kde&#46;or&#x67">Allen Winter</a>.
<br/>
    KDE and K Desktop Environment are trademarks of <a href="http://www.kde.org/areas/kde-ev/" title="Homepage of the KDE non-profit Organization">KDE e.V.</a> |
    <a href="http://www.kde.org/contact/impressum.php">Legal</a>
  </div>
  <div id="footer_right"><img src="/media/images/footer_right.png" style="margin: 0px" alt="" /></div>
</div>

<!--
WARNING: DO NOT SEND MAIL TO THE FOLLOWING EMAIL ADDRESS! YOU WILL
BE BLOCKED INSTANTLY AND PERMANENTLY!
<a href="mailto:aaaatrap-425acc3b5374943f@kde.org">Block me</a>
WARNING END
-->

</body>
</html>