Sophie

Sophie

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

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.h Source File (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 -->
<h1>kgameproperty.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment">    This file is part of the KDE games library</span>
<a name="l00003"></a>00003 <span class="comment">    Copyright (C) 2001 Andreas Beckermann (b_mann@gmx.de)</span>
<a name="l00004"></a>00004 <span class="comment">    Copyright (C) 2001 Martin Heni (martin@heni-online.de)</span>
<a name="l00005"></a>00005 <span class="comment"></span>
<a name="l00006"></a>00006 <span class="comment">    This library is free software; you can redistribute it and/or</span>
<a name="l00007"></a>00007 <span class="comment">    modify it under the terms of the GNU Library General Public</span>
<a name="l00008"></a>00008 <span class="comment">    License version 2 as published by the Free Software Foundation.</span>
<a name="l00009"></a>00009 <span class="comment"></span>
<a name="l00010"></a>00010 <span class="comment">    This library is distributed in the hope that it will be useful,</span>
<a name="l00011"></a>00011 <span class="comment">    but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00012"></a>00012 <span class="comment">    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU</span>
<a name="l00013"></a>00013 <span class="comment">    Library General Public License for more details.</span>
<a name="l00014"></a>00014 <span class="comment"></span>
<a name="l00015"></a>00015 <span class="comment">    You should have received a copy of the GNU Library General Public License</span>
<a name="l00016"></a>00016 <span class="comment">    along with this library; see the file COPYING.LIB.  If not, write to</span>
<a name="l00017"></a>00017 <span class="comment">    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,</span>
<a name="l00018"></a>00018 <span class="comment">    Boston, MA 02110-1301, USA.</span>
<a name="l00019"></a>00019 <span class="comment">*/</span>
<a name="l00020"></a>00020 
<a name="l00021"></a>00021 <span class="preprocessor">#ifndef __KGAMEPROPERTY_H_</span>
<a name="l00022"></a>00022 <span class="preprocessor"></span><span class="preprocessor">#define __KGAMEPROPERTY_H_</span>
<a name="l00023"></a>00023 <span class="preprocessor"></span>
<a name="l00024"></a>00024 <span class="preprocessor">#include &lt;qdatastream.h&gt;</span>
<a name="l00025"></a>00025 
<a name="l00026"></a>00026 <span class="preprocessor">#include &lt;kdebug.h&gt;</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include &lt;typeinfo&gt;</span>
<a name="l00028"></a>00028 <span class="preprocessor">#include &lt;kdemacros.h&gt;</span>
<a name="l00029"></a>00029 <span class="keyword">class </span><a class="code" href="classKGame.html" title="The main KDE game object.">KGame</a>;
<a name="l00030"></a>00030 <span class="keyword">class </span><a class="code" href="classKPlayer.html" title="Base class for a game player.">KPlayer</a>;
<a name="l00031"></a>00031 <span class="keyword">class </span><a class="code" href="classKGamePropertyHandler.html" title="A collection class for KGameProperty objects.">KGamePropertyHandler</a>;
<a name="l00032"></a>00032 <span class="keyword">using namespace </span>std;
<a name="l00033"></a>00033 
<a name="l00042"></a><a class="code" href="classKGamePropertyBase.html">00042</a> <span class="keyword">class </span>KDE_EXPORT <a class="code" href="classKGamePropertyBase.html" title="Base class of KGameProperty.">KGamePropertyBase</a>
<a name="l00043"></a>00043 {
<a name="l00044"></a>00044 <span class="keyword">public</span>:
<a name="l00045"></a>00045     <span class="keyword">enum</span> PropertyDataIds  { <span class="comment">// these belong to KPlayer/KGame!</span>
<a name="l00046"></a>00046         <span class="comment">//KPlayer</span>
<a name="l00047"></a>00047         IdGroup=1,
<a name="l00048"></a>00048         IdUserId=2,
<a name="l00049"></a>00049         IdAsyncInput=3,
<a name="l00050"></a>00050         IdTurn=4,
<a name="l00051"></a>00051         IdName=5,
<a name="l00052"></a>00052 
<a name="l00053"></a>00053         <span class="comment">//KGame</span>
<a name="l00054"></a>00054         IdGameStatus=6,
<a name="l00055"></a>00055         IdMaxPlayer=7,
<a name="l00056"></a>00056         IdMinPlayer=8,
<a name="l00057"></a>00057 
<a name="l00058"></a>00058     <span class="comment">// Input Grabbing</span>
<a name="l00059"></a>00059     IdGrabInput=16,
<a name="l00060"></a>00060     IdReleaseInput=17,
<a name="l00061"></a>00061 
<a name="l00062"></a>00062         IdCommand, <span class="comment">// Reserved for internal use</span>
<a name="l00063"></a>00063         IdUser=256,
<a name="l00064"></a>00064 
<a name="l00065"></a>00065         IdAutomatic=0x7000  <span class="comment">// Id's from here on are automatically given (16bit)</span>
<a name="l00066"></a>00066     };
<a name="l00067"></a>00067 
<a name="l00071"></a><a class="code" href="classKGamePropertyBase.html#7a6866f09f68dbf37e69ab161d7b8536">00071</a>     <span class="keyword">enum</span> <a class="code" href="classKGamePropertyBase.html#7a6866f09f68dbf37e69ab161d7b8536" title="Commands for advanced properties (Q_INT8).">PropertyCommandIds</a> 
<a name="l00072"></a>00072     {
<a name="l00073"></a>00073         <span class="comment">// General</span>
<a name="l00074"></a>00074         CmdLock=1,
<a name="l00075"></a>00075         
<a name="l00076"></a>00076         <span class="comment">// Array</span>
<a name="l00077"></a>00077         CmdAt=51,
<a name="l00078"></a>00078         CmdResize=52,
<a name="l00079"></a>00079         CmdFill=53,
<a name="l00080"></a>00080         CmdSort=54,
<a name="l00081"></a>00081         <span class="comment">// List (could be the same id's actually)</span>
<a name="l00082"></a>00082         CmdInsert=61,
<a name="l00083"></a>00083         CmdAppend=62,
<a name="l00084"></a>00084         CmdRemove=63,
<a name="l00085"></a>00085         CmdClear=64
<a name="l00086"></a>00086     };
<a name="l00087"></a>00087 
<a name="l00109"></a><a class="code" href="classKGamePropertyBase.html#5a1327924368b7d080a417dcac821543">00109</a>     <span class="keyword">enum</span> <a class="code" href="classKGamePropertyBase.html#5a1327924368b7d080a417dcac821543" title="The policy of the property.">PropertyPolicy</a>
<a name="l00110"></a>00110     {
<a name="l00111"></a>00111         PolicyUndefined = 0,
<a name="l00112"></a>00112         PolicyClean = 1,
<a name="l00113"></a>00113         PolicyDirty = 2,
<a name="l00114"></a>00114         PolicyLocal = 3
<a name="l00115"></a>00115     };
<a name="l00116"></a>00116 
<a name="l00117"></a>00117 
<a name="l00126"></a>00126     <a class="code" href="classKGamePropertyBase.html" title="Base class of KGameProperty.">KGamePropertyBase</a>(<span class="keywordtype">int</span> <span class="keywordtype">id</span>, <a class="code" href="classKGamePropertyHandler.html" title="A collection class for KGameProperty objects.">KGamePropertyHandler</a>* owner);
<a name="l00127"></a>00127 
<a name="l00128"></a>00128     <a class="code" href="classKGamePropertyBase.html" title="Base class of KGameProperty.">KGamePropertyBase</a>(<span class="keywordtype">int</span> <span class="keywordtype">id</span>, <a class="code" href="classKGame.html" title="The main KDE game object.">KGame</a>* parent);
<a name="l00129"></a>00129     <a class="code" href="classKGamePropertyBase.html" title="Base class of KGameProperty.">KGamePropertyBase</a>(<span class="keywordtype">int</span> <span class="keywordtype">id</span>, <a class="code" href="classKPlayer.html" title="Base class for a game player.">KPlayer</a>* parent);
<a name="l00130"></a>00130 
<a name="l00135"></a>00135     <a class="code" href="classKGamePropertyBase.html" title="Base class of KGameProperty.">KGamePropertyBase</a>();
<a name="l00136"></a>00136 
<a name="l00137"></a>00137     <span class="keyword">virtual</span> ~<a class="code" href="classKGamePropertyBase.html" title="Base class of KGameProperty.">KGamePropertyBase</a>();
<a name="l00138"></a>00138 
<a name="l00145"></a><a class="code" href="classKGamePropertyBase.html#922017bb68b766757f992e61ea3b6f16">00145</a>     <span class="keywordtype">void</span> setPolicy(<a class="code" href="classKGamePropertyBase.html#5a1327924368b7d080a417dcac821543" title="The policy of the property.">PropertyPolicy</a> p) { mFlags.bits.policy = p; } 
<a name="l00146"></a>00146 
<a name="l00150"></a><a class="code" href="classKGamePropertyBase.html#800fa663bf1830db1e8b1ee1018a0e79">00150</a>     <a class="code" href="classKGamePropertyBase.html#5a1327924368b7d080a417dcac821543" title="The policy of the property.">PropertyPolicy</a> policy()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> (<a class="code" href="classKGamePropertyBase.html#5a1327924368b7d080a417dcac821543" title="The policy of the property.">PropertyPolicy</a>)mFlags.bits.policy; }
<a name="l00151"></a>00151 
<a name="l00157"></a><a class="code" href="classKGamePropertyBase.html#47512e7fc6657f60e3b4112ae7d5b091">00157</a>     <span class="keywordtype">void</span> setEmittingSignal(<span class="keywordtype">bool</span> p)  { mFlags.bits.emitsignal=p; }
<a name="l00158"></a>00158 
<a name="l00163"></a><a class="code" href="classKGamePropertyBase.html#982e064965d7e5d1b0e39442aeb19965">00163</a>     <span class="keywordtype">bool</span> isEmittingSignal()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> mFlags.bits.emitsignal; }
<a name="l00164"></a>00164 
<a name="l00169"></a><a class="code" href="classKGamePropertyBase.html#3db9f94619d7306cf5c3e63179822db6">00169</a>     <span class="keywordtype">void</span> setOptimized(<span class="keywordtype">bool</span> p) { mFlags.bits.optimize = p ; }
<a name="l00170"></a>00170 
<a name="l00175"></a><a class="code" href="classKGamePropertyBase.html#1f22784787aa6a75c41ca6a31cfae2a3">00175</a>     <span class="keywordtype">bool</span> isOptimized()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> mFlags.bits.optimize; }
<a name="l00176"></a>00176 
<a name="l00180"></a><a class="code" href="classKGamePropertyBase.html#b0b5b01f8abcfe927966031dfc497f27">00180</a>     <span class="keywordtype">bool</span> isDirty()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> mFlags.bits.dirty; }
<a name="l00181"></a>00181 
<a name="l00187"></a><a class="code" href="classKGamePropertyBase.html#e489ae29929b2592a6b292e17de28144">00187</a>     <span class="keywordtype">bool</span> isLocked()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> mFlags.bits.locked; }
<a name="l00188"></a>00188 
<a name="l00200"></a>00200     <span class="keywordtype">bool</span> lock();
<a name="l00201"></a>00201 
<a name="l00213"></a>00213     <span class="keywordtype">bool</span> unlock(<span class="keywordtype">bool</span> force=<span class="keyword">false</span>);
<a name="l00214"></a>00214 
<a name="l00220"></a>00220     <span class="keyword">virtual</span> <span class="keywordtype">void</span> load(QDataStream&amp; s) = 0;
<a name="l00221"></a>00221 
<a name="l00225"></a>00225     <span class="keyword">virtual</span> <span class="keywordtype">void</span> save(QDataStream&amp; s) = 0;
<a name="l00226"></a>00226 
<a name="l00233"></a>00233     <span class="keyword">virtual</span> <span class="keywordtype">void</span> command(QDataStream &amp;stream, <span class="keywordtype">int</span> msgid, <span class="keywordtype">bool</span> isSender=<span class="keyword">false</span>);
<a name="l00234"></a>00234 
<a name="l00238"></a><a class="code" href="classKGamePropertyBase.html#737382aa3e0194409c3b56fcc2ea15cb">00238</a>     <span class="keywordtype">int</span> id()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> mId; }
<a name="l00239"></a>00239 
<a name="l00244"></a><a class="code" href="classKGamePropertyBase.html#1e9a0ba7673ae71c7962663ee8802cd9">00244</a>     <span class="keyword">virtual</span> <span class="keyword">const</span> type_info* typeinfo() { <span class="keywordflow">return</span> &amp;<span class="keyword">typeid</span>(<span class="keyword">this</span>); }
<a name="l00245"></a>00245 
<a name="l00264"></a>00264     <span class="keywordtype">int</span> registerData(<span class="keywordtype">int</span> <span class="keywordtype">id</span>, <a class="code" href="classKGamePropertyHandler.html" title="A collection class for KGameProperty objects.">KGamePropertyHandler</a>* owner,PropertyPolicy p, QString name=0);
<a name="l00265"></a>00265 
<a name="l00270"></a>00270     <span class="keywordtype">int</span> registerData(<span class="keywordtype">int</span> <span class="keywordtype">id</span>, <a class="code" href="classKGamePropertyHandler.html" title="A collection class for KGameProperty objects.">KGamePropertyHandler</a>* owner, QString name=0);
<a name="l00271"></a>00271 
<a name="l00276"></a>00276     <span class="keywordtype">int</span> registerData(<span class="keywordtype">int</span> <span class="keywordtype">id</span>, <a class="code" href="classKGame.html" title="The main KDE game object.">KGame</a>* owner, QString name=0);
<a name="l00277"></a>00277 
<a name="l00282"></a>00282     <span class="keywordtype">int</span> registerData(<span class="keywordtype">int</span> <span class="keywordtype">id</span>, <a class="code" href="classKPlayer.html" title="Base class for a game player.">KPlayer</a>* owner, QString name=0);
<a name="l00283"></a>00283 
<a name="l00290"></a>00290     <span class="keywordtype">int</span> registerData(<a class="code" href="classKGamePropertyHandler.html" title="A collection class for KGameProperty objects.">KGamePropertyHandler</a>* owner,PropertyPolicy p=PolicyUndefined, QString name=0);
<a name="l00291"></a>00291 
<a name="l00292"></a>00292     <span class="keywordtype">void</span> unregisterData();
<a name="l00293"></a>00293 
<a name="l00294"></a>00294  
<a name="l00295"></a>00295 <span class="keyword">protected</span>:
<a name="l00306"></a>00306     <span class="keywordtype">void</span> setLock(<span class="keywordtype">bool</span> l);
<a name="l00307"></a>00307 
<a name="l00316"></a><a class="code" href="classKGamePropertyBase.html#8e51f750e75d619b192cdd5c34d8b6a0">00316</a>     <span class="keywordtype">void</span> setDirty(<span class="keywordtype">bool</span> d) { mFlags.bits.dirty = d ; }
<a name="l00317"></a>00317 
<a name="l00329"></a>00329     <span class="keywordtype">bool</span> sendProperty();
<a name="l00330"></a>00330     
<a name="l00344"></a>00344     <span class="keywordtype">bool</span> sendProperty(<span class="keyword">const</span> QByteArray&amp; b);
<a name="l00345"></a>00345     
<a name="l00349"></a>00349     <span class="keywordtype">void</span> emitSignal();
<a name="l00350"></a>00350 
<a name="l00351"></a>00351 <span class="keyword">protected</span>:
<a name="l00352"></a>00352     <a class="code" href="classKGamePropertyHandler.html" title="A collection class for KGameProperty objects.">KGamePropertyHandler</a>* mOwner;
<a name="l00353"></a>00353     
<a name="l00354"></a>00354     <span class="comment">// Having this as a union of the bitfield and the char</span>
<a name="l00355"></a>00355     <span class="comment">// allows us to stream this quantity easily (if we need to)</span>
<a name="l00356"></a>00356     <span class="comment">// At the moment it is not yet transmitted</span>
<a name="l00357"></a>00357     <span class="keyword">union </span>Flags {
<a name="l00358"></a>00358         <span class="keywordtype">char</span> flag;
<a name="l00359"></a>00359         <span class="keyword">struct </span>{
<a name="l00360"></a>00360             <span class="comment">// unsigned char dosave : 1;   // do save this property</span>
<a name="l00361"></a>00361             <span class="comment">// unsigned char delaytransmit : 1;   // do not send immediately on</span>
<a name="l00362"></a>00362                                              <span class="comment">// change but a KPlayer:QTimer</span>
<a name="l00363"></a>00363                                              <span class="comment">// sends it later on - fast</span>
<a name="l00364"></a>00364                                              <span class="comment">// changing variables</span>
<a name="l00365"></a>00365             <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> emitsignal : 1; <span class="comment">// KPlayer notifies on variable change (true)</span>
<a name="l00366"></a>00366             <span class="comment">//unsigned char readonly : 1; // whether the property can be changed (false)</span>
<a name="l00367"></a>00367             <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> optimize : 1; <span class="comment">// whether the property tries to optimize send/emit (false)</span>
<a name="l00368"></a>00368             <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> dirty: 1; <span class="comment">// whether the property dirty (setLocal() was used)</span>
<a name="l00369"></a>00369             <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> policy : 2; <span class="comment">// whether the property is always consistent (see PropertyPolicy)</span>
<a name="l00370"></a>00370             <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> locked: 1; <span class="comment">// whether the property is locked (true)</span>
<a name="l00371"></a>00371         } bits;
<a name="l00372"></a>00372     } mFlags;
<a name="l00373"></a>00373     
<a name="l00374"></a>00374 <span class="keyword">private</span>:
<a name="l00375"></a>00375     <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classKGamePropertyHandler.html" title="A collection class for KGameProperty objects.">KGamePropertyHandler</a>;
<a name="l00376"></a>00376     <span class="keywordtype">void</span> init();
<a name="l00377"></a>00377     
<a name="l00378"></a>00378 <span class="keyword">private</span>:
<a name="l00379"></a>00379     <span class="keywordtype">int</span> mId;
<a name="l00380"></a>00380 
<a name="l00381"></a>00381 };
<a name="l00382"></a>00382 
<a name="l00580"></a>00580 <span class="keyword">template</span>&lt;<span class="keyword">class</span> type&gt;
<a name="l00581"></a><a class="code" href="classKGameProperty.html">00581</a> <span class="keyword">class </span><a class="code" href="classKGameProperty.html" title="A class for network transparent games.">KGameProperty</a>  : <span class="keyword">public</span> <a class="code" href="classKGamePropertyBase.html" title="Base class of KGameProperty.">KGamePropertyBase</a>
<a name="l00582"></a>00582 {
<a name="l00583"></a>00583 <span class="keyword">public</span>:
<a name="l00596"></a>00596 <span class="comment">// TODO: ID: Very ugly - better use something like parent()-&gt;propertyId() or so which assigns a free id automatically.</span>
<a name="l00597"></a><a class="code" href="classKGameProperty.html#ffa5ef05e76b069508028a0039dc5625">00597</a>     <a class="code" href="classKGameProperty.html#4788af0f44a62054248f377cdeabdb02" title="This constructor does nothing.">KGameProperty</a>(<span class="keywordtype">int</span> <span class="keywordtype">id</span>, <a class="code" href="classKGamePropertyHandler.html" title="A collection class for KGameProperty objects.">KGamePropertyHandler</a>* owner) : <a class="code" href="classKGamePropertyBase.html" title="Base class of KGameProperty.">KGamePropertyBase</a>(id, owner) { init(); }
<a name="l00598"></a>00598 
<a name="l00604"></a><a class="code" href="classKGameProperty.html#4788af0f44a62054248f377cdeabdb02">00604</a>     <a class="code" href="classKGameProperty.html#4788af0f44a62054248f377cdeabdb02" title="This constructor does nothing.">KGameProperty</a>() : <a class="code" href="classKGamePropertyBase.html" title="Base class of KGameProperty.">KGamePropertyBase</a>() { init(); }
<a name="l00605"></a>00605 
<a name="l00606"></a>00606     <span class="keyword">virtual</span> ~<a class="code" href="classKGameProperty.html" title="A class for network transparent games.">KGameProperty</a>() {}
<a name="l00607"></a>00607 
<a name="l00615"></a><a class="code" href="classKGameProperty.html#dbf2c949b391600d83b73d2ff9dff6e8">00615</a>     <span class="keywordtype">void</span> <a class="code" href="classKGameProperty.html#dbf2c949b391600d83b73d2ff9dff6e8" title="Set the value depending on the current policy (see setConsistent).">setValue</a>(type v)
<a name="l00616"></a>00616     {
<a name="l00617"></a>00617         <span class="keywordflow">switch</span> (<a class="code" href="classKGamePropertyBase.html#800fa663bf1830db1e8b1ee1018a0e79">policy</a>()) {
<a name="l00618"></a>00618             <span class="keywordflow">case</span> PolicyClean:
<a name="l00619"></a>00619                 <a class="code" href="classKGameProperty.html#33713f6ce7c4c801a3fbd7a3e1d27993" title="This function sends a new value over network.">send</a>(v);
<a name="l00620"></a>00620                 <span class="keywordflow">break</span>;
<a name="l00621"></a>00621             <span class="keywordflow">case</span> PolicyDirty:
<a name="l00622"></a>00622                 <a class="code" href="classKGameProperty.html#e82b8f80aae034aabea58cb95063f0c5" title="This function does both, change the local value and change the network value.">changeValue</a>(v);
<a name="l00623"></a>00623                 <span class="keywordflow">break</span>;
<a name="l00624"></a>00624             <span class="keywordflow">case</span> PolicyLocal:
<a name="l00625"></a>00625                 <a class="code" href="classKGameProperty.html#fd47964f181f5980af9b1adec5d24fb1" title="This function sets the value of the property directly, i.e.">setLocal</a>(v);
<a name="l00626"></a>00626                 <span class="keywordflow">break</span>;
<a name="l00627"></a>00627             <span class="keywordflow">default</span>: <span class="comment">// NEVER!</span>
<a name="l00628"></a>00628                 kdError(11001) &lt;&lt; <span class="stringliteral">"Undefined Policy in property "</span> &lt;&lt; <a class="code" href="classKGamePropertyBase.html#737382aa3e0194409c3b56fcc2ea15cb">id</a>() &lt;&lt; endl;
<a name="l00629"></a>00629                 <span class="keywordflow">return</span>;
<a name="l00630"></a>00630         }
<a name="l00631"></a>00631     }
<a name="l00632"></a>00632 
<a name="l00633"></a>00633 
<a name="l00670"></a><a class="code" href="classKGameProperty.html#33713f6ce7c4c801a3fbd7a3e1d27993">00670</a>     <span class="keywordtype">bool</span> <a class="code" href="classKGameProperty.html#33713f6ce7c4c801a3fbd7a3e1d27993" title="This function sends a new value over network.">send</a>(type v)
<a name="l00671"></a>00671     {
<a name="l00672"></a>00672         <span class="keywordflow">if</span> (<a class="code" href="classKGamePropertyBase.html#1f22784787aa6a75c41ca6a31cfae2a3" title="See also setOptimize.">isOptimized</a>() &amp;&amp; mData == v) {
<a name="l00673"></a>00673             <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00674"></a>00674         }
<a name="l00675"></a>00675         <span class="keywordflow">if</span> (<a class="code" href="classKGamePropertyBase.html#e489ae29929b2592a6b292e17de28144" title="A locked property can only be changed by the player who has set the lock.">isLocked</a>()) {
<a name="l00676"></a>00676             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00677"></a>00677         }
<a name="l00678"></a>00678         QByteArray b;
<a name="l00679"></a>00679         QDataStream stream(b, IO_WriteOnly);
<a name="l00680"></a>00680         stream &lt;&lt; v;
<a name="l00681"></a>00681         <span class="keywordflow">if</span> (!<a class="code" href="classKGamePropertyBase.html#b2dc4485e586ee34173e800f2c3bebab" title="Forward the data to the owner of this property which then sends it over network.">sendProperty</a>(b)) {
<a name="l00682"></a>00682             <a class="code" href="classKGameProperty.html#fd47964f181f5980af9b1adec5d24fb1" title="This function sets the value of the property directly, i.e.">setLocal</a>(v);
<a name="l00683"></a>00683             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00684"></a>00684         }
<a name="l00685"></a>00685         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00686"></a>00686     }
<a name="l00687"></a>00687 
<a name="l00715"></a><a class="code" href="classKGameProperty.html#fd47964f181f5980af9b1adec5d24fb1">00715</a>     <span class="keywordtype">bool</span> <a class="code" href="classKGameProperty.html#fd47964f181f5980af9b1adec5d24fb1" title="This function sets the value of the property directly, i.e.">setLocal</a>(type v) 
<a name="l00716"></a>00716     {
<a name="l00717"></a>00717         <span class="keywordflow">if</span> (<a class="code" href="classKGamePropertyBase.html#1f22784787aa6a75c41ca6a31cfae2a3" title="See also setOptimize.">isOptimized</a>() &amp;&amp; mData == v) {
<a name="l00718"></a>00718             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00719"></a>00719         }
<a name="l00720"></a>00720         <span class="keywordflow">if</span> (<a class="code" href="classKGamePropertyBase.html#e489ae29929b2592a6b292e17de28144" title="A locked property can only be changed by the player who has set the lock.">isLocked</a>()) {
<a name="l00721"></a>00721             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00722"></a>00722         }
<a name="l00723"></a>00723         mData = v;
<a name="l00724"></a>00724         <a class="code" href="classKGamePropertyBase.html#8e51f750e75d619b192cdd5c34d8b6a0" title="Sets the &amp;quot;dirty&amp;quot; flag of the property.">setDirty</a>(<span class="keyword">true</span>);
<a name="l00725"></a>00725         <span class="keywordflow">if</span> (<a class="code" href="classKGamePropertyBase.html#982e064965d7e5d1b0e39442aeb19965" title="See also setEmittingSignal.">isEmittingSignal</a>()) {
<a name="l00726"></a>00726             <a class="code" href="classKGamePropertyBase.html#e93e88e5679a3f22d1201599efd42fb4" title="Causes the parent object to emit a signal on value change.">emitSignal</a>();
<a name="l00727"></a>00727         }
<a name="l00728"></a>00728         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00729"></a>00729     }
<a name="l00730"></a>00730 
<a name="l00744"></a><a class="code" href="classKGameProperty.html#e82b8f80aae034aabea58cb95063f0c5">00744</a>     <span class="keywordtype">void</span> <a class="code" href="classKGameProperty.html#e82b8f80aae034aabea58cb95063f0c5" title="This function does both, change the local value and change the network value.">changeValue</a>(type v)
<a name="l00745"></a>00745     {
<a name="l00746"></a>00746         <a class="code" href="classKGameProperty.html#33713f6ce7c4c801a3fbd7a3e1d27993" title="This function sends a new value over network.">send</a>(v);
<a name="l00747"></a>00747         <a class="code" href="classKGameProperty.html#fd47964f181f5980af9b1adec5d24fb1" title="This function sets the value of the property directly, i.e.">setLocal</a>(v);
<a name="l00748"></a>00748     }
<a name="l00749"></a>00749 
<a name="l00754"></a><a class="code" href="classKGameProperty.html#a4194d022619c74a632bc03166a474f0">00754</a>     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classKGameProperty.html#a4194d022619c74a632bc03166a474f0" title="Saves the object to a stream.">save</a>(QDataStream &amp;stream)
<a name="l00755"></a>00755     {
<a name="l00756"></a>00756         stream &lt;&lt; mData;
<a name="l00757"></a>00757     }
<a name="l00758"></a>00758 
<a name="l00764"></a><a class="code" href="classKGameProperty.html#13c8d6333e09c220e9a327edeb79e074">00764</a>     <span class="keyword">const</span> type&amp; <a class="code" href="classKGameProperty.html#13c8d6333e09c220e9a327edeb79e074">value</a>()<span class="keyword"> const</span>
<a name="l00765"></a>00765 <span class="keyword">    </span>{
<a name="l00766"></a>00766         <span class="keywordflow">return</span> mData;
<a name="l00767"></a>00767     }
<a name="l00768"></a>00768 
<a name="l00780"></a><a class="code" href="classKGameProperty.html#7330f32ea354c068ce21293b14e60dbe">00780</a>     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classKGameProperty.html#7330f32ea354c068ce21293b14e60dbe" title="Reads from a stream and assigns the read value to this object.">load</a>(QDataStream&amp; s)
<a name="l00781"></a>00781     {
<a name="l00782"></a>00782         s &gt;&gt; mData;
<a name="l00783"></a>00783         <a class="code" href="classKGamePropertyBase.html#8e51f750e75d619b192cdd5c34d8b6a0" title="Sets the &amp;quot;dirty&amp;quot; flag of the property.">setDirty</a>(<span class="keyword">false</span>);
<a name="l00784"></a>00784         <span class="keywordflow">if</span> (<a class="code" href="classKGamePropertyBase.html#982e064965d7e5d1b0e39442aeb19965" title="See also setEmittingSignal.">isEmittingSignal</a>()) {
<a name="l00785"></a>00785             <a class="code" href="classKGamePropertyBase.html#e93e88e5679a3f22d1201599efd42fb4" title="Causes the parent object to emit a signal on value change.">emitSignal</a>();
<a name="l00786"></a>00786         }
<a name="l00787"></a>00787     }
<a name="l00788"></a>00788 
<a name="l00807"></a><a class="code" href="classKGameProperty.html#9b803fd7aa57ac9747ae953732aa5511">00807</a>     <span class="keyword">const</span> type&amp; <a class="code" href="classKGameProperty.html#9b803fd7aa57ac9747ae953732aa5511" title="This calls setValue to change the value of the property.">operator=</a>(<span class="keyword">const</span> type&amp; t) 
<a name="l00808"></a>00808     { 
<a name="l00809"></a>00809         <a class="code" href="classKGameProperty.html#dbf2c949b391600d83b73d2ff9dff6e8" title="Set the value depending on the current policy (see setConsistent).">setValue</a>(t); 
<a name="l00810"></a>00810         <span class="keywordflow">return</span> <a class="code" href="classKGameProperty.html#13c8d6333e09c220e9a327edeb79e074">value</a>();
<a name="l00811"></a>00811     }
<a name="l00812"></a>00812 
<a name="l00818"></a><a class="code" href="classKGameProperty.html#9661dbb23b731cd1db1195a871fb53d7">00818</a>     <span class="keyword">const</span> type&amp; <a class="code" href="classKGameProperty.html#9b803fd7aa57ac9747ae953732aa5511" title="This calls setValue to change the value of the property.">operator=</a>(<span class="keyword">const</span> <a class="code" href="classKGameProperty.html" title="A class for network transparent games.">KGameProperty</a>&amp; property)
<a name="l00819"></a>00819     {
<a name="l00820"></a>00820         <a class="code" href="classKGameProperty.html#dbf2c949b391600d83b73d2ff9dff6e8" title="Set the value depending on the current policy (see setConsistent).">setValue</a>(property.<a class="code" href="classKGameProperty.html#13c8d6333e09c220e9a327edeb79e074">value</a>());
<a name="l00821"></a>00821         <span class="keywordflow">return</span> <a class="code" href="classKGameProperty.html#13c8d6333e09c220e9a327edeb79e074">value</a>();
<a name="l00822"></a>00822     }
<a name="l00823"></a>00823 
<a name="l00831"></a><a class="code" href="classKGameProperty.html#6f85e9c088ef4f9cbe290aea6268e151">00831</a>     <a class="code" href="classKGameProperty.html#6f85e9c088ef4f9cbe290aea6268e151" title="Yeah, you can do it!">operator type</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classKGameProperty.html#13c8d6333e09c220e9a327edeb79e074">value</a>(); }
<a name="l00832"></a>00832 
<a name="l00833"></a><a class="code" href="classKGameProperty.html#8cb9c0dbdca1b166dbc080734438ee49">00833</a>     <span class="keyword">virtual</span> <span class="keyword">const</span> type_info* <a class="code" href="classKGameProperty.html#8cb9c0dbdca1b166dbc080734438ee49">typeinfo</a>() { <span class="keywordflow">return</span> &amp;<span class="keyword">typeid</span>(type); }
<a name="l00834"></a>00834 
<a name="l00835"></a>00835 <span class="keyword">private</span>:
<a name="l00836"></a>00836     <span class="keywordtype">void</span> init() { }
<a name="l00837"></a>00837 
<a name="l00838"></a>00838 <span class="keyword">private</span>:
<a name="l00839"></a>00839     type mData;
<a name="l00840"></a>00840 };
<a name="l00841"></a>00841 
<a name="l00842"></a>00842 
<a name="l00843"></a>00843 <span class="keyword">typedef</span> <a class="code" href="classKGameProperty.html" title="A class for network transparent games.">KGameProperty&lt;int&gt;</a>   <a class="code" href="classKGameProperty.html">KGamePropertyInt</a>;
<a name="l00844"></a>00844 <span class="keyword">typedef</span> <a class="code" href="classKGameProperty.html" title="A class for network transparent games.">KGameProperty&lt;unsigned int&gt;</a>   <a class="code" href="classKGameProperty.html">KGamePropertyUInt</a>;
<a name="l00845"></a>00845 <span class="keyword">typedef</span> <a class="code" href="classKGameProperty.html" title="A class for network transparent games.">KGameProperty&lt;QString&gt;</a>   <a class="code" href="classKGameProperty.html">KGamePropertyQString</a>;
<a name="l00846"></a>00846 <span class="keyword">typedef</span> <a class="code" href="classKGameProperty.html" title="A class for network transparent games.">KGameProperty&lt;Q_INT8&gt;</a>   <a class="code" href="classKGameProperty.html">KGamePropertyBool</a>;
<a name="l00847"></a>00847 
<a name="l00848"></a>00848 <span class="preprocessor">#endif</span>
</pre></div></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>