Generic locator abstracting the location of an image. More...
#include <picture.hpp>
Classes | |
struct | value |
Public Types | |
enum | type { NONE, FILE, SUB_FILE } |
typedef std::unordered_map< value, int > | locator_finder_t |
Public Member Functions | |
locator () | |
locator (const locator &a, const std::string &mods="") | |
locator (const char *filename) | |
locator (const std::string &filename) | |
locator (const char *filename, const char *modifications) | |
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="") | |
locator & | operator= (const locator &a) |
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_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 > | |
void | add_to_cache (cache_type< T > &cache, const T &data) const |
Private Member Functions | |
void | init_index () |
void | parse_arguments () |
Private Attributes | |
int | index_ |
value | val_ |
Friends | |
struct | std::hash< value > |
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.
typedef std::unordered_map<value, int> image::locator::locator_finder_t |
Definition at line 148 of file picture.hpp.
enum image::locator::type |
Enumerator | |
---|---|
NONE | |
FILE | |
SUB_FILE |
Definition at line 65 of file picture.hpp.
image::locator::locator | ( | ) |
Definition at line 299 of file picture.cpp.
image::locator::locator | ( | const locator & | a, |
const std::string & | mods = "" |
||
) |
Definition at line 305 of file picture.cpp.
References index_, init_index(), image::locator::value::modifications_, SUB_FILE, image::locator::value::type_, and val_.
image::locator::locator | ( | const char * | filename | ) |
Definition at line 318 of file picture.cpp.
References init_index(), and parse_arguments().
image::locator::locator | ( | const std::string & | filename | ) |
Definition at line 326 of file picture.cpp.
References init_index(), and parse_arguments().
image::locator::locator | ( | const char * | filename, |
const char * | modifications | ||
) |
Definition at line 341 of file picture.cpp.
References init_index().
image::locator::locator | ( | const std::string & | filename, |
const std::string & | modifications | ||
) |
Definition at line 334 of file picture.cpp.
References init_index().
image::locator::locator | ( | const std::string & | filename, |
const map_location & | loc, | ||
int | center_x, | ||
int | center_y, | ||
const std::string & | modifications = "" |
||
) |
Definition at line 348 of file picture.cpp.
References init_index().
T & image::locator::access_in_cache | ( | cache_type< T > & | cache | ) | const |
Definition at line 142 of file picture.cpp.
References image::cache_type< T >::get_element().
Referenced by is_void().
void image::locator::add_to_cache | ( | cache_type< T > & | cache, |
const T & | data | ||
) | const |
Definition at line 149 of file picture.cpp.
References data, and image::cache_type< T >::get_element().
Referenced by image::get_hexed(), image::get_lighted_image(), image::get_lighted_texture(), image::is_empty_hex(), image::is_in_hex(), is_void(), and image::load_image_sub_file().
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 715 of file picture.cpp.
References image::locator::value::filename_, filesystem::get_binary_file_location(), image::locator::value::is_data_uri_, and val_.
Referenced by adjust_profile(), attack_info(), intf_get_image_size(), is_void(), and gui2::unit_preview_pane::print_attack_details().
|
inline |
Definition at line 84 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 85 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 81 of file picture.hpp.
References image::locator::value::filename_, and val_.
Referenced by unit_animation::add_anims(), frame_parsed_parameters::debug_strings(), image::exists(), image::get_hexed(), unit_frame::get_overlaped_hex(), display::get_terrain_images(), 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 83 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 86 of file picture.hpp.
References image::locator::value::modifications_, and val_.
Referenced by unit_animation::add_anims(), frame_parsed_parameters::debug_strings(), display::get_terrain_images(), image::load_image_sub_file(), and image::operator<<().
|
inline |
Definition at line 87 of file picture.hpp.
References image::locator::value::type_, and val_.
Referenced by image::exists(), and image::load_from_disk().
bool image::locator::in_cache | ( | cache_type< T > & | cache | ) | const |
Definition at line 129 of file picture.cpp.
References image::cache_type< T >::get_element().
Referenced by image::get_lighted_image(), image::get_lighted_texture(), image::get_surface(), image::get_texture(), image::is_empty_hex(), image::is_in_hex(), and is_void().
|
private |
|
inline |
Definition at line 82 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 93 of file picture.hpp.
References access_in_cache(), add_to_cache(), data, file_exists(), in_cache(), init_index(), locate_in_cache(), NONE, parse_arguments(), 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 135 of file picture.cpp.
References image::cache_type< T >::get_element().
Referenced by image::get_lighted_image(), image::get_lighted_texture(), image::get_surface(), image::get_texture(), image::is_empty_hex(), image::is_in_hex(), and is_void().
|
inline |
Definition at line 78 of file picture.hpp.
References index_.
|
inline |
Definition at line 79 of file picture.hpp.
References index_.
Definition at line 359 of file picture.cpp.
|
inline |
Definition at line 77 of file picture.hpp.
References index_.
|
private |
Definition at line 271 of file picture.cpp.
References ERR_IMG.
|
friend |
Definition at line 151 of file picture.hpp.
|
private |
Definition at line 153 of file picture.hpp.
Referenced by locator(), operator!=(), operator<(), operator=(), and operator==().
|
private |
Definition at line 154 of file picture.hpp.
Referenced by file_exists(), get_center_x(), get_center_y(), get_filename(), get_loc(), get_modifications(), get_type(), is_data_uri(), is_void(), locator(), and operator=().