Kitlist  1.1.0
Public Member Functions | Protected Attributes | List of all members
KitListDao Class Referenceabstract

Defines the methods that an implementation of this class must implement. More...

#include <kitlistdao.hpp>

Inheritance diagram for KitListDao:
XmlDao

Public Member Functions

 KitListDao (int verbose=0)
 Constructor which will use default database connection parameters. More...
 
virtual ~KitListDao ()
 
virtual KitModelget_model ()=0
 Loads the data model. More...
 
virtual void save_model (KitModel *model)=0
 Saves the current data model. More...
 
void set_verbose (int verbose_flag)
 
int is_verbose ()
 
virtual Categoryget_category (long cat_id, item_choice choice=ALL_ITEMS)=0
 Loads a category. More...
 
virtual ItemContainerget_all_items (item_choice choice=ALL_ITEMS)=0
 Returns a list of all items. More...
 
virtual long add_item (const std::string name)=0
 
virtual long add_item (const std::string name, long cat_id)=0
 
virtual void append_items_to_category (long to_cat_id, long from_cat_id=-1, item_choice choice=ALL_ITEMS)=0
 Copies items from one category to another. More...
 
virtual void associate_item_with_category (long id, long cat_id)=0
 Associates an existing item with an existing category. More...
 
virtual CategoryContainer get_categories ()=0
 
virtual long new_category (const std::string name)=0
 Creates a new category. More...
 
virtual void delete_item (long id)=0
 
virtual void update_item_checked_state (ItemContainer &items)=0
 Persists the state of the 'checked' flag of each item. More...
 
virtual void remove_item_from_category (long id, long cat_id)=0
 
virtual long get_next_item_id ()=0
 
virtual long get_next_category_id ()=0
 
virtual void delete_category (long id)=0
 
virtual void set_item_flag (long id)=0
 
virtual void unset_item_flag (long id)=0
 
virtual void set_category_flag (long id)=0
 
virtual void unset_category_flag (long id)=0
 
virtual void set_all_flags ()=0
 
virtual void unset_all_flags ()=0
 
virtual bool require_filename ()
 Indicates whether the implementation of the data model requires a filename. More...
 

Protected Attributes

int m_verbose_flag
 

Detailed Description

Defines the methods that an implementation of this class must implement.

Definition at line 46 of file kitlistdao.hpp.

Constructor & Destructor Documentation

◆ KitListDao()

KitListDao::KitListDao ( int  verbose = 0)
inline

Constructor which will use default database connection parameters.

Parameters
verboseOptional parameter indicating whether to include verbose output to STDOUT. Defaults to false.

Definition at line 59 of file kitlistdao.hpp.

◆ ~KitListDao()

virtual KitListDao::~KitListDao ( )
inlinevirtual

Definition at line 61 of file kitlistdao.hpp.

References get_model(), and save_model().

Member Function Documentation

◆ add_item() [1/2]

virtual long KitListDao::add_item ( const std::string  name)
pure virtual

Creates a new item.

Parameters
nameThe name of the new item.

Implemented in XmlDao.

Referenced by is_verbose().

◆ add_item() [2/2]

virtual long KitListDao::add_item ( const std::string  name,
long  cat_id 
)
pure virtual

Creates a new item and associates it with a category.

Parameters
nameThe name of the new item.

Implemented in XmlDao.

◆ append_items_to_category()

virtual void KitListDao::append_items_to_category ( long  to_cat_id,
long  from_cat_id = -1,
item_choice  choice = ALL_ITEMS 
)
pure virtual

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.

Implemented in XmlDao.

Referenced by is_verbose().

◆ associate_item_with_category()

virtual void KitListDao::associate_item_with_category ( long  id,
long  cat_id 
)
pure virtual

Associates an existing item with an existing category.

Parameters
idThe Item ID
cat_idThe Category ID

Implemented in XmlDao.

Referenced by is_verbose().

◆ delete_category()

virtual void KitListDao::delete_category ( long  id)
pure virtual

Deletes a category.

Implemented in XmlDao.

Referenced by is_verbose().

◆ delete_item()

virtual void KitListDao::delete_item ( long  id)
pure virtual

Deletes an item by it's ID.

Parameters
idthe ID of the item to delete.

Implemented in XmlDao.

Referenced by is_verbose().

◆ get_all_items()

virtual ItemContainer* KitListDao::get_all_items ( item_choice  choice = ALL_ITEMS)
pure virtual

Returns a list of all items.

Parameters
choiceWhich items to load. One of ALL_ITEMS, CHECKED_ITEMS or UNCHECKED_ITEMS.

Implemented in XmlDao.

Referenced by is_verbose().

◆ get_categories()

virtual CategoryContainer KitListDao::get_categories ( )
pure virtual

Returns a list of all categories.

Implemented in XmlDao.

Referenced by is_verbose().

◆ get_category()

virtual Category* KitListDao::get_category ( long  cat_id,
item_choice  choice = ALL_ITEMS 
)
pure virtual

Loads a category.

Parameters
choiceWhich items to load for the category. One of ALL_ITEMS, CHECKED_ITEMS or UNCHECKED_ITEMS.

Implemented in XmlDao.

Referenced by is_verbose().

◆ get_model()

virtual KitModel* KitListDao::get_model ( )
pure virtual

Loads the data model.

The data model holds a rich graph of objects, representing the entire list of categories and items.

See also
KitModel

Implemented in XmlDao.

Referenced by Service::create_default_model(), Service::load_model(), and ~KitListDao().

◆ get_next_category_id()

virtual long KitListDao::get_next_category_id ( )
pure virtual

Returns the next unused unique id for categories.

Implemented in XmlDao.

Referenced by Service::get_next_category_id(), and is_verbose().

◆ get_next_item_id()

virtual long KitListDao::get_next_item_id ( )
pure virtual

Returns the next unused unique id for items.

Implemented in XmlDao.

Referenced by Service::get_next_item_id(), and is_verbose().

◆ is_verbose()

int KitListDao::is_verbose ( )
inline

◆ new_category()

virtual long KitListDao::new_category ( const std::string  name)
pure virtual

Creates a new category.

Parameters
namethe name of the new category.

Implemented in XmlDao.

Referenced by is_verbose().

◆ remove_item_from_category()

virtual void KitListDao::remove_item_from_category ( long  id,
long  cat_id 
)
pure virtual

Un-associates the specified item from the specified category.

Parameters
idThe Item id.
cat_idThe Category id.

Implemented in XmlDao.

Referenced by is_verbose().

◆ require_filename()

virtual bool KitListDao::require_filename ( )
inlinevirtual

Indicates whether the implementation of the data model requires a filename.

Some persistence models may require a filename to be chosen, others (e.g. database) may be defined through another mechanism. If a filename has not been set, then fire up save-as instead.

Returns
Always returns false.

Reimplemented in XmlDao.

Definition at line 225 of file kitlistdao.hpp.

Referenced by Service::require_filename().

◆ save_model()

virtual void KitListDao::save_model ( KitModel model)
pure virtual

Saves the current data model.

Note: The data model will only be saved if it is dirty. Further, only items that are individually flagged as dirty will be saved.

See also
GuiState

Implemented in XmlDao.

Referenced by Service::save(), and ~KitListDao().

◆ set_all_flags()

virtual void KitListDao::set_all_flags ( )
pure virtual

Checks/ticks all items.

Implemented in XmlDao.

Referenced by is_verbose().

◆ set_category_flag()

virtual void KitListDao::set_category_flag ( long  id)
pure virtual

Checks/ticks all items in the specified Category.

Implemented in XmlDao.

Referenced by is_verbose().

◆ set_item_flag()

virtual void KitListDao::set_item_flag ( long  id)
pure virtual

Sets the checked flag for an item.

Parameters
idThe id of the item to change.

Implemented in XmlDao.

Referenced by is_verbose().

◆ set_verbose()

void KitListDao::set_verbose ( int  verbose_flag)
inline

Indicates whether verbose output should be written to STDOUT.

Definition at line 85 of file kitlistdao.hpp.

References verbose_flag.

◆ unset_all_flags()

virtual void KitListDao::unset_all_flags ( )
pure virtual

Unchecks/unticks all items.

Implemented in XmlDao.

Referenced by is_verbose().

◆ unset_category_flag()

virtual void KitListDao::unset_category_flag ( long  id)
pure virtual

Unchecks/unticks all items in the specified Category.

Implemented in XmlDao.

Referenced by is_verbose().

◆ unset_item_flag()

virtual void KitListDao::unset_item_flag ( long  id)
pure virtual

Clears the checked flag for an item.

Implemented in XmlDao.

Referenced by is_verbose().

◆ update_item_checked_state()

virtual void KitListDao::update_item_checked_state ( ItemContainer items)
pure virtual

Persists the state of the 'checked' flag of each item.

Implemented in XmlDao.

Referenced by is_verbose().

Member Data Documentation

◆ m_verbose_flag

int KitListDao::m_verbose_flag
protected

Optional parameter indicating whether to include verbose output to STDOUT. Defaults to false.

Definition at line 50 of file kitlistdao.hpp.

Referenced by is_verbose().


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

Copyright 2008-2021 Frank Dean