The Battle for Wesnoth  1.19.7+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 &&)=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

struct std::hash< locator >
 

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 241 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 267 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 274 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 218 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 303 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 &&  )
default

◆ operator==()

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

Definition at line 289 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

◆ std::hash< locator >

friend struct std::hash< locator >
friend

Definition at line 102 of file picture.hpp.

Member Data Documentation

◆ center_x_

int image::locator::center_x_ = 0
private

◆ center_y_

int image::locator::center_y_ = 0
private

◆ filename_

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

◆ 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

◆ modifications_

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

◆ type_

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

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