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

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

#include "category.hpp"

Public Member Functions

 Category ()
 Default constructor.
int32_t get_id () const
const std::string get_name () const
void sort_items ()
 Sorts the list of items using the Item::operator< for comparison.

Public Attributes

std::string name
 The descriptive name of the Category.

Protected Member Functions

 Category (int32_t id, std::string name)
 Constructor taking the id and name of the Category.
void set_name (const std::string &name)
 Sets the descriptive name of the Category instance.

Private Attributes

int32_t id
 The unique ID of the Category within the Model instance.
std::vector< std::shared_ptr< Item > > items
 Zero or more related Item instances.
std::map< int32_t, std::shared_ptr< Item > > item_map
 A map containing all the items, keyed by id.

Friends

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

Detailed Description

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

Definition at line 41 of file category.hpp.

Constructor & Destructor Documentation

◆ Category() [1/2]

Category::Category ( )
inline

Default constructor.

Definition at line 51 of file category.hpp.

◆ Category() [2/2]

Category::Category ( int32_t id,
std::string name )
inlineprotected

Constructor taking the id and name of the Category.

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 Category.
namethe category's descriptive name.

Definition at line 120 of file category.hpp.

Member Function Documentation

◆ get_id()

int32_t Category::get_id ( ) const
inline

The unique ID of this Category.

Returns
the unique ID of the Category instance.

Definition at line 61 of file category.hpp.

◆ get_name()

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

This category's name.

Returns
the descriptive name of the Category instance.

Definition at line 69 of file category.hpp.

◆ set_name()

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

Sets the descriptive name of the Category instance.

Definition at line 125 of file category.hpp.

◆ sort_items()

void Category::sort_items ( )
inline

Sorts the list of items using the Item::operator< for comparison.

Definition at line 77 of file category.hpp.

◆ KitParser

friend class KitParser
friend

Definition at line 42 of file category.hpp.

◆ Model

friend class Model
friend

Definition at line 43 of file category.hpp.

◆ operator< [1/3]

bool operator< ( const Category & lhs,
const Category & rhs )
friend

Compares two Category instances.

Definition at line 87 of file category.hpp.

◆ operator< [2/3]

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

Compares two std::shared_ptr references to Category instances.

Definition at line 94 of file category.hpp.

◆ operator< [3/3]

bool operator< ( std::weak_ptr< Category > lhs,
std::weak_ptr< Category > rhs )
friend

Compares two std::weak_ptr references to Category instances.

Definition at line 101 of file category.hpp.

◆ XmlWriter

friend class XmlWriter
friend

Definition at line 44 of file category.hpp.

Member Data Documentation

◆ id

int32_t Category::id
private

The unique ID of the Category within the Model instance.

Definition at line 47 of file category.hpp.

◆ item_map

std::map<int32_t, std::shared_ptr<Item> > Category::item_map
private

A map containing all the items, keyed by id.

Definition at line 134 of file category.hpp.

◆ items

std::vector<std::shared_ptr<Item> > Category::items
private

Zero or more related Item instances.

Definition at line 131 of file category.hpp.

◆ name

std::string Category::name

The descriptive name of the Category.

Definition at line 55 of file category.hpp.


The documentation for this class was generated from the following file:
Copyright 2008-2025 Frank Dean