src/tron/zone/zValidator.h

Go to the documentation of this file.
00001 /*
00002 
00003 *************************************************************************
00004 
00005 ArmageTron -- Just another Tron Lightcycle Game in 3D.
00006 Copyright (C) 2000  Manuel Moos (manuel@moosnet.de)
00007 
00008 **************************************************************************
00009 
00010 This program is free software; you can redistribute it and/or
00011 modify it under the terms of the GNU General Public License
00012 as published by the Free Software Foundation; either version 2
00013 of the License, or (at your option) any later version.
00014 
00015 This program is distributed in the hope that it will be useful,
00016 but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 GNU General Public License for more details.
00019 
00020 You should have received a copy of the GNU General Public License
00021 along with this program; if not, write to the Free Software
00022 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00023 
00024 ***************************************************************************
00025 
00026 */
00027 
00028 #ifndef ARMAGETRONAD_H_VALIDATOR
00029 #define ARMAGETRONAD_H_VALIDATOR
00030 
00031 
00032 #include <vector>
00033 #include <boost/shared_ptr.hpp>
00034 #include "gVectorExtra.h"
00035 #include "ePlayer.h"
00036 #include "gCycle.h"
00037 #include "eTeam.h"
00038 #include "zone/zMisc.h"
00039 #include <boost/shared_ptr.hpp>
00040 #include "tPolynomial.h"
00041 
00042 class zSelector;
00043 typedef boost::shared_ptr<zSelector> zSelectorPtr;
00044 typedef std::vector< zSelectorPtr > zSelectorPtrs;
00045 
00046 class zMonitorInfluence;
00047 typedef boost::shared_ptr<zMonitorInfluence> zMonitorInfluencePtr;
00048 typedef std::vector< zMonitorInfluencePtr > zMonitorInfluencePtrs;
00049 
00050 class zZoneInfluence;
00051 typedef boost::shared_ptr<zZoneInfluence> zZoneInfluencePtr;
00052 typedef std::vector< zZoneInfluencePtr > zZoneInfluencePtrs;
00053 
00054 class zValidator
00055 {
00056 public:
00057     static zValidator* create(Triad _positive, Triad _marked);
00058     zValidator(Triad _positive, Triad _marked);
00059     zValidator(zValidator const &other);
00060     void operator=(zValidator const &other); 
00061     virtual zValidator *copy(void) const;
00062     virtual ~zValidator() {};
00063 
00064     void validate(gVectorExtra< nNetObjectID > &owners, gVectorExtra< nNetObjectID > &teamOwners, Triggerer possibleUser, const tPolynomial<nMessage> &tp);
00065 
00066     void addSelector(zSelectorPtr _selector) {
00067         selectors.push_back(_selector);
00068     };
00069     void addMonitorInfluence(zMonitorInfluencePtr newInfluence) {
00070         monitorInfluences.push_back( newInfluence );
00071     };
00072     void addZoneInfluence(zZoneInfluencePtr newInfluence) {
00073         zoneInfluences.push_back( newInfluence );
00074     };
00075 
00076     Triad getPositive(void) const {
00077         return positive;
00078     };
00079     Triad getMarked(void) const {
00080         return marked;
00081     };
00082 
00083 protected:
00084     zSelectorPtrs selectors;
00085     zMonitorInfluencePtrs monitorInfluences;
00086     zZoneInfluencePtrs zoneInfluences;
00087 
00088     Triad positive; // Should the possible user make a positive contribution. ATM this is only for monitors. Anything else should use _ignore
00089     Triad marked; // Should the possible user be "marked". ATM this is only for monitors. Anything else should use _ignore
00090 
00091 
00092     bool isOwner(ePlayerNetID *possibleOwner, gVectorExtra< nNetObjectID > &owners);
00093     bool isTeamOwner(eTeam *possibleTeamOwner, gVectorExtra< nNetObjectID > &teamOwners);
00094     virtual bool isValid(gVectorExtra< nNetObjectID > &owners, gVectorExtra< nNetObjectID > &teamOwners, gCycle* possibleUser) {
00095         return false;
00096     };
00097 };
00098 
00099 
00100 class zValidatorAll : public zValidator
00101 {
00102 public:
00103     static zValidator* create(Triad _positive, Triad _marked);
00104     zValidatorAll(Triad _positive, Triad _marked);
00105     zValidatorAll(zValidatorAll const &other);
00106     void operator=(zValidatorAll const &other); 
00107     virtual ~zValidatorAll() {};
00108     zValidator *copy(void) const;
00109 protected:
00110     bool isValid(gVectorExtra< nNetObjectID > &owners, gVectorExtra< nNetObjectID > &teamOwners, gCycle* possibleUser) {
00111         return true ;
00112     };
00113 };
00114 
00115 class zValidatorOwner : public zValidator
00116 {
00117 public:
00118     static zValidator* create(Triad _positive, Triad _marked);
00119     zValidatorOwner(Triad _positive, Triad _marked);
00120     zValidatorOwner(zValidatorOwner const &other);
00121     void operator=(zValidatorOwner const &other); 
00122     virtual ~zValidatorOwner() {};
00123     zValidator *copy(void) const;
00124 protected:
00125     bool isValid(gVectorExtra< nNetObjectID > &owners, gVectorExtra< nNetObjectID > &teamOwners, gCycle* possibleUser);
00126 };
00127 
00128 class zValidatorOwnerTeam : public zValidator
00129 {
00130 public:
00131     static zValidator* create(Triad _positive, Triad _marked);
00132     zValidatorOwnerTeam(Triad _positive, Triad _marked);
00133     zValidatorOwnerTeam(zValidatorOwnerTeam const &other);
00134     void operator=(zValidatorOwnerTeam const &other); 
00135     virtual ~zValidatorOwnerTeam() {};
00136     zValidator *copy(void) const;
00137 protected:
00138     bool isValid(gVectorExtra< nNetObjectID > &owners, gVectorExtra< nNetObjectID > &teamOwners, gCycle* possibleUser);
00139 };
00140 
00141 class zValidatorAllButOwner : public zValidator
00142 {
00143 public:
00144     static zValidator* create(Triad _positive, Triad _marked);
00145     zValidatorAllButOwner(Triad _positive, Triad _marked);
00146     zValidatorAllButOwner(zValidatorAllButOwner const &other);
00147     void operator=(zValidatorAllButOwner const &other); 
00148     virtual ~zValidatorAllButOwner() {};
00149     zValidator *copy(void) const;
00150 protected:
00151     bool isValid(gVectorExtra< nNetObjectID > &owners, gVectorExtra< nNetObjectID > &teamOwners, gCycle* possibleUser);
00152 };
00153 
00154 class zValidatorAllButTeamOwner : public zValidator
00155 {
00156 public:
00157     static zValidator* create(Triad _positive, Triad _marked);
00158     zValidatorAllButTeamOwner(Triad _positive, Triad _marked);
00159     zValidatorAllButTeamOwner(zValidatorAllButTeamOwner const &other);
00160     void operator=(zValidatorAllButTeamOwner const &other); 
00161     virtual ~zValidatorAllButTeamOwner() {};
00162     zValidator *copy(void) const;
00163 protected:
00164     bool isValid(gVectorExtra< nNetObjectID > &owners, gVectorExtra< nNetObjectID > &teamOwners, gCycle* possibleUser);
00165 };
00166 
00167 
00168 
00169 /*
00170  * ******** WARNING *********
00171  * This include has to be at the end of this file to break a cyclic referencing.
00172  * The classes involved are, in order:
00173  *
00174  * zMonitorRule
00175  * zEffectGroup
00176  * zValidator
00177  * zMonitorInfluence
00178  * wich points back to zMonitorRule
00179  * ******** WARNING *********
00180  */
00181 #include "zone/zMonitor.h"
00182 #include "zone/zSelector.h"
00183 #include "zone/zZoneInfluence.h"
00184 
00185 #endif

Generated on Sat Mar 15 22:56:13 2008 for Armagetron Advanced by  doxygen 1.5.4