Kitlist  1.1.0
Public Member Functions | Protected Attributes | Friends | List of all members
Category Class Reference

Represents a Category. More...

#include <category.hpp>

Inheritance diagram for Category:
ModelCategory

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. More...
 
virtual void remove_item (Item *item)
 Removes the association of the passed item from this Category. More...
 
virtual size_t item_count ()
 Returns the number of items associated with this category. More...
 
virtual bool has_items ()
 Returns true if there are any items associated with this category. More...
 
void foreach_item (const SlotForeachItem &slot)
 Executes a callback function for each associated item. More...
 
void execute (ItemFunctor &functor)
 Executes the passed ItemFunctor. More...
 

Protected Attributes

long m_id
 Unique id. More...
 
std::string m_name
 The category name. More...
 
ItemContainer m_items
 List of associated items. More...
 

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::~Category ( )
inline

Definition at line 43 of file category.hpp.

Member Function Documentation

◆ add_item()

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(), and get_name().

◆ execute()

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 has_items(), and KitList::tick_items().

◆ foreach_item()

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
slotthe callback function.

Definition at line 55 of file category.cpp.

References m_items.

Referenced by XmlDao::add_category_to_dom(), has_items(), and KitList::list_items().

◆ get_id()

long Category::get_id ( )
inline

◆ get_name()

std::string Category::get_name ( )
inline

◆ has_items()

virtual bool Category::has_items ( )
inlinevirtual

Returns true if there are any items associated with this category.

Definition at line 53 of file category.hpp.

References execute(), and foreach_item().

Referenced by KitList::list_items().

◆ item_count()

virtual size_t Category::item_count ( )
inlinevirtual

Returns the number of items associated with this category.

Definition at line 51 of file category.hpp.

Referenced by KitList::list_items().

◆ remove_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
itemthe item to un-associate.

Reimplemented in ModelCategory.

Definition at line 40 of file category.cpp.

References m_items.

Referenced by get_name(), and ModelCategory::remove_item().

◆ set_id()

void Category::set_id ( long  id)
inline

Definition at line 44 of file category.hpp.

Referenced by Service::create_category(), and KitParser::process_category().

◆ set_name()

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

Friends And Related Function Documentation

◆ CategoryCompareId

friend class CategoryCompareId
friend

Definition at line 57 of file category.hpp.

◆ CategoryCompareName

friend class CategoryCompareName
friend

Definition at line 56 of file category.hpp.

◆ KitModel

friend class KitModel
friend

Definition at line 58 of file category.hpp.

Member Data Documentation

◆ m_id

long Category::m_id
protected

Unique id.

Definition at line 39 of file category.hpp.

Referenced by get_id(), and CategoryCompareId::operator()().

◆ m_items

ItemContainer Category::m_items
protected

◆ m_name

std::string Category::m_name
protected

The category name.

Definition at line 40 of file category.hpp.

Referenced by get_name(), and CategoryCompareName::operator()().


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

Copyright 2008-2021 Frank Dean