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

Main application class. More...

Public Member Functions

 KitList (const string dbname, const string user, const string port, bool verbose=false)
 Constructor specifying Postgresql database connection parameters. More...
 
 ~KitList ()
 
KitListDaoget_dao ()
 
void add_item (const string name)
 
void add_item (const string name, long cat_id)
 
void append_items_to_category (long from_cat_id, long to_cat_id, item_choice choice)
 Copies items from one category to another. More...
 
void associate_item_with_category (long id, long cat_id)
 Associates an existing item with an existing category. More...
 
void list_items_start (bool empty_list)
 Called before writing a list of items to STDOUT. More...
 
void list_item (Item &item)
 Outputs details of the passed item to STDOUT. More...
 
void list_items_end (bool empty_list, size_t count)
 Called after writing a list of items to STDOUT. More...
 
void list_items (Category &c)
 
bool on_list_item (Item &item)
 
void list_items (ItemContainer &items)
 
void list_items (long cat_id, item_choice choice)
 
void execute (ItemContainer &items, ItemFunctor &functor)
 
void tick_items (Category &c)
 
void tick_items (ItemContainer &items)
 
void tick_items (long cat_id, item_choice choice)
 Checks/ticks all items belonging to a category. More...
 
void list_categories ()
 Lists details of all categories to STDOUT. More...
 
void new_category (const string name)
 
void delete_category (long id)
 
void delete_item (long id)
 
void remove_item_from_category (long id, long cat_id)
 
void set_item_flag (long id)
 
void unset_item_flag (long id)
 
void set_category_flag (long id)
 
void unset_category_flag (long id)
 
void set_all_flags ()
 
void unset_all_flags ()
 

Protected Attributes

KitListDaom_dao
 Reference to an implementation DAO class. More...
 

Detailed Description

Main application class.

Primarily performs application startup and command line parsing. Allows the application to be run either from the command line or as an interactive GUI application.

Definition at line 78 of file main.cpp.

Constructor & Destructor Documentation

◆ KitList()

KitList::KitList ( const string  dbname,
const string  user,
const string  port,
bool  verbose = false 
)

Constructor specifying Postgresql database connection parameters.

Note that the PostgreSQL libraries will use default values for these parameters if they are not specified, including examining environment variables. See the PostgreSQL documentation for full details.

Parameters
dbnameThe name of the database.
userThe database user name to connect with.
portThe database port to connect to.
verboseOptional parameter indicating whether to include verbose output to STDOUT. Defaults to false.

Definition at line 162 of file main.cpp.

◆ ~KitList()

KitList::~KitList ( )

Definition at line 171 of file main.cpp.

Member Function Documentation

◆ add_item() [1/2]

void KitList::add_item ( const string  name)

Referenced by main().

◆ add_item() [2/2]

void KitList::add_item ( const string  name,
long  cat_id 
)

Creates a new item with the specified name and optionally associates it with a category.

Parameters
nameThe name of the item to create.
cat_idThe ID of the existing category to associate the item with. If the ID is less than zero, the item will not be associated with a category. Otherwise, the category must already exist.

Definition at line 184 of file main.cpp.

◆ append_items_to_category()

void KitList::append_items_to_category ( long  from_cat_id,
long  to_cat_id,
item_choice  choice 
)

Copies items from one category to another.

Optionally, only checked or unchecked items are copied.

Parameters
from_cat_idThe ID of the source category.
to_cat_idThe ID of the target category.
choiceOne of ALL_ITEMS, CHECKED_ITEMS or UNCHECKED_ITEMS.

Definition at line 203 of file main.cpp.

Referenced by main().

◆ associate_item_with_category()

void KitList::associate_item_with_category ( long  id,
long  cat_id 
)

Associates an existing item with an existing category.

Parameters
idThe Item ID
cat_idThe Category ID

Definition at line 214 of file main.cpp.

Referenced by main().

◆ delete_category()

void KitList::delete_category ( long  id)

Deletes the Category with the specified id.

Parameters
idThe Category id.

Definition at line 435 of file main.cpp.

Referenced by main().

◆ delete_item()

void KitList::delete_item ( long  id)

Deletes the item with the passed id.

Definition at line 413 of file main.cpp.

Referenced by main().

◆ execute()

void KitList::execute ( ItemContainer items,
ItemFunctor functor 
)

Executes the passed ItemFunctor for each item in the ItemContainer.

See also
ItemFunctor.

Definition at line 356 of file main.cpp.

◆ get_dao()

KitListDao* KitList::get_dao ( )
inline

Definition at line 84 of file main.cpp.

Referenced by main().

◆ list_categories()

void KitList::list_categories ( )

Lists details of all categories to STDOUT.

Renders with HTML if the html_flag has been set using the '–html' command line option.

Definition at line 447 of file main.cpp.

References html_flag.

Referenced by main().

◆ list_item()

void KitList::list_item ( Item item)

Outputs details of the passed item to STDOUT.

Details are wrapped in HTML format if the html_flag has been set. The html_flag is set by the command line option, '–html'.

Definition at line 292 of file main.cpp.

References Item::get_description(), Item::get_id(), and html_flag.

◆ list_items() [1/3]

void KitList::list_items ( Category c)

Lists details of all items in the passed Category to STDOUT.

Definition at line 308 of file main.cpp.

References Category::foreach_item(), Category::has_items(), Category::item_count(), and on_list_item().

Referenced by main().

◆ list_items() [2/3]

void KitList::list_items ( ItemContainer items)

Lists details of all items in the passed ItemContainer to STDOUT.

Definition at line 318 of file main.cpp.

◆ list_items() [3/3]

void KitList::list_items ( long  cat_id,
item_choice  choice = ALL_ITEMS 
)

Lists details of items to STDOUT.

Parameters
cat_idThe ID Of the Category to list. If the value is less than zero, all items are listed.
choiceOptional. One of ALL_ITEMS (default), CHECKED_ITEMS or UNCHECKED_ITEMS.

Definition at line 336 of file main.cpp.

◆ list_items_end()

void KitList::list_items_end ( bool  empty_list,
size_t  count 
)

Called after writing a list of items to STDOUT.

Fundamentally outputs a footer, in either HTML or text format, depending on the value of html_flag. The html_flag is set by the command line option, '–html'.

Parameters
empty_listSet to true if the list is empty. If so, a table footer will not be output.

Definition at line 269 of file main.cpp.

References html_flag.

◆ list_items_start()

void KitList::list_items_start ( bool  empty_list)

Called before writing a list of items to STDOUT.

Fundamentally outputs headings, in either HTML or text format, depending on the value of html_flag. The html_flag is set by the command line option, '–html'.

Parameters
empty_listSet to true if the list is empty. If so, table headings will not be output.

Definition at line 238 of file main.cpp.

References html_flag.

◆ new_category()

void KitList::new_category ( const string  name)

Creates a new category with the passed name.

Definition at line 496 of file main.cpp.

Referenced by main().

◆ on_list_item()

bool KitList::on_list_item ( Item item)

A callback function to output details of the passed Item to STDOUT.

Definition at line 223 of file main.cpp.

Referenced by list_items().

◆ remove_item_from_category()

void KitList::remove_item_from_category ( long  id,
long  cat_id 
)

Un-associates the specified item from the specified category.

Parameters
idThe Item id.
cat_idThe Category id.

Definition at line 425 of file main.cpp.

Referenced by main().

◆ set_all_flags()

void KitList::set_all_flags ( )

Checks/ticks all items.

Definition at line 541 of file main.cpp.

Referenced by main().

◆ set_category_flag()

void KitList::set_category_flag ( long  id)

Checks/ticks all items in the specified Category.

Definition at line 523 of file main.cpp.

Referenced by main().

◆ set_item_flag()

void KitList::set_item_flag ( long  id)

Checks/ticks the specified item.

Definition at line 505 of file main.cpp.

Referenced by main().

◆ tick_items() [1/3]

void KitList::tick_items ( Category c)

Checks/ticks all items in the passed Category.

Definition at line 378 of file main.cpp.

References Category::execute().

Referenced by main().

◆ tick_items() [2/3]

void KitList::tick_items ( ItemContainer items)

Checks/ticks all items in the passed ItemContainer.

Definition at line 367 of file main.cpp.

◆ tick_items() [3/3]

void KitList::tick_items ( long  cat_id,
item_choice  choice = ALL_ITEMS 
)

Checks/ticks all items belonging to a category.

Acts on all items if the cat_id is less than zero. Optionally operates on checked or unchecked items, depending on the value of choice.

Parameters
choiceOne of ALL_ITEMS, CHECKED_ITEMS or UNCHECKED_ITEMS.

Definition at line 394 of file main.cpp.

◆ unset_all_flags()

void KitList::unset_all_flags ( )

Unchecks/unticks all items.

Definition at line 550 of file main.cpp.

Referenced by main().

◆ unset_category_flag()

void KitList::unset_category_flag ( long  id)

Unchecks/unticks all items in the specified Category.

Definition at line 532 of file main.cpp.

Referenced by main().

◆ unset_item_flag()

void KitList::unset_item_flag ( long  id)

Unchecks/unticks the specified item.

Definition at line 514 of file main.cpp.

Referenced by main().

Member Data Documentation

◆ m_dao

KitListDao* KitList::m_dao
protected

Reference to an implementation DAO class.

Definition at line 80 of file main.cpp.


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

Copyright 2008-2021 Frank Dean