The Battle for Wesnoth  1.15.0-dev
Classes | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
terrain_filter Class Reference

#include <filter.hpp>

Inheritance diagram for terrain_filter:
Inheritance graph

Classes

struct  terrain_filter_cache
 

Public Member Functions

 terrain_filter (const vconfig &cfg, const filter_context *fc, const bool flat_tod=false)
 
 terrain_filter (const vconfig &cfg, const terrain_filter &original)
 
 ~terrain_filter ()
 Default implementation, but defined out-of-line for efficiency reasons. More...
 
 terrain_filter (const terrain_filter &other)
 
terrain_filteroperator= (const terrain_filter &other)
 
bool match (const map_location &loc) const
 
bool match (const map_location &loc, const unit &ref_unit) const
 
virtual bool operator() (const map_location &loc) const
 
void get_locations (std::set< map_location > &locs, bool with_border=false) const
 gets all locations on the map that match this filter More...
 
void get_locations (std::set< map_location > &locs, const unit &ref_unit, bool with_border=false) const
 gets all locations on the map that match this filter More...
 
void flatten (const bool flat_tod=true)
 
config to_config () const
 
- Public Member Functions inherited from filter_impl
 filter_impl ()
 
virtual bool matches (const mapgen_gamemap &m, map_location l)=0
 
virtual ~filter_impl ()
 

Private Member Functions

bool match_impl (const map_location &loc, const unit *ref_unit) const
 
void get_locs_impl (std::set< map_location > &locs, const unit *ref_unit, bool with_border) const
 
bool match_internal (const map_location &loc, const unit *ref_unit, const bool ignore_xy) const
 

Private Attributes

const vconfig cfg_
 
const filter_contextfc_
 
terrain_filter_cache cache_
 
const std::size_t max_loop_
 
bool flat_
 

Friends

class terrain_filterimpl
 

Additional Inherited Members

- Protected Member Functions inherited from xy_pred
virtual ~xy_pred ()
 

Detailed Description

Definition at line 27 of file filter.hpp.

Constructor & Destructor Documentation

◆ terrain_filter() [1/3]

terrain_filter::terrain_filter ( const vconfig cfg,
const filter_context fc,
const bool  flat_tod = false 
)

◆ terrain_filter() [2/3]

terrain_filter::terrain_filter ( const vconfig cfg,
const terrain_filter original 
)

Definition at line 55 of file filter.cpp.

References terrain_filter().

◆ ~terrain_filter()

terrain_filter::~terrain_filter ( )

Default implementation, but defined out-of-line for efficiency reasons.

Definition at line 42 of file filter.cpp.

References game_config::max_loop, terrain_filter(), and ~terrain_filter().

Referenced by ~terrain_filter().

◆ terrain_filter() [3/3]

terrain_filter::terrain_filter ( const terrain_filter other)

Definition at line 64 of file filter.cpp.

References cache_, cfg_, fc_, flat_, max_loop_, and terrain_filter().

Member Function Documentation

◆ flatten()

void terrain_filter::flatten ( const bool  flat_tod = true)
inline

Definition at line 69 of file filter.hpp.

References flat_, and to_config().

◆ get_locations() [1/2]

void terrain_filter::get_locations ( std::set< map_location > &  locs,
bool  with_border = false 
) const
inline

gets all locations on the map that match this filter

Parameters
[out]locsset to store the results in
[in]with_borderwhether to include the borders

Definition at line 56 of file filter.hpp.

References get_locs_impl().

Referenced by ai::formula_ai::get_value().

◆ get_locations() [2/2]

void terrain_filter::get_locations ( std::set< map_location > &  locs,
const unit ref_unit,
bool  with_border = false 
) const
inline

gets all locations on the map that match this filter

Parameters
[out]locsset to store the results in
[in]with_borderwhether to include the borders
[in]ref_unitA reference unit for the $teleport_unit auto-stored variable

Definition at line 64 of file filter.hpp.

References get_locs_impl().

◆ get_locs_impl()

void terrain_filter::get_locs_impl ( std::set< map_location > &  locs,
const unit ref_unit,
bool  with_border 
) const
private

◆ match() [1/2]

bool terrain_filter::match ( const map_location loc) const
inline
Parameters
locThe location to test
Returns
true if and only if the given location matches this filter

Definition at line 40 of file filter.hpp.

References match_impl().

◆ match() [2/2]

bool terrain_filter::match ( const map_location loc,
const unit ref_unit 
) const
inline
Parameters
locThe location to test
ref_unitA reference unit for the $teleport_unit auto-stored variable
Returns
true if and only if the given location matches this filter

Definition at line 47 of file filter.hpp.

References match_impl().

◆ match_impl()

bool terrain_filter::match_impl ( const map_location loc,
const unit ref_unit 
) const
private

◆ match_internal()

bool terrain_filter::match_internal ( const map_location loc,
const unit ref_unit,
const bool  ignore_xy 
) const
private

◆ operator()()

virtual bool terrain_filter::operator() ( const map_location loc) const
inlinevirtual

Implements xy_pred.

Definition at line 51 of file filter.hpp.

References match().

◆ operator=()

terrain_filter & terrain_filter::operator= ( const terrain_filter other)

Definition at line 75 of file filter.cpp.

References operator=(), and terrain_filter().

Referenced by operator=().

◆ to_config()

config terrain_filter::to_config ( ) const

Definition at line 680 of file filter.cpp.

References to_config().

Referenced by flatten(), and to_config().

Friends And Related Function Documentation

◆ terrain_filterimpl

friend class terrain_filterimpl
friend

Definition at line 72 of file filter.hpp.

Member Data Documentation

◆ cache_

terrain_filter_cache terrain_filter::cache_
mutableprivate

Definition at line 96 of file filter.hpp.

Referenced by terrain_filter().

◆ cfg_

const vconfig terrain_filter::cfg_
private

Definition at line 78 of file filter.hpp.

Referenced by terrain_filter().

◆ fc_

const filter_context* terrain_filter::fc_
private

Definition at line 79 of file filter.hpp.

Referenced by terrain_filter().

◆ flat_

bool terrain_filter::flat_
private

Definition at line 98 of file filter.hpp.

Referenced by flatten(), and terrain_filter().

◆ max_loop_

const std::size_t terrain_filter::max_loop_
private

Definition at line 97 of file filter.hpp.

Referenced by terrain_filter().


The documentation for this class was generated from the following files: