Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

stolist.h

00001 // $Id: stolist_8h-source.html,v 1.2 2002/06/20 17:09:51 mkrohn5 Exp $
00002 
00003 // Stellar Object List Header File
00004 // Written by: Jai Shaw, Marco Krohn
00005 
00006 // Copyright (C) 1996 - 1999, Jai Shaw, <Jai@towersoft.com.au>
00007 //               2000 - 2001, Marco Krohn, <marco.krohn@gmx.de>
00008 //
00009 // This program is free software; you can redistribute it and/or modify
00010 // it under the terms of the GNU General Public License as published by
00011 // the Free Software Foundation; either version 2, or (at your option)
00012 // any later version.
00013 //
00014 // This program is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU General Public License for more details.
00018 
00019 #ifndef __STELLAR_OBJECT_LIST_INCLUDED
00020 #define __STELLAR_OBJECT_LIST_INCLUDED
00021 
00022 #include <algorithm>
00023 #include <list>
00024 #include <string>
00025 
00026 #include "common/point.h"
00027 #include "gamelogic/race.h"
00028 
00029 class TGalaxy;
00030 class TObjectID;
00031 class TStellarObject;
00032 class TSOLFilter;
00033 class TPlayer;
00034 
00035 
00036 
00037 
00038 //----------------------------------------  class TStellarObjectList  ----------------------------------------
00039 
00049 class TStellarObjectList : public list<TStellarObject*>
00050 {
00051   public:
00052     friend class TCompareByDistance;
00053 
00057     TStellarObjectList();
00061     TStellarObjectList( const TStellarObjectList& List );
00062 
00068     TStellarObjectList& Add( TStellarObject* pObject );
00074     TStellarObjectList& Add( const TStellarObjectList& List );
00088     double ApplyFilterMinDistance( const TPoint& Point, double dEpsilon=0.001 );
00097     int Filter( TStellarObjectList* newlist, const TSOLFilter& f, const bool clear = false ) const;
00098 
00099     TStellarObjectList& operator=( TStellarObject* pObject );
00100     TStellarObjectList& operator=( const TStellarObjectList& List );
00101     TStellarObjectList operator+( TStellarObject* pObject ) const;
00102     TStellarObjectList operator+( const TStellarObjectList& List ) const;
00109     TStellarObjectList& operator+=( TStellarObject* pObject );
00116     TStellarObjectList& operator+=( const TStellarObjectList& List );
00121     void showContent() const;
00126     void SortByDistance( const TPoint& Pos );
00130     void SortByID();
00134     void SortByName();
00138     void SortByType();
00139 
00140   private:
00142     TPoint fReferencePos;
00143 
00150     bool CompareByDistance( TStellarObject* x, TStellarObject* y );
00151 };
00152 
00153 
00154 
00155 class TSOLFilter {
00156   public:
00157     virtual ~TSOLFilter() {};
00158     virtual bool operator()( TStellarObject& obj ) const = 0;
00159 };
00160 
00161 
00162 class TSOLFilterCreator : public TSOLFilter {
00163   public:
00164     bool operator()( TStellarObject& obj ) const;
00165     TSOLFilterCreator(const TRace& creator) : fCreator(&creator) {};
00166 
00167   private:
00168     const TRace* fCreator;
00169 };
00170 
00171 
00172 
00173 class TSOLFilterOwner : public TSOLFilter {
00174   public:
00175     bool operator()( TStellarObject& obj ) const;
00176     TSOLFilterOwner(const TRace& own) : fOwner(&own) {};
00177 
00178   private:
00179     const TRace* fOwner;
00180 };
00181 
00182 
00183 class TSOLFilterController : public TSOLFilter {
00184   public:
00185     bool operator()( TStellarObject& obj ) const;
00186     TSOLFilterController(const TPlayer& control) : fController(&control) {};
00187 
00188   private:
00189     const TPlayer* fController;
00190 };
00191 
00192 
00193 class TSOLFilterPosition : public TSOLFilter {
00194   public:
00195     bool operator()( TStellarObject& obj ) const;
00196     TSOLFilterPosition(const TPoint& pos, double radius = 0) : 
00197       fPosition(pos), fRadius(radius) {};
00198 
00199   private:
00200     TPoint fPosition;
00201     double fRadius;
00202 };
00203 
00204 
00205 class TSOLFilterName : public TSOLFilter {
00206   public:
00207     bool operator()( TStellarObject& obj ) const;
00208     TSOLFilterName(const string& name) : fName(name) {} ;
00209 
00210   private:
00211     string fName;
00212 };
00213 
00214 
00215 class TSOLFilterType : public TSOLFilter {
00216   public:
00217     bool operator()( TStellarObject& obj ) const;
00218     TSOLFilterType(const int2 type) : fType(type) {} ;
00219 
00220   private:
00221     const int2 fType;
00222 };
00223 
00224 
00225 class TSOLFilterAND : public TSOLFilter {
00226   public:
00227     bool operator()( TStellarObject& obj ) const;
00228     TSOLFilterAND(const TSOLFilter& f1, const TSOLFilter& f2) : fF1(f1), fF2(f2) {} ;
00229 
00230   private:
00231     const TSOLFilter& fF1;
00232     const TSOLFilter& fF2;
00233 };
00234 
00235 
00236 class TSOLFilterOR : public TSOLFilter {
00237   public:
00238     bool operator()( TStellarObject& obj ) const;
00239     TSOLFilterOR(const TSOLFilter& f1, const TSOLFilter& f2) : fF1(f1), fF2(f2) {} ;
00240 
00241   private:
00242     const TSOLFilter& fF1;
00243     const TSOLFilter& fF2;
00244 };
00245 
00246 
00247 
00248 
00249 
00250 #endif        // __STELLAR_OBJECT_LIST_INCLUDED

Generated on Thu Jun 20 18:13:16 2002 for Stellar Legacy by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001