KitList Class Reference

Main application class. More...

List of all members.

Public Member Functions

 KitList (const string dbname, const string user, const string port, bool verbose=false)
 Constructor specifying Postgresql database connection parameters.
 ~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.
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

KitListDaom_dao
 Reference to an implementation DAO class.


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 83 of file main.cpp.


Constructor & Destructor Documentation

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:
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.

KitList::~KitList (  ) 

Definition at line 176 of file main.cpp.

References m_dao.


Member Function Documentation

KitListDao* KitList::get_dao (  )  [inline]

Definition at line 89 of file main.cpp.

References m_dao.

Referenced by main().

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.

Parameters:
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.

Parameters:
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 
)

Associates an existing item with an existing category.

Parameters:
id The Item ID
cat_id The Category ID

Definition at line 219 of file main.cpp.

References KitListDao::associate_item_with_category(), and m_dao.

Referenced by main().

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_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'.

Parameters:
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.

Parameters:
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.

See also:
ItemFunctor.

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.

Parameters:
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 (  ) 

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 452 of file main.cpp.

References KitListDao::get_categories(), html_flag, and m_dao.

Referenced by main().

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  ) 

Deletes the Category with the specified id.

Parameters:
id The Category id.

Definition at line 440 of file main.cpp.

References KitListDao::delete_category(), and m_dao.

Referenced by main().

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 
)

Un-associates the specified item from the specified category.

Parameters:
id The Item id.
cat_id The Category id.

Definition at line 430 of file main.cpp.

References m_dao, and KitListDao::remove_item_from_category().

Referenced by main().

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  ) 

Checks/ticks all items in the specified Category.

Definition at line 528 of file main.cpp.

References m_dao, and KitListDao::set_category_flag().

Referenced by main().

void KitList::unset_category_flag ( long  id  ) 

Unchecks/unticks all items in the specified Category.

Definition at line 537 of file main.cpp.

References m_dao, and KitListDao::unset_category_flag().

Referenced by main().

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().


Member Data Documentation

KitListDao* KitList::m_dao [protected]


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

Copyright 2008-2010 Frank Dean