00001 /*===========================================================================*\ 00002 * * 00003 * OpenFlipper * 00004 * Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen * 00005 * www.openflipper.org * 00006 * * 00007 *---------------------------------------------------------------------------* 00008 * This file is part of OpenFlipper. * 00009 * * 00010 * OpenFlipper is free software: you can redistribute it and/or modify * 00011 * it under the terms of the GNU Lesser General Public License as * 00012 * published by the Free Software Foundation, either version 3 of * 00013 * the License, or (at your option) any later version with the * 00014 * following exceptions: * 00015 * * 00016 * If other files instantiate templates or use macros * 00017 * or inline functions from this file, or you compile this file and * 00018 * link it with other files to produce an executable, this file does * 00019 * not by itself cause the resulting executable to be covered by the * 00020 * GNU Lesser General Public License. This exception does not however * 00021 * invalidate any other reasons why the executable file might be * 00022 * covered by the GNU Lesser General Public License. * 00023 * * 00024 * OpenFlipper is distributed in the hope that it will be useful, * 00025 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00026 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00027 * GNU Lesser General Public License for more details. * 00028 * * 00029 * You should have received a copy of the GNU LesserGeneral Public * 00030 * License along with OpenFlipper. If not, * 00031 * see <http://www.gnu.org/licenses/>. * 00032 * * 00033 \*===========================================================================*/ 00034 00035 /*===========================================================================*\ 00036 * * 00037 * $Revision: 6727 $ * 00038 * $Author: moebius $ * 00039 * $Date: 2009-08-05 08:03:50 +0200 (Mi, 05. Aug 2009) $ * 00040 * * 00041 \*===========================================================================*/ 00042 00043 00044 00045 00046 //============================================================================= 00047 // 00048 // Types 00049 // 00050 //============================================================================= 00051 00058 #ifndef BASEOBJECT_HH 00059 #define BASEOBJECT_HH 00060 00061 //== INCLUDES ================================================================= 00062 00063 #include <OpenFlipper/common/GlobalDefines.hh> 00064 #include <QString> 00065 #include <QList> 00066 #include <QStringList> 00067 #include <vector> 00068 #include <QMap> 00069 #include "perObjectData.hh" 00070 00071 //== TYPEDEFS ================================================================= 00072 00073 00074 //== CLASS DEFINITION ========================================================= 00075 00080 class DLLEXPORTONLY BaseObject { 00081 friend class BaseObjectData; 00082 00083 public : 00084 00088 BaseObject(const BaseObject& _object); 00089 00090 BaseObject( BaseObject *_parent = 0); 00091 00092 virtual ~BaseObject(); 00093 00094 //=========================================================================== 00097 //=========================================================================== 00098 public: 00102 int id(); 00103 00108 int persistentId(); 00109 00112 void persistentId( int _id ); 00113 00114 private: 00120 int id_; 00121 00127 int persistentId_; 00128 00129 //=========================================================================== 00132 //=========================================================================== 00133 00134 public: 00138 bool dataType(DataType _type); 00139 00142 DataType dataType(); 00143 00147 void setDataType(DataType _type); 00148 00149 private: 00153 DataType objectType_; 00154 00157 //=========================================================================== 00160 //=========================================================================== 00161 00162 public: 00166 virtual void cleanup(); 00167 00170 //=========================================================================== 00173 //=========================================================================== 00174 public: 00176 virtual QString getObjectinfo(); 00177 00179 virtual void printObjectInfo(); 00180 00183 //=========================================================================== 00186 //=========================================================================== 00187 00188 public: 00194 bool target(); 00195 00198 void target(bool _target); 00199 00203 bool source(); 00204 00207 void source(bool _source); 00208 00211 bool flag(QString _flag); 00212 00215 void setFlag(QString _flag, bool _set); 00216 00219 QStringList flags(); 00220 00221 private: 00222 00226 QStringList flags_; 00227 00228 00231 //=========================================================================== 00234 //=========================================================================== 00235 00236 public : 00238 virtual bool visible(); 00239 00241 virtual void visible(bool _visible); 00242 00243 private : 00248 bool visible_; 00249 00252 //=========================================================================== 00255 //=========================================================================== 00256 00257 public: 00264 virtual void update(); 00265 00267 void dumpTree(); 00268 00270 virtual BaseObject* copy(); 00271 00275 //=========================================================================== 00278 //=========================================================================== 00279 00280 public: 00281 00284 BaseObject* last(); 00285 00288 BaseObject* next(); 00289 00292 int level(); 00293 00294 private: 00296 BaseObject *parentItem_; 00297 00299 QList<BaseObject*> childItems_; 00300 00301 public: 00302 //=========================================================================== 00305 //=========================================================================== 00306 00308 int row() const; 00309 00311 BaseObject *parent(); 00312 00314 void setParent(BaseObject* _parent); 00315 00318 //=========================================================================== 00321 //=========================================================================== 00322 00324 BaseObject* childExists(int _objectId); 00325 00327 BaseObject* childExists(QString _name); 00328 00330 void appendChild(BaseObject *child); 00331 00333 BaseObject *child(int row); 00334 00336 int childCount() const; 00337 00339 void removeChild( BaseObject* _item ); 00340 00342 QList< BaseObject* > getLeafs(); 00343 00345 void deleteSubtree(); 00346 00349 //=========================================================================== 00352 //=========================================================================== 00353 00359 int group(); 00360 00362 bool isGroup(); 00363 00368 bool isInGroup( int _id ); 00369 00374 bool isInGroup( QString _name ); 00375 00378 std::vector< int > getGroupIds(); 00379 00382 QStringList getGroupNames(); 00383 00384 00387 //=========================================================================== 00390 //=========================================================================== 00391 00393 QString name( ); 00394 00396 virtual void setName( QString _name ); 00397 00398 00399 private: 00400 00402 QString name_; 00403 00404 00407 //=========================================================================== 00410 //=========================================================================== 00411 00412 public: 00413 00421 void setObjectData( QString _dataName , PerObjectData* _data ); 00422 00424 void clearObjectData( QString _dataName ); 00425 00427 bool hasObjectData( QString _dataName ); 00428 00430 PerObjectData* objectData( QString _dataName ); 00431 00433 void deleteData(); 00434 00435 private: 00436 00437 QMap<QString, PerObjectData* > dataMap_; 00438 00441 }; 00442 00443 00444 //============================================================================= 00445 #endif // BASEOBJECT_HH defined 00446 //=============================================================================