This class encapsulates the recall list of a team. More...
#include <recall_list_manager.hpp>
Public Types | |
typedef std::vector< unit_ptr >::iterator | iterator |
typedef std::vector< unit_ptr >::const_iterator | const_iterator |
Public Member Functions | |
iterator | begin () |
begin iterator More... | |
iterator | end () |
end iterator More... | |
const_iterator | begin () const |
begin const iterator More... | |
const_iterator | end () const |
end const iterator More... | |
unit_ptr | operator[] (std::size_t index) |
vector style dereference More... | |
unit_const_ptr | operator[] (std::size_t index) const |
vector style dereference More... | |
unit_ptr | find_if_matches_id (const std::string &unit_id) |
Find a unit by id. More... | |
unit_ptr | extract_if_matches_id (const std::string &unit_id, int *pos=nullptr) |
Find a unit by id, and extract from this object if found. More... | |
unit_const_ptr | find_if_matches_id (const std::string &unit_id) const |
Const find by id. More... | |
void | erase_if_matches_id (const std::string &unit_id) |
Erase any unit with this id. More... | |
unit_ptr | find_if_matches_underlying_id (std::size_t uid) |
Find a unit by underlying id. More... | |
unit_ptr | extract_if_matches_underlying_id (std::size_t uid) |
Find a unit by underlying id, and extract if found. More... | |
unit_const_ptr | find_if_matches_underlying_id (std::size_t uid) const |
Const find by underlying id. More... | |
void | erase_by_underlying_id (std::size_t uid) |
Erase any unit with this underlying id. More... | |
iterator | erase_index (std::size_t index) |
Erase by index. More... | |
iterator | erase (iterator it) |
Erase an iterator to this object. More... | |
std::size_t | find_index (const std::string &unit_id) const |
Find the index of a unit by its id. More... | |
std::size_t | size () const |
Get the number of units on the list. More... | |
bool | empty () const |
Is it empty? More... | |
void | add (const unit_ptr &ptr, int pos=-1) |
Add a unit to the list. More... | |
Private Attributes | |
std::vector< unit_ptr > | recall_list_ |
The underlying data struture. More... | |
This class encapsulates the recall list of a team.
Definition at line 24 of file recall_list_manager.hpp.
typedef std::vector<unit_ptr >::const_iterator recall_list_manager::const_iterator |
Definition at line 27 of file recall_list_manager.hpp.
typedef std::vector<unit_ptr >::iterator recall_list_manager::iterator |
Definition at line 26 of file recall_list_manager.hpp.
void recall_list_manager::add | ( | const unit_ptr & | ptr, |
int | pos = -1 |
||
) |
Add a unit to the list.
pos the location where to insert the unit, -1 for 'at end'
Definition at line 64 of file recall_list_manager.cpp.
References recall_list_.
Referenced by unit_creator::add_unit(), BOOST_AUTO_TEST_CASE(), team_builder::handle_unit(), game_board::try_add_unit_to_recall_list(), actions::undo::dismiss_action::undo(), and actions::undo::recall_action::undo().
|
inline |
begin iterator
Definition at line 30 of file recall_list_manager.hpp.
References recall_list_.
Referenced by BOOST_AUTO_TEST_CASE(), gui2::dialogs::team_mode_controller::show_recall_unit(), and game_events::WML_HANDLER_FUNCTION().
|
inline |
begin const iterator
Definition at line 35 of file recall_list_manager.hpp.
References recall_list_.
|
inline |
Is it empty?
Definition at line 75 of file recall_list_manager.hpp.
References recall_list_.
Referenced by events::menu_handler::recall().
|
inline |
end iterator
Definition at line 32 of file recall_list_manager.hpp.
References recall_list_.
Referenced by BOOST_AUTO_TEST_CASE(), and game_events::WML_HANDLER_FUNCTION().
|
inline |
Erase an iterator to this object.
Definition at line 143 of file recall_list_manager.cpp.
References recall_list_.
Referenced by game_events::WML_HANDLER_FUNCTION().
void recall_list_manager::erase_by_underlying_id | ( | std::size_t | uid | ) |
Erase any unit with this underlying id.
Definition at line 120 of file recall_list_manager.cpp.
References utils::erase_if(), and recall_list_.
void recall_list_manager::erase_if_matches_id | ( | const std::string & | unit_id | ) |
Erase any unit with this id.
Used to erase units from vectors by their ID.
Definition at line 57 of file recall_list_manager.cpp.
References utils::erase_if(), and recall_list_.
Referenced by unit_creator::add_unit(), BOOST_AUTO_TEST_CASE(), and SYNCED_COMMAND_HANDLER_FUNCTION().
unit_ptr recall_list_manager::extract_if_matches_id | ( | const std::string & | unit_id, |
int * | pos = nullptr |
||
) |
Find a unit by id, and extract from this object if found.
Null if not found. pos an output paramter, to know in which position the unit was.
Definition at line 82 of file recall_list_manager.cpp.
References recall_list_.
Referenced by actions::recall_unit(), and ai::simulated_recall().
unit_ptr recall_list_manager::extract_if_matches_underlying_id | ( | std::size_t | uid | ) |
Find a unit by underlying id, and extract if found.
Null if not found.
Definition at line 125 of file recall_list_manager.cpp.
References recall_list_.
Referenced by lua_unit::put_map().
unit_ptr recall_list_manager::find_if_matches_id | ( | const std::string & | unit_id | ) |
Find a unit by id.
Used to find units in vectors by their ID.
Null pointer if not found.
Definition at line 29 of file recall_list_manager.cpp.
References recall_list_.
Referenced by unit_creator::add_unit(), BOOST_AUTO_TEST_CASE(), gui2::dialogs::unit_recall::dismiss_unit(), ai::recall_result::get_recall_unit(), and SYNCED_COMMAND_HANDLER_FUNCTION().
unit_const_ptr recall_list_manager::find_if_matches_id | ( | const std::string & | unit_id | ) | const |
Const find by id.
Used to find units in vectors by their ID.
Definition at line 43 of file recall_list_manager.cpp.
References recall_list_.
unit_ptr recall_list_manager::find_if_matches_underlying_id | ( | std::size_t | uid | ) |
Find a unit by underlying id.
Null pointer if not found.
Definition at line 98 of file recall_list_manager.cpp.
References recall_list_.
Referenced by lua_unit::get(), and lua_unit::get_shared().
unit_const_ptr recall_list_manager::find_if_matches_underlying_id | ( | std::size_t | uid | ) | const |
Const find by underlying id.
Definition at line 109 of file recall_list_manager.cpp.
References recall_list_.
std::size_t recall_list_manager::find_index | ( | const std::string & | unit_id | ) | const |
Find the index of a unit by its id.
Definition at line 74 of file recall_list_manager.cpp.
References recall_list_.
|
inline |
vector style dereference
Definition at line 40 of file recall_list_manager.hpp.
References utf8::index(), and recall_list_.
|
inline |
vector style dereference
Definition at line 42 of file recall_list_manager.hpp.
References utf8::index(), and recall_list_.
|
inline |
Get the number of units on the list.
Definition at line 73 of file recall_list_manager.hpp.
References recall_list_.
Referenced by BOOST_AUTO_TEST_CASE(), and SYNCED_COMMAND_HANDLER_FUNCTION().
|
private |
The underlying data struture.
TODO: Should this be a map based on underlying id instead?
Definition at line 88 of file recall_list_manager.hpp.
Referenced by add(), begin(), empty(), end(), erase(), erase_by_underlying_id(), erase_if_matches_id(), erase_index(), extract_if_matches_id(), extract_if_matches_underlying_id(), find_if_matches_id(), find_if_matches_underlying_id(), find_index(), operator[](), and size().