| 3 | #ifdef DEBUG |
| 4 | |
| 5 | class CLevelDebug |
| 6 | { |
| 7 | public: |
| 8 | template <typename T> |
| 9 | class CItemBase |
| 10 | { |
| 11 | xr_vector<T> m_data; |
| 12 | typedef typename xr_vector<T>::iterator ITEM_STORAGE_VEC_IT; |
| 13 | |
| 14 | struct remove_text_pred |
| 15 | { |
| 16 | LPCSTR text; |
| 17 | remove_text_pred(LPCSTR t) : text(t) {} |
| 18 | bool operator()(const T& item) { return (item.text == text); } |
| 19 | }; |
| 20 | |
| 21 | struct remove_id_pred |
| 22 | { |
| 23 | u32 id; |
| 24 | remove_id_pred(u32 i) : id(i) {} |
| 25 | bool operator()(const T& item) { return (item.id == id); } |
| 26 | }; |
| 27 | |
| 28 | struct sort_id_pred |
| 29 | { |
| 30 | bool operator()(const T& item1, const T& item2) { return (item1.id < item2.id); } |
| 31 | }; |
| 32 | |
| 33 | public: |
| 34 | IC void add_item(T data) |
| 35 | { |
| 36 | m_data.push_back(data); |
| 37 | std::sort(m_data.begin(), m_data.end(), sort_id_pred()); |
| 38 | } |
| 39 | |
| 40 | IC void remove_item(LPCSTR text) |
| 41 | { |
| 42 | ITEM_STORAGE_VEC_IT it = std::remove_if(m_data.begin(), m_data.end(), remove_text_pred(text)); |
| 43 | m_data.erase(it, m_data.end()); |
| 44 | |
| 45 | std::sort(m_data.begin(), m_data.end(), sort_id_pred()); |
| 46 | } |
| 47 | IC void remove_item(u32 id) |
| 48 | { |
| 49 | ITEM_STORAGE_VEC_IT it = std::remove_if(m_data.begin(), m_data.end(), remove_id_pred(id)); |
| 50 | m_data.erase(it, m_data.end()); |
| 51 | |
| 52 | std::sort(m_data.begin(), m_data.end(), sort_id_pred()); |
| 53 | } |
| 54 | IC void clear() { m_data.clear(); } |
| 55 | |
| 56 | template <class T> |
| 57 | IC void process(T& process_pred) |
| 58 | { |
| 59 | for (ITEM_STORAGE_VEC_IT it = m_data.begin(); it != m_data.end(); ++it) |
| 60 | { |
| 61 | process_pred(*it); |
| 62 | } |