The Battle for Wesnoth 1.21.0-dev
 
Loading...
Searching...
No Matches
side_filter.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2010 - 2025
3 by Yurii Chernyi <terraninfo@terraninfo.net>
4 Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY.
12
13 See the COPYING file for more details.
14*/
15
16#pragma once
17
18#include "variable.hpp"
19
20#include <string>
21#include <vector>
22
23class config;
24class filter_context;
25class unit_filter;
26class team;
27
28//side_filter: a class that implements the Standard Side Filter
30public:
31
33
34 side_filter(const std::string &side_string, const filter_context * fc, bool flat_tod = false);
35 side_filter(const vconfig &cfg, const filter_context * fc, bool flat_tod = false);
36
37 //match: returns true if and only if the given team matches this filter
38 bool match(const team& t) const;
39 bool match(const int side) const;
40 std::vector<int> get_teams() const;
41 const config& get_config() const {return cfg_.get_config();}
42
43private:
44 side_filter(const side_filter &other);
46
47 bool match_internal(const team& t) const;
48
49 const vconfig cfg_; //config contains WML for a Standard Side Filter
50
51 bool flat_;
52 std::string side_string_;
53
54 /** The filter context for this filter. It should be a pointer because otherwise the default ctor doesn't work */
56
57 mutable std::unique_ptr<unit_filter> ufilter_;
58 mutable std::unique_ptr<side_filter> allied_filter_;
59 mutable std::unique_ptr<side_filter> enemy_filter_;
60 mutable std::unique_ptr<side_filter> has_ally_filter_;
61 mutable std::unique_ptr<side_filter> has_enemy_filter_;
62};
double t
A config object defines a single node in a WML file, with access to child nodes.
Definition config.hpp:157
std::unique_ptr< side_filter > has_ally_filter_
std::vector< int > get_teams() const
const filter_context * fc_
The filter context for this filter.
std::string side_string_
bool match(const team &t) const
const config & get_config() const
side_filter(const side_filter &other)
side_filter & operator=(const side_filter &other)
bool match_internal(const team &t) const
std::unique_ptr< side_filter > allied_filter_
std::unique_ptr< side_filter > has_enemy_filter_
const vconfig cfg_
std::unique_ptr< side_filter > enemy_filter_
std::unique_ptr< unit_filter > ufilter_
This class stores all the data for a single 'side' (in game nomenclature).
Definition team.hpp:74
A variable-expanding proxy for the config class.
Definition variable.hpp:45
const config & get_config() const
Definition variable.hpp:75
const config * cfg