#include <category.hpp>
Public Member Functions | |
~Category () | |
void | set_id (long id) |
long | get_id () |
void | set_name (const std::string name) |
std::string | get_name () |
virtual void | add_item (Item *item) |
Associates the passed item with this Category. | |
virtual void | remove_item (Item *item) |
Removes the association of the passed item from this Category. | |
virtual size_t | item_count () |
Returns the number of items associated with this category. | |
virtual bool | has_items () |
Returns true if there are any items associated with this category. | |
void | foreach_item (const SlotForeachItem &slot) |
Executes a callback function for each associated item. | |
void | execute (ItemFunctor &functor) |
Executes the passed ItemFunctor. | |
Protected Attributes | |
long | m_id |
Unique id. | |
std::string | m_name |
The category name. | |
ItemContainer | m_items |
List of associated items. | |
Friends | |
class | CategoryCompareName |
class | CategoryCompareId |
class | KitModel |
Many categories may have one or more items.
Definition at line 37 of file category.hpp.
Category::~Category | ( | ) | [inline] |
Definition at line 43 of file category.hpp.
void Category::set_id | ( | long | id | ) | [inline] |
Definition at line 44 of file category.hpp.
References m_id.
Referenced by Service::create_category(), and KitParser::process_category().
long Category::get_id | ( | ) | [inline] |
Definition at line 45 of file category.hpp.
References m_id.
Referenced by KitModel::add_category(), XmlDao::add_category_to_dom(), KitListGui::close_add_category_window(), XmlDao::get_model(), KitListGui::on_menu_create_category(), KitListGui::on_menu_rename_category(), KitParser::process_category_item(), and KitListGui::refresh_category_list().
void Category::set_name | ( | const std::string | name | ) | [inline] |
Definition at line 46 of file category.hpp.
References m_name.
Referenced by KitListGui::close_add_category_window(), KitParser::on_end_element(), KitListGui::on_menu_create_category(), and KitListGui::on_menu_rename_category().
std::string Category::get_name | ( | ) | [inline] |
Definition at line 47 of file category.hpp.
References m_name.
Referenced by XmlDao::add_category_to_dom(), KitListGui::on_menu_rename_category(), and KitListGui::refresh_category_list().
void Category::add_item | ( | Item * | item | ) | [virtual] |
Associates the passed item with this Category.
Reimplemented in ModelCategory.
Definition at line 29 of file category.cpp.
References m_items.
Referenced by ModelCategory::add_item().
void Category::remove_item | ( | Item * | item | ) | [virtual] |
Removes the association of the passed item from this Category.
The passed item is not deleted.
item | the item to un-associate. |
Reimplemented in ModelCategory.
Definition at line 40 of file category.cpp.
References m_items.
Referenced by ModelCategory::remove_item().
virtual size_t Category::item_count | ( | ) | [inline, virtual] |
Returns the number of items associated with this category.
Definition at line 51 of file category.hpp.
References m_items.
Referenced by KitList::list_items().
virtual bool Category::has_items | ( | ) | [inline, virtual] |
Returns true if there are any items associated with this category.
Definition at line 53 of file category.hpp.
References m_items.
Referenced by KitList::list_items().
void Category::foreach_item | ( | const SlotForeachItem & | slot | ) |
Executes a callback function for each associated item.
The callback function will be passed a reference to the current item being iterated.
slot | the callback function. |
Definition at line 55 of file category.cpp.
References m_items.
Referenced by XmlDao::add_category_to_dom(), and KitList::list_items().
void Category::execute | ( | ItemFunctor & | functor | ) |
Executes the passed ItemFunctor.
The ItemFunctor's override operator() method is called, passing a reference to the item being iterated over. If the called method returns true, the iteration stops and no more calls will be made to the functor.
Definition at line 71 of file category.cpp.
References m_items.
Referenced by KitList::tick_items().
friend class CategoryCompareName [friend] |
Definition at line 56 of file category.hpp.
friend class CategoryCompareId [friend] |
Definition at line 57 of file category.hpp.
friend class KitModel [friend] |
long Category::m_id [protected] |
Unique id.
Definition at line 39 of file category.hpp.
Referenced by get_id(), CategoryCompareId::operator()(), and set_id().
std::string Category::m_name [protected] |
The category name.
Definition at line 40 of file category.hpp.
Referenced by get_name(), CategoryCompareName::operator()(), and set_name().
ItemContainer Category::m_items [protected] |
List of associated items.
Definition at line 41 of file category.hpp.
Referenced by add_item(), KitModel::copy_items(), execute(), foreach_item(), ModelCategory::get_items(), ModelCategory::get_model_items(), has_items(), item_count(), ModelCategory::purge(), and remove_item().