player_predicate.h

説明を見る。
00001 // -*-c++-*-
00002 
00008 /*
00009  *Copyright:
00010 
00011  Copyright (C) Hiroki SHIMORA, Hidehisa AKIYAMA
00012 
00013  This code is free software; you can redistribute it and/or
00014  modify it under the terms of the GNU Lesser General Public
00015  License as published by the Free Software Foundation; either
00016  version 2.1 of the License, or (at your option) any later version.
00017 
00018  This library is distributed in the hope that it will be useful,
00019  but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00021  Lesser General Public License for more details.
00022 
00023  You should have received a copy of the GNU Lesser General Public
00024  License along with this library; if not, write to the Free Software
00025  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026 
00027  *EndCopyright:
00028  */
00029 
00031 
00032 
00033 #ifndef RCSC_PLAYER_PLAYER_PREDICATE_H
00034 #define RCSC_PLAYER_PLAYER_PREDICATE_H
00035 
00036 #include <rcsc/player/abstract_player_object.h>
00037 #include <rcsc/player/world_model.h>
00038 #include <rcsc/math_util.h>
00039 
00040 #include <boost/shared_ptr.hpp>
00041 
00042 #include <vector>
00043 #include <algorithm>
00044 #include <cmath>
00045 
00046 namespace rcsc {
00047 
00052 class PlayerPredicate {
00053 protected:
00057     PlayerPredicate()
00058       { }
00059 
00060 public:
00064     virtual
00065     ~PlayerPredicate()
00066       { }
00067 
00073     virtual
00074     bool operator()( const AbstractPlayerObject & p ) const = 0;
00075 };
00076 
00081 class SelfPlayerPredicate
00082     : public PlayerPredicate {
00083 private:
00085     const WorldModel & M_world;
00086 
00087     // not used
00088     SelfPlayerPredicate();
00089 public:
00094     explicit
00095     SelfPlayerPredicate( const WorldModel & wm )
00096         : M_world( wm )
00097       { }
00098 
00104     bool operator()( const AbstractPlayerObject & p ) const
00105       {
00106           return p.side() == M_world.self().side()
00107               && p.unum() == M_world.self().unum();
00108       }
00109 };
00110 
00115 class TeammateOrSelfPlayerPredicate
00116     : public PlayerPredicate {
00117 private:
00119     const WorldModel & M_world;
00120 
00121     // not used
00122     TeammateOrSelfPlayerPredicate();
00123 public:
00128     explicit
00129     TeammateOrSelfPlayerPredicate( const WorldModel & wm )
00130         : M_world( wm )
00131       { }
00132 
00138     bool operator()( const AbstractPlayerObject & p ) const
00139       {
00140           return p.side() == M_world.self().side();
00141       }
00142 };
00143 
00148 class TeammatePlayerPredicate
00149     : public PlayerPredicate {
00150 private:
00152     const WorldModel & M_world;
00153 
00154     // not used
00155     TeammatePlayerPredicate();
00156 public:
00161     explicit
00162     TeammatePlayerPredicate( const WorldModel & wm )
00163         : M_world( wm )
00164       { }
00165 
00171     bool operator()( const AbstractPlayerObject & p ) const
00172       {
00173           return p.side() == M_world.self().side()
00174               && p.unum() != M_world.self().unum();
00175       }
00176 };
00177 
00184 class OpponentPlayerPredicate
00185     : public PlayerPredicate {
00186 private:
00188     const WorldModel & M_world;
00189 
00190     // not used
00191     OpponentPlayerPredicate();
00192 public:
00197     explicit
00198     OpponentPlayerPredicate( const WorldModel & wm )
00199         : M_world( wm )
00200       { }
00201 
00207     bool operator()( const AbstractPlayerObject & p ) const
00208       {
00209           return p.side() != M_world.self().side()
00210               && p.side() != NEUTRAL;
00211       }
00212 };
00213 
00218 class OpponentOrUnknownPlayerPredicate
00219     : public PlayerPredicate {
00220 private:
00222     const WorldModel & M_world;
00223 
00224     // not used
00225     OpponentOrUnknownPlayerPredicate();
00226 public:
00231     explicit
00232     OpponentOrUnknownPlayerPredicate( const WorldModel & wm )
00233         : M_world( wm )
00234       { }
00235 
00241     bool operator()( const AbstractPlayerObject & p ) const
00242       {
00243           return p.side() != M_world.self().side();
00244       }
00245 };
00246 
00251 class GoaliePlayerPredicate
00252     : public PlayerPredicate {
00253 public:
00254 
00260     bool operator()( const AbstractPlayerObject & p ) const
00261       {
00262           return p.goalie();
00263       }
00264 };
00265 
00270 class FieldPlayerPlayerPredicate
00271     : public PlayerPredicate {
00272 public:
00273 
00279     bool operator()( const AbstractPlayerObject & p ) const
00280       {
00281           return ! p.goalie();
00282       }
00283 };
00284 
00289 class CoordinateAccuratePlayerPredicate
00290     : public PlayerPredicate {
00291 private:
00293     const int M_threshold;
00294 
00295     // not used
00296     CoordinateAccuratePlayerPredicate();
00297 public:
00302     explicit
00303     CoordinateAccuratePlayerPredicate( const int threshold )
00304         : M_threshold( threshold )
00305       { }
00306 
00312     bool operator()( const AbstractPlayerObject & p ) const
00313       {
00314           return p.posCount() <= M_threshold;
00315       }
00316 };
00317 
00322 class XCoordinateForwardPlayerPredicate
00323     : public PlayerPredicate {
00324 private:
00326     const double M_threshold;
00327 
00328     // not used
00329     XCoordinateForwardPlayerPredicate();
00330 public:
00335     explicit
00336     XCoordinateForwardPlayerPredicate( const double & threshold )
00337         : M_threshold( threshold )
00338       { }
00339 
00345     bool operator()( const AbstractPlayerObject & p ) const
00346       {
00347           return p.pos().x >= M_threshold;
00348       }
00349 };
00350 
00355 class XCoordinateBackwardPlayerPredicate
00356     : public PlayerPredicate {
00357 private:
00359     const double M_threshold;
00360 
00361     // not used
00362     XCoordinateBackwardPlayerPredicate();
00363 public:
00368     explicit
00369     XCoordinateBackwardPlayerPredicate( const double & threshold )
00370         : M_threshold( threshold )
00371       { }
00372 
00378     bool operator()( const AbstractPlayerObject & p ) const
00379       {
00380           return p.pos().x <= M_threshold;
00381       }
00382 };
00383 
00388 class YCoordinatePlusPlayerPredicate
00389     : public PlayerPredicate {
00390 private:
00392     const double M_threshold;
00393 
00394     // not used
00395     YCoordinatePlusPlayerPredicate();
00396 public:
00401     explicit
00402     YCoordinatePlusPlayerPredicate( const double & threshold )
00403         : M_threshold( threshold )
00404       { }
00405 
00411     bool operator()( const AbstractPlayerObject & p ) const
00412       {
00413           return p.pos().y >= M_threshold;
00414       }
00415 };
00416 
00421 class YCoordinateMinusPlayerPredicate
00422     : public PlayerPredicate {
00423 private:
00425     const double M_threshold;
00426 
00427     // not used
00428     YCoordinateMinusPlayerPredicate();
00429 public:
00434     explicit
00435     YCoordinateMinusPlayerPredicate( const double & threshold )
00436         : M_threshold( threshold )
00437       { }
00438 
00444     bool operator()( const AbstractPlayerObject & p ) const
00445       {
00446           return p.pos().y <= M_threshold;
00447       }
00448 };
00449 
00454 class PointFarPlayerPredicate
00455     : public PlayerPredicate {
00456 private:
00458     const Vector2D M_base_point;
00460     const double M_threshold2;
00461 
00462     // not used
00463     PointFarPlayerPredicate();
00464 public:
00470     PointFarPlayerPredicate( const Vector2D & base_point,
00471                              const double & threshold )
00472         : M_base_point( base_point )
00473         , M_threshold2( threshold * threshold )
00474       { }
00475 
00481     bool operator()( const AbstractPlayerObject & p ) const
00482       {
00483           return ( p.pos() - M_base_point ).r2() >= M_threshold2;
00484       }
00485 };
00486 
00491 class PointNearPlayerPredicate
00492     : public PlayerPredicate {
00493 private:
00495     const Vector2D M_base_point;
00497     const double M_threshold2;
00498 
00499     // not used
00500     PointNearPlayerPredicate();
00501 public:
00507     PointNearPlayerPredicate( const Vector2D & base_point,
00508                               const double & threshold )
00509         : M_base_point( base_point )
00510         , M_threshold2( threshold * threshold )
00511       { }
00512 
00518     bool operator()( const AbstractPlayerObject & p ) const
00519       {
00520           return ( p.pos() - M_base_point ).r2() <= M_threshold2;
00521       }
00522 };
00523 
00528 class AbsAngleDiffLessPlayerPredicate
00529     : public PlayerPredicate {
00530 private:
00532     const Vector2D M_base_point;
00534     const AngleDeg M_base_angle;
00536     const double M_threshold;
00537 
00538     // not used
00539     AbsAngleDiffLessPlayerPredicate();
00540 public:
00547     AbsAngleDiffLessPlayerPredicate( const Vector2D & base_point,
00548                                      const AngleDeg & base_angle,
00549                                      const double & degree_threshold )
00550         : M_base_point( base_point )
00551         , M_base_angle( base_angle ),
00552           M_threshold( std::fabs( degree_threshold ) )
00553       { }
00554 
00560     bool operator()( const AbstractPlayerObject & p ) const
00561       {
00562           return ( ( p.pos() - M_base_point ).th() - M_base_angle ).abs() <= M_threshold;
00563       }
00564 };
00565 
00570 class AbsAngleDiffGreaterPlayerPredicate
00571     : public PlayerPredicate {
00572 private:
00574     const Vector2D M_base_point;
00576     const AngleDeg M_base_angle;
00578     const double M_threshold;
00579 
00580     // not used
00581     AbsAngleDiffGreaterPlayerPredicate();
00582 public:
00589     AbsAngleDiffGreaterPlayerPredicate( const Vector2D & base_point,
00590                                         const AngleDeg & base_angle,
00591                                         const double & threshold )
00592         : M_base_point( base_point )
00593         , M_base_angle( base_angle )
00594         , M_threshold( std::fabs( threshold ) )
00595       { }
00596 
00602     bool operator()( const AbstractPlayerObject & p ) const
00603       {
00604           return ( ( p.pos() - M_base_point ).th() - M_base_angle ).abs() >= M_threshold;
00605       }
00606 };
00607 
00612 class OffsidePositionPlayerPredicate
00613     : public PlayerPredicate {
00614 private:
00616     const WorldModel & M_world;
00617 
00618     // not used
00619     OffsidePositionPlayerPredicate();
00620 public:
00625     OffsidePositionPlayerPredicate( const WorldModel & wm )
00626         : M_world( wm )
00627       { }
00628 
00634     bool operator()( const AbstractPlayerObject & p ) const
00635       {
00636           if ( p.side() == M_world.self().side() )
00637           {
00638               return p.pos().x > M_world.offsideLineX();
00639           }
00640           else if ( p.side() == NEUTRAL )
00641           {
00642               return false;
00643           }
00644           else
00645           {
00646               return p.pos().x < bound( M_world.ball().pos().x, M_world.defenseLineX(), 0.0 );
00647           }
00648       }
00649 };
00650 
00655 class ExistNearPlayerPlayerPredicate
00656     : public PlayerPredicate {
00657 
00658 private:
00660     const rcsc::WorldModel & M_world;
00661 
00663     std::auto_ptr<const rcsc::PlayerPredicate> M_predicate;
00664 
00666     double M_threshold2;
00667 
00668 public:
00669     ExistNearPlayerPlayerPredicate( const rcsc::WorldModel & wm,
00670                                     const rcsc::PlayerPredicate * predicate,
00671                                     double threshold )
00672         : M_world( wm )
00673         , M_predicate( predicate )
00674         , M_threshold2( threshold * threshold )
00675       {
00676       }
00677 
00678     bool operator() ( const rcsc::AbstractPlayerObject & p ) const
00679       {
00680           const rcsc::AbstractPlayerCont::const_iterator end = M_world.allPlayers().end();
00681           for ( rcsc::AbstractPlayerCont::const_iterator it = M_world.allPlayers().begin();
00682                 it != end;
00683                 ++ it )
00684           {
00685               if ( ((**it).pos() - p.pos()).r2() <= M_threshold2
00686                    && (*M_predicate)( **it ) )
00687               {
00688                   return true;
00689               }
00690           }
00691 
00692           return false;
00693       }
00694 };
00695 
00700 class AndPlayerPredicate
00701     : public PlayerPredicate {
00702 private:
00704     std::vector< boost::shared_ptr< const PlayerPredicate > > M_predicates;
00705 
00706     // not used
00707     AndPlayerPredicate();
00708 public:
00709     // XXX: implicit_shared_ptr
00710 
00716     AndPlayerPredicate( const PlayerPredicate * p1 ,
00717                         const PlayerPredicate * p2 )
00718         : M_predicates()
00719       {
00720           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p1 ) );
00721           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p2 ) );
00722       }
00723 
00730     AndPlayerPredicate( const PlayerPredicate * p1 ,
00731                         const PlayerPredicate * p2 ,
00732                         const PlayerPredicate * p3 )
00733         : M_predicates()
00734       {
00735           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p1 ) );
00736           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p2 ) );
00737           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p3 ) );
00738       }
00739 
00747     AndPlayerPredicate( const PlayerPredicate * p1 ,
00748                         const PlayerPredicate * p2 ,
00749                         const PlayerPredicate * p3 ,
00750                         const PlayerPredicate * p4 )
00751         : M_predicates()
00752       {
00753           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p1 ) );
00754           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p2 ) );
00755           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p3 ) );
00756           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p4 ) );
00757       }
00758 
00767     AndPlayerPredicate( const PlayerPredicate * p1 ,
00768                         const PlayerPredicate * p2 ,
00769                         const PlayerPredicate * p3 ,
00770                         const PlayerPredicate * p4 ,
00771                         const PlayerPredicate * p5 )
00772         : M_predicates()
00773       {
00774           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p1 ) );
00775           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p2 ) );
00776           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p3 ) );
00777           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p4 ) );
00778           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p5 ) );
00779       }
00780 
00790     AndPlayerPredicate( const PlayerPredicate * p1 ,
00791                         const PlayerPredicate * p2 ,
00792                         const PlayerPredicate * p3 ,
00793                         const PlayerPredicate * p4 ,
00794                         const PlayerPredicate * p5 ,
00795                         const PlayerPredicate * p6 )
00796         : M_predicates()
00797       {
00798           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p1 ) );
00799           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p2 ) );
00800           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p3 ) );
00801           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p4 ) );
00802           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p5 ) );
00803           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p6 ) );
00804       }
00805 
00816     AndPlayerPredicate( const PlayerPredicate * p1 ,
00817                         const PlayerPredicate * p2 ,
00818                         const PlayerPredicate * p3 ,
00819                         const PlayerPredicate * p4 ,
00820                         const PlayerPredicate * p5 ,
00821                         const PlayerPredicate * p6 ,
00822                         const PlayerPredicate * p7 )
00823         : M_predicates()
00824       {
00825           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p1 ) );
00826           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p2 ) );
00827           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p3 ) );
00828           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p4 ) );
00829           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p5 ) );
00830           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p6 ) );
00831           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p7 ) );
00832       }
00833 
00845     AndPlayerPredicate( const PlayerPredicate * p1 ,
00846                         const PlayerPredicate * p2 ,
00847                         const PlayerPredicate * p3 ,
00848                         const PlayerPredicate * p4 ,
00849                         const PlayerPredicate * p5 ,
00850                         const PlayerPredicate * p6 ,
00851                         const PlayerPredicate * p7 ,
00852                         const PlayerPredicate * p8 )
00853         : M_predicates()
00854       {
00855           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p1 ) );
00856           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p2 ) );
00857           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p3 ) );
00858           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p4 ) );
00859           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p5 ) );
00860           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p6 ) );
00861           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p7 ) );
00862           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p8 ) );
00863       }
00864 
00870     bool operator()( const AbstractPlayerObject & p ) const
00871       {
00872           const std::vector< boost::shared_ptr< const PlayerPredicate > >::const_iterator
00873               p_end = M_predicates.end();
00874 
00875           for ( std::vector< boost::shared_ptr< const PlayerPredicate > >::const_iterator
00876                     it = M_predicates.begin();
00877                 it != p_end;
00878                 ++it )
00879           {
00880               if ( ! (**it)( p ) )
00881               {
00882                   return false;
00883               }
00884           }
00885 
00886           return true;
00887       }
00888 };
00889 
00894 class OrPlayerPredicate
00895     : public PlayerPredicate {
00896 private:
00898     std::vector< boost::shared_ptr< const PlayerPredicate > > M_predicates;
00899 
00900     // not used
00901     OrPlayerPredicate();
00902 public:
00903     // XXX: implicit_shared_ptr
00904 
00910     OrPlayerPredicate( const PlayerPredicate * p1 ,
00911                        const PlayerPredicate * p2 )
00912         : M_predicates()
00913       {
00914           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p1 ) );
00915           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p2 ) );
00916       }
00917 
00924     OrPlayerPredicate( const PlayerPredicate * p1 ,
00925                        const PlayerPredicate * p2 ,
00926                        const PlayerPredicate * p3 )
00927         : M_predicates()
00928       {
00929           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p1 ) );
00930           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p2 ) );
00931           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p3 ) );
00932       }
00933 
00941     OrPlayerPredicate( const PlayerPredicate * p1 ,
00942                        const PlayerPredicate * p2 ,
00943                        const PlayerPredicate * p3 ,
00944                        const PlayerPredicate * p4 )
00945         : M_predicates()
00946       {
00947           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p1 ) );
00948           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p2 ) );
00949           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p3 ) );
00950           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p4 ) );
00951       }
00952 
00961     OrPlayerPredicate( const PlayerPredicate * p1 ,
00962                        const PlayerPredicate * p2 ,
00963                        const PlayerPredicate * p3 ,
00964                        const PlayerPredicate * p4 ,
00965                        const PlayerPredicate * p5 )
00966         : M_predicates()
00967       {
00968           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p1 ) );
00969           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p2 ) );
00970           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p3 ) );
00971           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p4 ) );
00972           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p5 ) );
00973       }
00974 
00984     OrPlayerPredicate( const PlayerPredicate * p1 ,
00985                        const PlayerPredicate * p2 ,
00986                        const PlayerPredicate * p3 ,
00987                        const PlayerPredicate * p4 ,
00988                        const PlayerPredicate * p5 ,
00989                        const PlayerPredicate * p6 )
00990         : M_predicates()
00991       {
00992           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p1 ) );
00993           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p2 ) );
00994           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p3 ) );
00995           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p4 ) );
00996           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p5 ) );
00997           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p6 ) );
00998       }
00999 
01010     OrPlayerPredicate( const PlayerPredicate * p1 ,
01011                        const PlayerPredicate * p2 ,
01012                        const PlayerPredicate * p3 ,
01013                        const PlayerPredicate * p4 ,
01014                        const PlayerPredicate * p5 ,
01015                        const PlayerPredicate * p6 ,
01016                        const PlayerPredicate * p7 )
01017         : M_predicates()
01018       {
01019           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p1 ) );
01020           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p2 ) );
01021           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p3 ) );
01022           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p4 ) );
01023           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p5 ) );
01024           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p6 ) );
01025           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p7 ) );
01026       }
01027 
01039     OrPlayerPredicate( const PlayerPredicate * p1 ,
01040                        const PlayerPredicate * p2 ,
01041                        const PlayerPredicate * p3 ,
01042                        const PlayerPredicate * p4 ,
01043                        const PlayerPredicate * p5 ,
01044                        const PlayerPredicate * p6 ,
01045                        const PlayerPredicate * p7 ,
01046                        const PlayerPredicate * p8 )
01047         : M_predicates()
01048       {
01049           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p1 ) );
01050           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p2 ) );
01051           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p3 ) );
01052           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p4 ) );
01053           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p5 ) );
01054           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p6 ) );
01055           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p7 ) );
01056           M_predicates.push_back( boost::shared_ptr< const PlayerPredicate >( p8 ) );
01057       }
01058 
01064     bool operator()( const AbstractPlayerObject & p ) const
01065       {
01066           const std::vector< boost::shared_ptr< const PlayerPredicate > >::const_iterator
01067               p_end = M_predicates.end();
01068 
01069           for ( std::vector< boost::shared_ptr< const PlayerPredicate > >::const_iterator
01070                     it = M_predicates.begin();
01071                 it != p_end;
01072                 ++it )
01073           {
01074               if ( (**it)( p ) )
01075               {
01076                   return true;
01077               }
01078           }
01079 
01080           return false;
01081       }
01082 };
01083 
01088 class NotPlayerPredicate
01089     : public PlayerPredicate {
01090 private:
01092     boost::shared_ptr< const PlayerPredicate > M_predicate;
01093 
01094     // not used
01095     NotPlayerPredicate();
01096 public:
01097     // XXX: implicit_shared_ptr
01098 
01103     explicit
01104     NotPlayerPredicate( const PlayerPredicate * predicate )
01105         : M_predicate( predicate )
01106       {
01107       }
01108 
01114     bool operator()( const AbstractPlayerObject & p ) const
01115       {
01116           return ! (*M_predicate)( p );
01117       }
01118 };
01119 
01120 }
01121 
01122 #endif

librcscに対してThu May 1 15:41:21 2008に生成されました。  doxygen 1.5.0