The Battle for Wesnoth  1.19.0-dev
Public Member Functions | Private Attributes | List of all members
unit_filter Class Reference

#include <filter.hpp>

Public Member Functions

 unit_filter (vconfig cfg)
 
 unit_filter (const unit_filter &)=default
 
unit_filteroperator= (const unit_filter &)=default
 
 unit_filter (unit_filter &&)=default
 
unit_filteroperator= (unit_filter &&)=default
 
unit_filterset_use_flat_tod (bool value)
 
bool matches (const unit &u, const map_location &loc) const
 Determine if *this matches filter at a specified location. More...
 
bool matches (const unit &u) const
 Determine if *this matches filter at its current location. More...
 
bool matches (const unit &u, const map_location &loc, const unit &u2) const
 
bool matches (const unit &u, const unit &u2) const
 
bool operator() (const unit &u, const map_location &loc) const
 
bool operator() (const unit &u) const
 
bool operator() (const unit &u, const map_location &loc, const unit &u2) const
 
bool operator() (const unit &u, const unit &u2) const
 
std::vector< const unit * > all_matches_on_map (const map_location *loc=nullptr, const unit *other_unit=nullptr) const
 
std::vector< const unit * > all_matches_at (const map_location &loc) const
 
std::vector< const unit * > all_matches_with_unit (const unit &u) const
 
std::vector< const unit * > all_matches_with_unit_at (const unit &u, const map_location &loc) const
 
unit_const_ptr first_match_on_map () const
 
config to_config () const
 
bool empty () const
 

Private Attributes

vconfig cfg_
 
const filter_contextfc_
 
bool use_flat_tod_
 
unit_filter_impl::unit_filter_compound impl_
 
int max_matches_
 

Detailed Description

Definition at line 102 of file filter.hpp.

Constructor & Destructor Documentation

◆ unit_filter() [1/3]

unit_filter::unit_filter ( vconfig  cfg)
explicit

Definition at line 49 of file filter.cpp.

◆ unit_filter() [2/3]

unit_filter::unit_filter ( const unit_filter )
default

◆ unit_filter() [3/3]

unit_filter::unit_filter ( unit_filter &&  )
default

Member Function Documentation

◆ all_matches_at()

std::vector<const unit*> unit_filter::all_matches_at ( const map_location loc) const
inline

Definition at line 158 of file filter.hpp.

References all_matches_on_map().

Referenced by game_lua_kernel::intf_get_units().

◆ all_matches_on_map()

std::vector< const unit * > unit_filter::all_matches_on_map ( const map_location loc = nullptr,
const unit other_unit = nullptr 
) const

◆ all_matches_with_unit()

std::vector<const unit*> unit_filter::all_matches_with_unit ( const unit u) const
inline

Definition at line 162 of file filter.hpp.

References all_matches_on_map().

Referenced by game_lua_kernel::intf_get_units().

◆ all_matches_with_unit_at()

std::vector<const unit*> unit_filter::all_matches_with_unit_at ( const unit u,
const map_location loc 
) const
inline

Definition at line 166 of file filter.hpp.

References all_matches_on_map().

◆ empty()

bool unit_filter::empty ( ) const
inline

◆ first_match_on_map()

unit_const_ptr unit_filter::first_match_on_map ( ) const

◆ matches() [1/4]

bool unit_filter::matches ( const unit u) const

Determine if *this matches filter at its current location.

(Only use for units currently on the map; otherwise use the overload that takes a location, possibly with a null location.)

Definition at line 58 of file filter.cpp.

References fc_, unit::get_location(), impl_, unit_filter_impl::unit_filter_compound::matches(), and use_flat_tod_.

◆ matches() [2/4]

bool unit_filter::matches ( const unit u,
const map_location loc 
) const
inline

Determine if *this matches filter at a specified location.

Use this for units on a recall list, or to test for a match if a unit is hypothetically moved.

Definition at line 123 of file filter.hpp.

References fc_, impl_, unit_filter_impl::unit_filter_compound::matches(), and use_flat_tod_.

Referenced by unit::ability_affects_self(), first_match_on_map(), pathfind::teleport_group::get_teleport_pair(), game_events::entity_location::matches_unit_filter(), operator()(), and game_events::WML_HANDLER_FUNCTION().

◆ matches() [3/4]

bool unit_filter::matches ( const unit u,
const map_location loc,
const unit u2 
) const
inline

◆ matches() [4/4]

bool unit_filter::matches ( const unit u,
const unit u2 
) const

◆ operator()() [1/4]

bool unit_filter::operator() ( const unit u) const
inline

Definition at line 144 of file filter.hpp.

References matches().

◆ operator()() [2/4]

bool unit_filter::operator() ( const unit u,
const map_location loc 
) const
inline

Definition at line 140 of file filter.hpp.

References matches().

◆ operator()() [3/4]

bool unit_filter::operator() ( const unit u,
const map_location loc,
const unit u2 
) const
inline

Definition at line 148 of file filter.hpp.

References matches().

◆ operator()() [4/4]

bool unit_filter::operator() ( const unit u,
const unit u2 
) const
inline

Definition at line 152 of file filter.hpp.

References matches().

◆ operator=() [1/2]

unit_filter& unit_filter::operator= ( const unit_filter )
default

◆ operator=() [2/2]

unit_filter& unit_filter::operator= ( unit_filter &&  )
default

◆ set_use_flat_tod()

unit_filter& unit_filter::set_use_flat_tod ( bool  value)
inline

Definition at line 113 of file filter.hpp.

References use_flat_tod_.

Referenced by unit::ability_affects_self().

◆ to_config()

config unit_filter::to_config ( ) const
inline

Definition at line 172 of file filter.hpp.

References cfg_, and vconfig::get_config().

Referenced by game_events::filter_unit::serialize().

Member Data Documentation

◆ cfg_

vconfig unit_filter::cfg_
private

Definition at line 182 of file filter.hpp.

Referenced by empty(), and to_config().

◆ fc_

const filter_context* unit_filter::fc_
private

Definition at line 183 of file filter.hpp.

Referenced by all_matches_on_map(), first_match_on_map(), and matches().

◆ impl_

unit_filter_impl::unit_filter_compound unit_filter::impl_
private

Definition at line 185 of file filter.hpp.

Referenced by all_matches_on_map(), and matches().

◆ max_matches_

int unit_filter::max_matches_
private

Definition at line 186 of file filter.hpp.

Referenced by all_matches_on_map().

◆ use_flat_tod_

bool unit_filter::use_flat_tod_
private

Definition at line 184 of file filter.hpp.

Referenced by matches(), and set_use_flat_tod().


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