00001 /*************************************************************************** 00002 * Copyright (C) 2004 - 2005 by Raphael Langerhorst * 00003 * raphael-langerhorst@gmx.at * 00004 * * 00005 * Permission is hereby granted, free of charge, to any person obtaining * 00006 * a copy of this software and associated documentation files (the * 00007 * "Software"), to deal in the Software without restriction, including * 00008 * without limitation the rights to use, copy, modify, merge, publish, * 00009 * distribute, sublicense, and/or sell copies of the Software, and to * 00010 * permit persons to whom the Software is furnished to do so, subject to * 00011 * the following conditions: * 00012 * * 00013 * The above copyright notice and this permission notice shall be * 00014 * included in all copies or substantial portions of the Software. * 00015 * * 00016 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * 00017 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 00018 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.* 00019 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR * 00020 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * 00021 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * 00022 * OTHER DEALINGS IN THE SOFTWARE. * 00023 ***************************************************************************/ 00024 00025 #ifndef GOBJECTH 00026 #define GOBJECTH 00027 00028 #include "GElementID.h" 00029 00030 #include <QList> 00031 #include <qmutex.h> 00032 00033 class QDomDocument; 00034 00035 namespace GCS 00036 { 00037 00038 class GEnergy; 00039 class GForm; 00040 class GElementData; 00041 00042 class GWorldData; 00043 00089 class GObject : public QMutex 00090 { 00091 private: 00095 GEnergy* Energy; 00096 00100 GForm* Form; 00101 00105 GElementID Parent; 00106 00110 const GElementID ID; 00111 00121 const GElementID Connection; 00122 00123 // this is left as a comment for idea gathering 00124 // /** 00125 // * consider the following situation: 00126 // * you hava a certain characteristic, for example you 00127 // * tend to be very happy; if something happens and you 00128 // * are quite unhappy for a few hours it does not mean 00129 // * that you are unhappy in general; likely you will 00130 // * recover and be (almost!!) happy as ever a few days 00131 // * later; 00132 // * (and maybe if you have learned something from the 00133 // * unexpected event so that afterwards you are even 00134 // * more happy - but this requires influence from your 00135 // * spirit...) 00136 // * 00137 // * so, if the energy changes for what reason ever 00138 // * this attribute could tell the "ordinary" state of 00139 // * the element; 00140 // * 00141 // * removed, because: 00142 // * the above comment actually is true, but we have to 00143 // * consider the way how we get unhappy when we are 00144 // * normally happy: if we get influenced by different 00145 // * circumstances than normal then it is likely that 00146 // * we also feel different; but this will go away as 00147 // * soon as the different influence also goes away!! 00148 // */ 00149 // GEnergy LongTermEnergy; 00150 00151 // The children are not stored anymore, GObject uses GWorldData for this 00152 // /** 00153 // * This value list stores all IDs of the element's children. 00154 // */ 00155 // QValueList<GElementID> Children; 00156 00164 GElementData* ElementData; 00165 00172 const GWorldData* WorldData; 00173 00174 public: 00175 00179 GObject(GEnergy* energy, 00180 GForm* form, 00181 const GElementID& parent, 00182 const GElementID& ID, 00183 const GElementID& connection, 00184 GElementData* ElementData, 00185 const GWorldData* WorldData); 00186 00190 virtual ~GObject(); 00191 00192 // read methods: 00193 00197 bool hasEnergy() const; 00198 00202 GEnergy* getEnergy(); 00203 00207 const GEnergy* getEnergy() const; 00208 00212 bool hasForm() const; 00213 00217 GForm* getForm(); 00218 00222 const GForm* getForm() const; 00223 00227 const GElementID& getParent() const; 00228 00232 const GElementID& getID() const; 00233 00237 const GElementID& getConnection() const; 00238 00242 bool hasElementData() const; 00243 00247 const GElementData* getElementData() const; 00248 00252 GElementData* getElementData(); 00253 00257 bool hasWorldData() const; 00258 00262 const GWorldData* getWorldData() const; 00263 00264 // methods for hierarchy management: 00265 00269 void reparent(const GElementID& new_parent); 00270 00278 bool isChild(const GElementID&) const; 00279 00283 QList<GElementID> getChildren() const; 00284 }; 00285 00286 } 00287 00288 #endif
1.4.7