Public Member Functions | |
KitList (const string dbname, const string user, const string port, bool verbose=false) | |
Constructor specifying Postgresql database connection parameters. | |
~KitList () | |
KitListDao * | get_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. | |
void | associate_item_with_category (long id, long cat_id) |
Associates an existing item with an existing category. | |
void | list_items_start (bool empty_list) |
Called before writing a list of items to STDOUT. | |
void | list_item (Item &item) |
Outputs details of the passed item to STDOUT. | |
void | list_items_end (bool empty_list, size_t count) |
Called after writing a list of items to STDOUT. | |
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. | |
void | list_categories () |
Lists details of all categories to STDOUT. | |
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 | |
KitListDao * | m_dao |
Reference to an implementation DAO 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 83 of file main.cpp.
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.
dbname | The name of the database. | |
user | The database user name to connect with. | |
port | The database port to connect to. | |
verbose | Optional parameter indicating whether to include verbose output to STDOUT. Defaults to false. |
Definition at line 167 of file main.cpp.
References m_dao.
KitListDao* KitList::get_dao | ( | ) | [inline] |
void KitList::add_item | ( | const string | name | ) |
Referenced by main().
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.
name | The name of the item to create. | |
cat_id | The 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 189 of file main.cpp.
References KitListDao::add_item(), and m_dao.
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.
from_cat_id | The ID of the source category. | |
to_cat_id | The ID of the target category. | |
choice | One of ALL_ITEMS, CHECKED_ITEMS or UNCHECKED_ITEMS. |
Definition at line 208 of file main.cpp.
References KitListDao::append_items_to_category(), and m_dao.
Referenced by main().
void KitList::associate_item_with_category | ( | long | id, | |
long | cat_id | |||
) |
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'.
empty_list | Set to true if the list is empty. If so, table headings will not be output. |
Definition at line 243 of file main.cpp.
References html_flag.
Referenced by list_items().
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 297 of file main.cpp.
References Item::get_description(), Item::get_id(), and html_flag.
Referenced by list_items(), and on_list_item().
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'.
empty_list | Set to true if the list is empty. If so, a table footer will not be output. |
Definition at line 274 of file main.cpp.
References html_flag.
Referenced by list_items().
void KitList::list_items | ( | Category & | c | ) |
Lists details of all items in the passed Category to STDOUT.
Definition at line 313 of file main.cpp.
References Category::foreach_item(), Category::has_items(), Category::item_count(), list_items_end(), list_items_start(), and on_list_item().
Referenced by list_items(), and main().
bool KitList::on_list_item | ( | Item & | item | ) |
A callback function to output details of the passed Item to STDOUT.
Definition at line 228 of file main.cpp.
References list_item().
Referenced by list_items().
void KitList::list_items | ( | ItemContainer & | items | ) |
Lists details of all items in the passed ItemContainer to STDOUT.
Definition at line 323 of file main.cpp.
References list_item(), list_items_end(), and list_items_start().
void KitList::list_items | ( | long | cat_id, | |
item_choice | choice = ALL_ITEMS | |||
) |
Lists details of items to STDOUT.
cat_id | The ID Of the Category to list. If the value is less than zero, all items are listed. | |
choice | Optional. One of ALL_ITEMS (default), CHECKED_ITEMS or UNCHECKED_ITEMS. |
Definition at line 341 of file main.cpp.
References KitListDao::get_all_items(), KitListDao::get_category(), list_items(), and m_dao.
void KitList::execute | ( | ItemContainer & | items, | |
ItemFunctor & | functor | |||
) |
Executes the passed ItemFunctor for each item in the ItemContainer.
Definition at line 361 of file main.cpp.
Referenced by tick_items().
void KitList::tick_items | ( | Category & | c | ) |
Checks/ticks all items in the passed Category.
Definition at line 383 of file main.cpp.
References Category::execute(), m_dao, and KitListDao::update_item_checked_state().
Referenced by main(), and tick_items().
void KitList::tick_items | ( | ItemContainer & | items | ) |
Checks/ticks all items in the passed ItemContainer.
Definition at line 372 of file main.cpp.
References execute(), m_dao, and KitListDao::update_item_checked_state().
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.
choice | One of ALL_ITEMS, CHECKED_ITEMS or UNCHECKED_ITEMS. |
Definition at line 399 of file main.cpp.
References KitListDao::get_all_items(), KitListDao::get_category(), m_dao, and tick_items().
void KitList::list_categories | ( | ) |
void KitList::new_category | ( | const string | name | ) |
Creates a new category with the passed name.
Definition at line 501 of file main.cpp.
References m_dao, and KitListDao::new_category().
Referenced by main().
void KitList::delete_category | ( | long | id | ) |
void KitList::delete_item | ( | long | id | ) |
Deletes the item with the passed id.
Definition at line 418 of file main.cpp.
References KitListDao::delete_item(), and m_dao.
Referenced by main().
void KitList::remove_item_from_category | ( | long | id, | |
long | cat_id | |||
) |
void KitList::set_item_flag | ( | long | id | ) |
Checks/ticks the specified item.
Definition at line 510 of file main.cpp.
References m_dao, and KitListDao::set_item_flag().
Referenced by main().
void KitList::unset_item_flag | ( | long | id | ) |
Unchecks/unticks the specified item.
Definition at line 519 of file main.cpp.
References m_dao, and KitListDao::unset_item_flag().
Referenced by main().
void KitList::set_category_flag | ( | long | id | ) |
void KitList::unset_category_flag | ( | long | id | ) |
void KitList::set_all_flags | ( | ) |
Checks/ticks all items.
Definition at line 546 of file main.cpp.
References m_dao, and KitListDao::set_all_flags().
Referenced by main().
void KitList::unset_all_flags | ( | ) |
Unchecks/unticks all items.
Definition at line 555 of file main.cpp.
References m_dao, and KitListDao::unset_all_flags().
Referenced by main().
KitListDao* KitList::m_dao [protected] |
Reference to an implementation DAO class.
Definition at line 85 of file main.cpp.
Referenced by add_item(), append_items_to_category(), associate_item_with_category(), delete_category(), delete_item(), get_dao(), KitList(), list_categories(), list_items(), new_category(), remove_item_from_category(), set_all_flags(), set_category_flag(), set_item_flag(), tick_items(), unset_all_flags(), unset_category_flag(), unset_item_flag(), and ~KitList().