Kitlist
1.1.0
|
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 () | |
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. 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 | |
KitListDao * | m_dao |
Reference to an implementation DAO class. More... | |
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.
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. |
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. |
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 203 of file main.cpp.
Referenced by main().
void KitList::associate_item_with_category | ( | long | id, |
long | cat_id | ||
) |
void KitList::delete_category | ( | long | id | ) |
void KitList::delete_item | ( | long | id | ) |
void KitList::execute | ( | ItemContainer & | items, |
ItemFunctor & | functor | ||
) |
Executes the passed ItemFunctor for each item in the ItemContainer.
|
inline |
void KitList::list_categories | ( | ) |
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.
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().
void KitList::list_items | ( | ItemContainer & | items | ) |
void KitList::list_items | ( | long | cat_id, |
item_choice | choice = ALL_ITEMS |
||
) |
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 269 of file main.cpp.
References html_flag.
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 238 of file main.cpp.
References html_flag.
void KitList::new_category | ( | const string | name | ) |
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().
void KitList::remove_item_from_category | ( | long | id, |
long | cat_id | ||
) |
void KitList::set_all_flags | ( | ) |
void KitList::set_category_flag | ( | long | id | ) |
void KitList::set_item_flag | ( | long | id | ) |
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().
void KitList::tick_items | ( | ItemContainer & | items | ) |
void KitList::tick_items | ( | long | cat_id, |
item_choice | choice = ALL_ITEMS |
||
) |
void KitList::unset_all_flags | ( | ) |
void KitList::unset_category_flag | ( | long | id | ) |
void KitList::unset_item_flag | ( | long | id | ) |
|
protected |