The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
side_filter.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 - 2016 by Yurii Chernyi <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #ifndef SIDE_FILTER_H_INCLUDED
16 #define SIDE_FILTER_H_INCLUDED
17 
18 #include "variable.hpp"
19 
20 #include <boost/scoped_ptr.hpp>
21 #include <set>
22 #include <string>
23 #include <vector>
24 
25 class config;
26 class filter_context;
27 class unit;
28 class unit_filter;
29 class unit_map;
30 class team;
31 
32 //side_filter: a class that implements the Standard Side Filter
33 class side_filter {
34 public:
35 
36 #ifdef _MSC_VER
37  // This constructor is required for MSVC 9 SP1 due to a bug there
38  // see http://social.msdn.microsoft.com/forums/en-US/vcgeneral/thread/34473b8c-0184-4750-a290-08558e4eda4e
39  // other compilers don't need it.
40  side_filter();
41 #endif
42  ~side_filter();
43 
44  side_filter(const std::string &side_string, const filter_context * fc, bool flat_tod = false);
45  side_filter(const vconfig &cfg, const filter_context * fc, bool flat_tod = false);
46 
47  //match: returns true if and only if the given team matches this filter
48  bool match(const team& t) const;
49  bool match(const int side) const;
50  std::vector<int> get_teams() const;
51 
52 private:
53  side_filter(const side_filter &other);
54  side_filter& operator=(const side_filter &other);
55 
56  bool match_internal(const team& t) const;
57 
58  const vconfig cfg_; //config contains WML for a Standard Side Filter
59 
60  bool flat_;
62 
63  const filter_context * fc_; //!< The filter context for this filter. It should be a pointer because otherwise the default ctor doesn't work
64 
65  mutable boost::scoped_ptr<unit_filter> ufilter_;
66  mutable boost::scoped_ptr<side_filter> allied_filter_;
67  mutable boost::scoped_ptr<side_filter> enemy_filter_;
68  mutable boost::scoped_ptr<side_filter> has_ally_filter_;
69  mutable boost::scoped_ptr<side_filter> has_enemy_filter_;
70 };
71 
72 #endif
73 
std::vector< int > get_teams() const
Definition: side_filter.cpp:72
Definition: unit.hpp:95
boost::scoped_ptr< side_filter > enemy_filter_
Definition: side_filter.hpp:67
const filter_context * fc_
The filter context for this filter. It should be a pointer because otherwise the default ctor doesn't...
Definition: side_filter.hpp:63
bool match(const team &t) const
GLdouble GLdouble t
Definition: glew.h:1366
This class stores all the data for a single 'side' (in game nomenclature).
Definition: team.hpp:50
std::string side_string_
Definition: side_filter.hpp:61
boost::scoped_ptr< side_filter > allied_filter_
Definition: side_filter.hpp:66
boost::scoped_ptr< unit_filter > ufilter_
Definition: side_filter.hpp:65
bool match_internal(const team &t) const
Definition: side_filter.cpp:99
const vconfig cfg_
Definition: side_filter.hpp:58
boost::scoped_ptr< side_filter > has_ally_filter_
Definition: side_filter.hpp:68
side_filter & operator=(const side_filter &other)
boost::scoped_ptr< side_filter > has_enemy_filter_
Definition: side_filter.hpp:69
A variable-expanding proxy for the config class.
Definition: variable.hpp:36
Container associating units to locations.
Definition: map.hpp:90
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
GLsizei const GLcharARB ** string
Definition: glew.h:4503
side_filter(const std::string &side_string, const filter_context *fc, bool flat_tod=false)
Definition: side_filter.cpp:67