Category Class Reference

Represents a Category. More...

#include <category.hpp>

Inheritance diagram for Category:

ModelCategory

List of all members.

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


Detailed Description

Represents a Category.

Many categories may have one or more items.

Definition at line 37 of file category.hpp.


Constructor & Destructor Documentation

Category::~Category (  )  [inline]

Definition at line 43 of file category.hpp.


Member Function Documentation

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]

void Category::set_name ( const std::string  name  )  [inline]

std::string Category::get_name (  )  [inline]

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.

Parameters:
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.

Parameters:
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().


Friends And Related Function Documentation

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]

Reimplemented in ModelCategory.

Definition at line 58 of file category.hpp.


Member Data Documentation

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().


The documentation for this class was generated from the following files:

Copyright 2008, 2009 Frank Dean