Kitlist  1.1.0
category.cpp
Go to the documentation of this file.
1 /*
2 
3  This file is part of Kitlist, a program to maintain a simple list
4  of items and assign items to one or more categories.
5 
6  Copyright (C) 2008,2009 Frank Dean
7 
8  Kitlist is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  Kitlist is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with Kitlist. If not, see <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #include <algorithm>
24 // #include <iterator>
25 #include "category.hpp"
26 
27 
29 void Category::add_item(Item* item) {
30  m_items.push_back(item);
31 }
32 
33 
41  ItemIter i = std::find(m_items.begin(), m_items.end(), item);
42  if (i != m_items.end()) {
43  m_items.erase(i);
44  }
45 }
46 
47 
56  for (ItemIter i = m_items.begin(); i != m_items.end(); ++i) {
57  if (slot(*(*i)))
58  break;
59  }
60 }
61 
62 
72  for (ItemIter i = m_items.begin(); i != m_items.end(); ++i) {
73  if (functor(**i))
74  break;
75  }
76 }
ItemContainer m_items
List of associated items.
Definition: category.hpp:41
ItemContainer::iterator ItemIter
Definition: item.hpp:92
virtual void add_item(Item *item)
Associates the passed item with this Category.
Definition: category.cpp:29
void foreach_item(const SlotForeachItem &slot)
Executes a callback function for each associated item.
Definition: category.cpp:55
sigc::slot< bool, Item & > SlotForeachItem
Definition: item.hpp:97
Represents an Item.
Definition: item.hpp:37
virtual void remove_item(Item *item)
Removes the association of the passed item from this Category.
Definition: category.cpp:40
void execute(ItemFunctor &functor)
Executes the passed ItemFunctor.
Definition: category.cpp:71
Functor for processing items.
Definition: item.hpp:85

Copyright 2008-2021 Frank Dean