Generic locator abstracting the location of an image. More...
#include <picture.hpp>
Classes | |
struct | value |
Public Types | |
enum | type { NONE , FILE , SUB_FILE } |
Public Member Functions | |
locator ()=default | |
locator (locator &&) noexcept=default | |
locator (const locator &)=default | |
template<typename... Args> | |
locator (Args &&... args) | |
locator & | operator= (const locator &a)=default |
locator & | operator= (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 |
const std::string & | get_filename () const |
bool | is_data_uri () const |
const map_location & | get_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... | |
bool | file_exists () const |
Tests whether the file the locator points at exists. More... | |
template<typename T > | |
bool | in_cache (cache_type< T > &cache) const |
template<typename T > | |
T & | access_in_cache (cache_type< T > &cache) const |
template<typename T > | |
const T & | locate_in_cache (cache_type< T > &cache) const |
template<typename T > | |
std::optional< T > | copy_from_cache (cache_type< T > &cache) const |
template<typename T > | |
void | add_to_cache (cache_type< T > &cache, T data) const |
std::size_t | hash () const |
Private Attributes | |
value | val_ |
Friends | |
struct | std::hash< value > |
template<typename T > | |
class | cache_type |
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 62 of file picture.hpp.
enum image::locator::type |
Enumerator | |
---|---|
NONE | |
FILE | |
SUB_FILE |
Definition at line 65 of file picture.hpp.
|
default |
|
defaultnoexcept |
|
default |
|
inline |
Definition at line 72 of file picture.hpp.
T & image::locator::access_in_cache | ( | cache_type< T > & | cache | ) | const |
Definition at line 128 of file picture.cpp.
References image::cache_type< T >::get_element(), image::cache_type< T >::cache_item::item, and val_.
Referenced by image::get_lighted_image(), and image::get_lighted_texture().
void image::locator::add_to_cache | ( | cache_type< T > & | cache, |
T | data | ||
) | const |
Definition at line 141 of file picture.cpp.
References data, image::cache_type< T >::get_element(), image::cache_type< T >::cache_item::populate(), and val_.
Referenced by image::get_hexed(), image::get_lighted_image(), image::get_lighted_texture(), image::get_surface(), image::get_texture(), image::is_empty_hex(), image::is_in_hex(), and image::load_image_sub_file().
locator image::locator::clone | ( | const std::string & | mods | ) | const |
Returns a copy of this locator with the given IPF.
Definition at line 234 of file picture.cpp.
References image::locator::value::modifications, SUB_FILE, image::locator::value::type, and val_.
Referenced by unit_frame::get_overlaped_hex(), and unit_frame::redraw().
std::optional< T > image::locator::copy_from_cache | ( | cache_type< T > & | cache | ) | const |
Definition at line 134 of file picture.cpp.
References image::cache_type< T >::get_element(), image::cache_type< T >::cache_item::loaded, and val_.
Referenced by image::get_surface(), image::get_texture(), and image::is_in_hex().
bool image::locator::file_exists | ( | ) | const |
Tests whether the file the locator points at exists.
is_void does not work before the image is loaded, and also a placeholder is returned instead in debug mode. Thus it's not possible to test for the existence of an actual file without this function.
Definition at line 564 of file picture.cpp.
References image::locator::value::filename, filesystem::get_binary_file_location(), image::locator::value::is_data_uri, and val_.
Referenced by attack_info(), intf_get_image_size(), and gui2::unit_preview_pane::print_attack_details().
|
inline |
Definition at line 88 of file picture.hpp.
References image::locator::value::center_x, and val_.
Referenced by image::load_image_sub_file(), and gui2::dialogs::terrain_layers::pre_show().
|
inline |
Definition at line 89 of file picture.hpp.
References image::locator::value::center_y, and val_.
Referenced by image::load_image_sub_file(), and gui2::dialogs::terrain_layers::pre_show().
|
inline |
Definition at line 85 of file picture.hpp.
References image::locator::value::filename, and val_.
Referenced by unit_animation::add_anims(), image::exists(), image::get_hexed(), unit_frame::get_overlaped_hex(), image::load_image_data_uri(), image::load_image_file(), image::load_image_sub_file(), unit_frame::merge_parameters(), image::operator<<(), gui2::dialogs::terrain_layers::pre_show(), and unit_frame::redraw().
|
inline |
Definition at line 87 of file picture.hpp.
References image::locator::value::loc, and val_.
Referenced by image::load_image_sub_file(), gui2::dialogs::terrain_layers::pre_show(), and image::simplify_type().
|
inline |
Definition at line 90 of file picture.hpp.
References image::locator::value::modifications, and val_.
Referenced by unit_animation::add_anims(), image::get_texture(), image::load_image_sub_file(), and image::operator<<().
|
inline |
Definition at line 91 of file picture.hpp.
References image::locator::value::type, and val_.
Referenced by image::exists(), and image::load_from_disk().
std::size_t image::locator::hash | ( | ) | const |
Definition at line 110 of file picture.cpp.
References val_.
bool image::locator::in_cache | ( | cache_type< T > & | cache | ) | const |
Definition at line 116 of file picture.cpp.
References image::cache_type< T >::get_element(), image::cache_type< T >::cache_item::loaded, and val_.
Referenced by image::get_lighted_image(), image::get_lighted_texture(), image::get_surface(), and image::is_empty_hex().
|
inline |
Definition at line 86 of file picture.hpp.
References image::locator::value::is_data_uri, and val_.
Referenced by image::exists(), and image::load_from_disk().
|
inline |
Returns true if the locator does not correspond to an actual image.
Definition at line 96 of file picture.hpp.
References NONE, image::locator::value::type, and val_.
Referenced by 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().
const T & image::locator::locate_in_cache | ( | cache_type< T > & | cache | ) | const |
Definition at line 122 of file picture.cpp.
References image::cache_type< T >::get_element(), image::cache_type< T >::cache_item::item, and val_.
Referenced by image::get_lighted_image(), image::get_lighted_texture(), image::get_surface(), and image::is_empty_hex().
|
inline |
Definition at line 83 of file picture.hpp.
References a, and operator==().
|
inline |
|
friend |
Definition at line 153 of file picture.hpp.
|
friend |
Definition at line 147 of file picture.hpp.
|
private |
Definition at line 147 of file picture.hpp.
Referenced by access_in_cache(), add_to_cache(), clone(), copy_from_cache(), file_exists(), get_center_x(), get_center_y(), get_filename(), get_loc(), get_modifications(), get_type(), hash(), in_cache(), is_data_uri(), is_void(), locate_in_cache(), and operator==().