Datastructure holding the actions of a side on multiple turns. More...
#include <side_actions.hpp>
Classes | |
struct | by_hex |
Tag for action_set's hashed_non_unique index. More... | |
struct | by_unit |
Tag for action_set's hashed_non_unique index. More... | |
struct | chronological |
Tag for action_set's random_access index. More... | |
Public Types | |
typedef boost::multi_index::multi_index_container < action_ptr, boost::multi_index::indexed_by < boost::multi_index::random_access < boost::multi_index::tag < chronological > >, boost::multi_index::hashed_non_unique < boost::multi_index::tag < by_unit > , boost::multi_index::const_mem_fun < action, size_t,&action::get_unit_id > >, boost::multi_index::hashed_non_unique < boost::multi_index::tag < by_hex > , boost::multi_index::const_mem_fun < action, map_location,&action::get_numbering_hex > > > > | action_set |
Underlying container. More... | |
typedef action_set::index < chronological > ::type::iterator | iterator |
typedef action_set::index < chronological > ::type::const_iterator | const_iterator |
typedef action_set::index < chronological > ::type::reverse_iterator | reverse_iterator |
typedef action_set::index < chronological > ::type::const_reverse_iterator | const_reverse_iterator |
typedef std::pair< iterator, iterator > | range_t |
typedef std::pair < reverse_iterator, reverse_iterator > | rrange_t |
typedef std::pair < const_iterator, const_iterator > | crange_t |
typedef std::pair < const_reverse_iterator, const_reverse_iterator > | crrange_t |
typedef std::deque< iterator > | action_limits |
Public Member Functions | |
side_actions_container () | |
iterator | insert (iterator position, action_ptr action) |
Inserts an action at the specified position. More... | |
iterator | queue (size_t turn_num, action_ptr action) |
Queues an action to be executed last. More... | |
iterator | push_front (size_t turn, action_ptr action) |
Pushes an action in front of a given turn. More... | |
iterator | bump_earlier (iterator position) |
Moves an action earlier in the execution order. More... | |
iterator | bump_later (iterator position) |
Moves an action later in the execution order. More... | |
iterator | erase (iterator position) |
Deletes the action at the specified position. More... | |
iterator | erase (iterator first, iterator last) |
Deletes the action at the specified position. More... | |
void | clear () |
Empties the action queue. More... | |
void | turn_shift () |
Shift turn. More... | |
bool | replace (iterator it, action_ptr act) |
Replaces the action at a given position with another action. More... | |
template<typename T > | |
action_set::index< T >::type & | get () |
Returns a given index. More... | |
template<typename T > | |
action_set::index< T >::type const & | get () const |
template<typename T , typename U > | |
action_set::index< T > ::type::iterator | project (U it) |
Projects an iterator on a given index. More... | |
template<typename T , typename U > | |
action_set::index< T > ::type::const_iterator | project (U it) const |
iterator | begin () |
Returns the iterator for the first (executed earlier) action within the actions queue. More... | |
reverse_iterator | rbegin () |
reverse version of the above More... | |
const_iterator | begin () const |
const versions of the above More... | |
const_reverse_iterator | rbegin () const |
const reverse versions of the above More... | |
iterator | end () |
Returns the iterator for the position after the last executed action within the actions queue. More... | |
reverse_iterator | rend () |
reverse version of the above More... | |
const_iterator | end () const |
const versions of the above More... | |
const_reverse_iterator | rend () const |
const reverse versions of the above More... | |
bool | empty () const |
Indicates whether the action queue is empty. More... | |
size_t | size () const |
Returns the number of actions in the action queue. More... | |
size_t | num_turns () const |
Returns the number of turns that have plans. More... | |
size_t | get_turn (const_iterator it) const |
Returns the turn of a given iterator planned execution. More... | |
size_t | position_in_turn (const_iterator it) const |
Returns the position of a given iterator in its turn. More... | |
iterator | turn_begin (size_t turn_num) |
Returns the iterator for the first (executed earlier) action of a given turn within the actions queue. More... | |
const_iterator | turn_begin (size_t turn_num) const |
reverse_iterator | turn_rbegin (size_t turn_num) |
const_reverse_iterator | turn_rbegin (size_t turn_num) const |
iterator | turn_end (size_t turn_num) |
const_iterator | turn_end (size_t turn_num) const |
reverse_iterator | turn_rend (size_t turn_num) |
const_reverse_iterator | turn_rend (size_t turn_num) const |
range_t | iter_turn (size_t turn_num) |
Returns an iterator range corresponding to the requested turn. More... | |
rrange_t | riter_turn (size_t turn_num) |
crange_t | iter_turn (size_t turn_num) const |
crrange_t | riter_turn (size_t turn_num) const |
size_t | turn_size (size_t turn_num) const |
Returns the number of actions planned for turn turn_num. More... | |
action_set const & | actions () const |
Get the underlying action container. More... | |
Private Member Functions | |
size_t | get_turn_impl (size_t begin, size_t end, const_iterator it) const |
Binary search to find the occuring turn of the action pointed by an iterator. More... | |
Private Attributes | |
action_set | actions_ |
action_limits | turn_beginnings_ |
Contains a list of iterator to the beginning of each turn. More... | |
Datastructure holding the actions of a side on multiple turns.
Definition at line 42 of file side_actions.hpp.
typedef std::deque<iterator> wb::side_actions_container::action_limits |
Definition at line 82 of file side_actions.hpp.
typedef boost::multi_index::multi_index_container< action_ptr, boost::multi_index::indexed_by< boost::multi_index::random_access< boost::multi_index::tag< chronological > >, boost::multi_index::hashed_non_unique< boost::multi_index::tag< by_unit >, boost::multi_index::const_mem_fun< action, size_t, &action::get_unit_id > >, boost::multi_index::hashed_non_unique< boost::multi_index::tag< by_hex >, boost::multi_index::const_mem_fun< action, map_location, &action::get_numbering_hex > > > > wb::side_actions_container::action_set |
Underlying container.
Definition at line 70 of file side_actions.hpp.
typedef action_set::index<chronological>::type::const_iterator wb::side_actions_container::const_iterator |
Definition at line 73 of file side_actions.hpp.
typedef action_set::index<chronological>::type::const_reverse_iterator wb::side_actions_container::const_reverse_iterator |
Definition at line 75 of file side_actions.hpp.
typedef std::pair<const_iterator,const_iterator> wb::side_actions_container::crange_t |
Definition at line 79 of file side_actions.hpp.
typedef std::pair<const_reverse_iterator,const_reverse_iterator> wb::side_actions_container::crrange_t |
Definition at line 80 of file side_actions.hpp.
typedef action_set::index<chronological>::type::iterator wb::side_actions_container::iterator |
Definition at line 72 of file side_actions.hpp.
typedef std::pair<iterator,iterator> wb::side_actions_container::range_t |
Definition at line 77 of file side_actions.hpp.
typedef action_set::index<chronological>::type::reverse_iterator wb::side_actions_container::reverse_iterator |
Definition at line 74 of file side_actions.hpp.
typedef std::pair<reverse_iterator,reverse_iterator> wb::side_actions_container::rrange_t |
Definition at line 78 of file side_actions.hpp.
wb::side_actions_container::side_actions_container | ( | ) |
Definition at line 72 of file side_actions.cpp.
|
inline |
Get the underlying action container.
Definition at line 256 of file side_actions.hpp.
References actions_.
|
inline |
Returns the iterator for the first (executed earlier) action within the actions queue.
Definition at line 176 of file side_actions.hpp.
References actions_, and begin().
Referenced by begin(), wb::side_actions::begin(), BOOST_AUTO_TEST_CASE(), bump_earlier(), get_turn_impl(), and insert().
|
inline |
side_actions_container::iterator wb::side_actions_container::bump_earlier | ( | iterator | position | ) |
Moves an action earlier in the execution order.
i.e. at the front of the queue by one position.
Definition at line 184 of file side_actions.cpp.
References actions_, begin(), and end().
Referenced by wb::side_actions::bump_earlier(), and bump_later().
side_actions_container::iterator wb::side_actions_container::bump_later | ( | iterator | position | ) |
Moves an action later in the execution order.
i.e. at the back of the queue by one position.
Definition at line 197 of file side_actions.cpp.
References bump_earlier().
|
inline |
Empties the action queue.
Definition at line 141 of file side_actions.hpp.
References actions_, and turn_beginnings_.
Referenced by wb::side_actions::clear().
|
inline |
Indicates whether the action queue is empty.
Definition at line 198 of file side_actions.hpp.
References actions_.
Referenced by wb::side_actions::empty(), and wb::side_actions::execute().
|
inline |
Returns the iterator for the position after the last executed action within the actions queue.
Definition at line 187 of file side_actions.hpp.
References actions_, and end().
Referenced by bump_earlier(), end(), wb::side_actions::end(), erase(), wb::side_actions::execute(), wb::side_actions::find_first_action_of(), get_turn_impl(), insert(), push_front(), queue(), and turn_begin().
|
inline |
side_actions_container::iterator wb::side_actions_container::erase | ( | iterator | position | ) |
Deletes the action at the specified position.
Definition at line 202 of file side_actions.cpp.
References actions_, end(), gui2::event::find(), get_turn(), next, size(), turn_beginnings_, and turn_end().
Referenced by BOOST_AUTO_TEST_CASE(), erase(), wb::side_actions::raw_turn_shift(), and wb::side_actions::safe_erase().
side_actions_container::iterator wb::side_actions_container::erase | ( | iterator | first, |
iterator | last | ||
) |
Deletes the action at the specified position.
Definition at line 238 of file side_actions.cpp.
References erase().
|
inline |
Returns a given index.
Definition at line 161 of file side_actions.hpp.
References actions_.
Referenced by wb::side_actions::actions_of(), wb::side_actions::count_actions_of(), wb::side_actions::find_first_action_at(), wb::side_actions::find_first_action_of(), wb::side_actions::find_last_action_of(), and wb::side_actions::unit_has_actions().
|
inline |
Definition at line 163 of file side_actions.hpp.
References actions_.
size_t wb::side_actions_container::get_turn | ( | const_iterator | it | ) | const |
Returns the turn of a given iterator planned execution.
The value returned is the difference between the planned turn and the current turn.
0 | If the action is planned for the current turn. |
Definition at line 93 of file side_actions.cpp.
References get_turn_impl(), and num_turns().
Referenced by erase(), wb::side_actions::get_turn(), and position_in_turn().
|
private |
Binary search to find the occuring turn of the action pointed by an iterator.
Definition at line 78 of file side_actions.cpp.
References begin(), end(), and turn_beginnings_.
Referenced by get_turn().
side_actions_container::iterator wb::side_actions_container::insert | ( | iterator | position, |
action_ptr | action | ||
) |
Inserts an action at the specified position.
The planned turn of the inserted action is the same as the planned turn of position-1 before the insertion. If position == begin(), the new action will became the first action of the current turn.
position | The iterator before which action will be inserted. |
action | The action to insert. |
end() | When the action can't be inserted. |
Definition at line 137 of file side_actions.cpp.
References actions_, begin(), end(), and turn_beginnings_.
Referenced by BOOST_AUTO_TEST_CASE(), push_front(), wb::side_actions::safe_insert(), and wb::side_actions::synced_insert().
|
inline |
Returns an iterator range corresponding to the requested turn.
Definition at line 247 of file side_actions.hpp.
References turn_begin(), and turn_end().
Referenced by wb::side_actions::iter_turn().
|
inline |
Definition at line 249 of file side_actions.hpp.
References turn_begin(), and turn_end().
|
inline |
Returns the number of turns that have plans.
If the container holds only one action on turn 1 (that is turn 0 is empty), this function will still returns 2. Indeed, turn 0 has an "empty" plan.
Definition at line 212 of file side_actions.hpp.
References turn_beginnings_.
Referenced by BOOST_AUTO_TEST_CASE(), get_turn(), wb::side_actions::num_turns(), queue(), and turn_begin().
size_t wb::side_actions_container::position_in_turn | ( | const_iterator | it | ) | const |
Returns the position of a given iterator in its turn.
Definition at line 98 of file side_actions.cpp.
References get_turn(), and turn_begin().
Referenced by wb::side_actions::bump_earlier(), wb::side_actions::insert_action(), wb::side_actions::make_net_cmd_bump_later(), wb::side_actions::make_net_cmd_insert(), wb::side_actions::make_net_cmd_refresh(), wb::side_actions::make_net_cmd_remove(), wb::side_actions::make_net_cmd_replace(), and wb::side_actions::remove_action().
|
inline |
Projects an iterator on a given index.
Definition at line 169 of file side_actions.hpp.
References actions_.
Referenced by wb::side_actions::find_first_action_of().
|
inline |
Definition at line 171 of file side_actions.hpp.
References actions_.
side_actions_container::iterator wb::side_actions_container::push_front | ( | size_t | turn, |
action_ptr | action | ||
) |
Pushes an action in front of a given turn.
Definition at line 120 of file side_actions.cpp.
References end(), insert(), queue(), turn_begin(), turn_beginnings_, and turn_size().
Referenced by wb::side_actions::safe_insert().
side_actions_container::iterator wb::side_actions_container::queue | ( | size_t | turn_num, |
action_ptr | action | ||
) |
Queues an action to be executed last.
end() | when the action can't be inserted |
Definition at line 154 of file side_actions.cpp.
References actions_, end(), num_turns(), turn_beginnings_, turn_end(), and turn_size().
Referenced by BOOST_AUTO_TEST_CASE(), push_front(), and wb::side_actions::synced_enqueue().
|
inline |
reverse version of the above
Definition at line 178 of file side_actions.hpp.
References actions_, and rbegin().
Referenced by rbegin(), and wb::side_actions::rbegin().
|
inline |
const reverse versions of the above
Definition at line 182 of file side_actions.hpp.
References actions_.
|
inline |
reverse version of the above
Definition at line 189 of file side_actions.hpp.
References actions_, and rend().
Referenced by rend(), and wb::side_actions::rend().
|
inline |
const reverse versions of the above
Definition at line 193 of file side_actions.hpp.
References actions_.
|
inline |
Replaces the action at a given position with another action.
Definition at line 154 of file side_actions.hpp.
References actions_.
Referenced by wb::side_actions::execute_net_cmd().
|
inline |
Definition at line 248 of file side_actions.hpp.
References turn_rbegin(), and turn_rend().
Referenced by wb::side_actions::riter_turn().
|
inline |
Definition at line 250 of file side_actions.hpp.
References turn_rbegin(), and turn_rend().
|
inline |
Returns the number of actions in the action queue.
Definition at line 203 of file side_actions.hpp.
References actions_.
Referenced by erase(), and wb::side_actions::size().
side_actions_container::iterator wb::side_actions_container::turn_begin | ( | size_t | turn_num | ) |
Returns the iterator for the first (executed earlier) action of a given turn within the actions queue.
Definition at line 103 of file side_actions.cpp.
References end(), num_turns(), and turn_beginnings_.
Referenced by iter_turn(), position_in_turn(), push_front(), wb::side_actions::turn_begin(), turn_end(), turn_rend(), and turn_size().
side_actions_container::const_iterator wb::side_actions_container::turn_begin | ( | size_t | turn_num | ) | const |
Definition at line 111 of file side_actions.cpp.
References end(), num_turns(), and turn_beginnings_.
|
inline |
Definition at line 239 of file side_actions.hpp.
References turn_begin().
Referenced by erase(), iter_turn(), queue(), wb::side_actions::turn_end(), turn_rbegin(), and turn_size().
|
inline |
Definition at line 240 of file side_actions.hpp.
References turn_begin().
|
inline |
Definition at line 233 of file side_actions.hpp.
References turn_end().
Referenced by riter_turn(), and wb::side_actions::turn_rbegin().
|
inline |
Definition at line 234 of file side_actions.hpp.
References turn_end().
|
inline |
Definition at line 241 of file side_actions.hpp.
References turn_begin().
Referenced by riter_turn(), and wb::side_actions::turn_rend().
|
inline |
Definition at line 242 of file side_actions.hpp.
References turn_begin().
|
inline |
Shift turn.
The turn 0 is deleted, the actions of turn n are moved to turn n-1.
Definition at line 149 of file side_actions.hpp.
References turn_beginnings_, and turn_size().
Referenced by wb::side_actions::raw_turn_shift().
|
inline |
Returns the number of actions planned for turn turn_num.
Definition at line 253 of file side_actions.hpp.
References turn_begin(), and turn_end().
Referenced by push_front(), queue(), turn_shift(), and wb::side_actions::turn_size().
|
private |
|
private |
Contains a list of iterator to the beginning of each turn.
Definition at line 272 of file side_actions.hpp.
Referenced by clear(), erase(), get_turn_impl(), insert(), num_turns(), push_front(), queue(), turn_begin(), and turn_shift().