The Battle for Wesnoth  1.19.12+dev
Public Types | Public Member Functions | Private Attributes | Friends | List of all members
image::locator Class Reference

Generic locator abstracting the location of an image. More...

#include <picture.hpp>

Public Types

enum  type { NONE , FILE , SUB_FILE }
 

Public Member Functions

 locator ()=default
 
 locator (locator &&) noexcept=default
 
 locator (const locator &)=default
 
 locator (const std::string &filename)
 
 locator (const std::string &filename, const std::string &modifications)
 
 locator (const std::string &filename, const map_location &loc, int center_x, int center_y, const std::string &modifications="")
 
locatoroperator= (const locator &a)=default
 
locatoroperator= (locator &&) noexcept=default
 
locator clone (const std::string &mods) const
 Returns a copy of this locator with the given IPF. More...
 
bool operator== (const locator &a) const
 
bool operator!= (const locator &a) const
 
bool operator< (const locator &a) const
 
const std::string & get_filename () const
 
bool is_data_uri () const
 
const map_locationget_loc () const
 
int get_center_x () const
 
int get_center_y () const
 
const std::string & get_modifications () const
 
type get_type () const
 
bool is_void () const
 Returns true if the locator does not correspond to an actual image. More...
 

Private Attributes

locator::type type_ = NONE
 
bool is_data_uri_ = false
 
std::string filename_ {}
 
std::string modifications_ {}
 
map_location loc_ {}
 
int center_x_ = 0
 
int center_y_ = 0
 

Friends

std::size_t hash_value (const locator &)
 Hash function overload for boost::hash. More...
 

Detailed Description

Generic locator abstracting the location of an image.

Constructing locators is somewhat slow, while accessing images through locators is fast. The general idea is that callers should store locators and not strings to construct new ones. (The latter will still work, of course, even if it is slower.)

Definition at line 58 of file picture.hpp.

Member Enumeration Documentation

◆ type

Enumerator
NONE 
FILE 
SUB_FILE 

Definition at line 61 of file picture.hpp.

Constructor & Destructor Documentation

◆ locator() [1/6]

image::locator::locator ( )
default

◆ locator() [2/6]

image::locator::locator ( locator &&  )
defaultnoexcept

◆ locator() [3/6]

image::locator::locator ( const locator )
default

◆ locator() [4/6]

image::locator::locator ( const std::string &  filename)

Definition at line 251 of file picture.cpp.

References ERR_IMG, FILE, filename_, is_data_uri_, modifications_, SUB_FILE, and type_.

◆ locator() [5/6]

image::locator::locator ( const std::string &  filename,
const std::string &  modifications 
)

Definition at line 277 of file picture.cpp.

◆ locator() [6/6]

image::locator::locator ( const std::string &  filename,
const map_location loc,
int  center_x,
int  center_y,
const std::string &  modifications = "" 
)

Definition at line 284 of file picture.cpp.

Member Function Documentation

◆ clone()

locator image::locator::clone ( const std::string &  mods) const

Returns a copy of this locator with the given IPF.

Definition at line 228 of file picture.cpp.

References modifications_, SUB_FILE, and type_.

Referenced by unit_frame::get_overlaped_hex(), and unit_frame::redraw().

◆ get_center_x()

int image::locator::get_center_x ( ) const
inline

Definition at line 85 of file picture.hpp.

References center_x_.

◆ get_center_y()

int image::locator::get_center_y ( ) const
inline

Definition at line 86 of file picture.hpp.

References center_y_.

◆ get_filename()

const std::string& image::locator::get_filename ( ) const
inline

◆ get_loc()

const map_location& image::locator::get_loc ( ) const
inline

Definition at line 84 of file picture.hpp.

References loc_.

Referenced by image::simplify_type().

◆ get_modifications()

const std::string& image::locator::get_modifications ( ) const
inline

Definition at line 87 of file picture.hpp.

References modifications_.

Referenced by unit_animation::add_anims(), image::get_texture(), and image::operator<<().

◆ get_type()

type image::locator::get_type ( ) const
inline

Definition at line 88 of file picture.hpp.

References type_.

◆ is_data_uri()

bool image::locator::is_data_uri ( ) const
inline

Definition at line 83 of file picture.hpp.

References is_data_uri_.

Referenced by image::exists().

◆ is_void()

bool image::locator::is_void ( ) const
inline

Returns true if the locator does not correspond to an actual image.

Definition at line 93 of file picture.hpp.

References NONE, and type_.

Referenced by image::exists(), image::get_lighted_image(), image::get_lighted_texture(), unit_frame::get_overlaped_hex(), image::get_surface(), image::get_texture(), unit_frame::merge_parameters(), and unit_frame::redraw().

◆ operator!=()

bool image::locator::operator!= ( const locator a) const
inline

Definition at line 78 of file picture.hpp.

References operator==().

◆ operator<()

bool image::locator::operator< ( const locator a) const

Definition at line 313 of file picture.cpp.

References center_x_, center_y_, FILE, filename_, loc_, modifications_, SUB_FILE, and type_.

◆ operator=() [1/2]

locator& image::locator::operator= ( const locator a)
default

◆ operator=() [2/2]

locator& image::locator::operator= ( locator &&  )
defaultnoexcept

◆ operator==()

bool image::locator::operator== ( const locator a) const

Definition at line 299 of file picture.cpp.

References center_x_, center_y_, FILE, filename_, loc_, modifications_, SUB_FILE, and type_.

Referenced by operator!=().

Friends And Related Function Documentation

◆ hash_value

std::size_t hash_value ( const locator val)
friend

Hash function overload for boost::hash.

Must be in the image namespace to satisfy ADL.

Definition at line 67 of file picture.cpp.

Member Data Documentation

◆ center_x_

int image::locator::center_x_ = 0
private

Definition at line 101 of file picture.hpp.

Referenced by get_center_x(), operator<(), and operator==().

◆ center_y_

int image::locator::center_y_ = 0
private

Definition at line 102 of file picture.hpp.

Referenced by get_center_y(), operator<(), and operator==().

◆ filename_

std::string image::locator::filename_ {}
private

Definition at line 98 of file picture.hpp.

Referenced by get_filename(), locator(), operator<(), and operator==().

◆ is_data_uri_

bool image::locator::is_data_uri_ = false
private

Definition at line 97 of file picture.hpp.

Referenced by is_data_uri(), and locator().

◆ loc_

map_location image::locator::loc_ {}
private

Definition at line 100 of file picture.hpp.

Referenced by get_loc(), operator<(), and operator==().

◆ modifications_

std::string image::locator::modifications_ {}
private

Definition at line 99 of file picture.hpp.

Referenced by clone(), get_modifications(), locator(), operator<(), and operator==().

◆ type_

locator::type image::locator::type_ = NONE
private

Definition at line 96 of file picture.hpp.

Referenced by clone(), get_type(), is_void(), locator(), operator<(), and operator==().


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