Kitlist
A list manager for maintaining kit lists
Loading...
Searching...
No Matches
Item Class Reference

Represents a Item having a many-to-many relationship to zero or more Category instances. More...

#include "item.hpp"

Public Member Functions

 Item ()
 Default constructor.
int32_t get_id () const
const std::string get_name () const
bool is_checked () const
 Whether this Item is checked.

Public Attributes

std::string name
 The descriptive name of the Item.
bool checked
 Whether the item is in a checked state.

Protected Member Functions

 Item (int32_t id, std::string name, bool checked)
 Constructor taking the id and name of the Item.
void set_checked (bool state)
 Sets the checked state of the Item instance.
void set_name (const std::string &name)
 Sets the descriptive name of the Item instance.

Private Attributes

std::vector< std::weak_ptr< Category > > categories
 List of Category instances this item belongs to.
std::map< int32_t, std::weak_ptr< Category > > category_map
 A map containing all the categories, keyed by id.
int32_t id
 The unique ID of the Item within the Model instance.

Friends

class KitParser
class Model
bool operator< (Item &lhs, Item &rhs)
 Compares two Item instances.
bool operator< (std::shared_ptr< Item > lhs, std::shared_ptr< Item > rhs)
 Compares two std::shared_ptr references to Item instances.

Detailed Description

Represents a Item having a many-to-many relationship to zero or more Category instances.

Definition at line 41 of file item.hpp.

Constructor & Destructor Documentation

◆ Item() [1/2]

Item::Item ( )
inline

Default constructor.

Definition at line 48 of file item.hpp.

◆ Item() [2/2]

Item::Item ( int32_t id,
std::string name,
bool checked )
inlineprotected

Constructor taking the id and name of the Item.

This constructor is intended to only be used by the process reading from the Kitlist XML file, hence it has protected scope.

Parameters
idthe unique ID of the Item.
namethe item's descriptive name.
checkedthe item's checked state.

Definition at line 112 of file item.hpp.

Member Function Documentation

◆ get_id()

int32_t Item::get_id ( ) const
inline

The unique ID of this Item.

Returns
the unique ID of the Item instance.

Definition at line 65 of file item.hpp.

◆ get_name()

const std::string Item::get_name ( ) const
inline

This item's name.

Returns
the descriptive name of the Item instance.

Definition at line 73 of file item.hpp.

◆ is_checked()

bool Item::is_checked ( ) const
inline

Whether this Item is checked.

Returns
the checked state of the Item instance.

Definition at line 82 of file item.hpp.

◆ set_checked()

void Item::set_checked ( bool state)
inlineprotected

Sets the checked state of the Item instance.

Definition at line 118 of file item.hpp.

◆ set_name()

void Item::set_name ( const std::string & name)
inlineprotected

Sets the descriptive name of the Item instance.

Definition at line 123 of file item.hpp.

◆ KitParser

friend class KitParser
friend

Definition at line 43 of file item.hpp.

◆ Model

friend class Model
friend

Definition at line 44 of file item.hpp.

◆ operator< [1/2]

bool operator< ( Item & lhs,
Item & rhs )
friend

Compares two Item instances.

Definition at line 89 of file item.hpp.

◆ operator< [2/2]

bool operator< ( std::shared_ptr< Item > lhs,
std::shared_ptr< Item > rhs )
friend

Compares two std::shared_ptr references to Item instances.

Definition at line 96 of file item.hpp.

Member Data Documentation

◆ categories

std::vector<std::weak_ptr<Category> > Item::categories
private

List of Category instances this item belongs to.

Definition at line 129 of file item.hpp.

◆ category_map

std::map<int32_t, std::weak_ptr<Category> > Item::category_map
private

A map containing all the categories, keyed by id.

Definition at line 132 of file item.hpp.

◆ checked

bool Item::checked

Whether the item is in a checked state.

This allows the user to choose operations that only operate on checked items and to filter the list of items using the checked state.

Definition at line 59 of file item.hpp.

◆ id

int32_t Item::id
private

The unique ID of the Item within the Model instance.

Definition at line 135 of file item.hpp.

◆ name

std::string Item::name

The descriptive name of the Item.

Definition at line 51 of file item.hpp.


The documentation for this class was generated from the following file:
  • /Users/frank/Projects/kitlist/src/item.hpp
Copyright 2008-2025 Frank Dean