Kitlist  1.1.0
kitlistdao.hpp
Go to the documentation of this file.
1 /*
2 
3  This file is part of Kitlist, a program to maintain a simple list
4  of items and assign items to one or more categories.
5 
6  Copyright (C) 2008,2009 Frank Dean
7 
8  Kitlist is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  Kitlist is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with Kitlist. If not, see <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #ifndef KIT_LIST_DAO_H
24 #define KIT_LIST_DAO_H 1
25 
26 #include "category.hpp"
27 #include "item.hpp"
28 #include "kitmodel.hpp"
29 #include <string>
30 
31 
40 
41 
46 class KitListDao {
47 protected :
51 public :
59  KitListDao(int verbose = 0) : m_verbose_flag(verbose) {}
60 
61  virtual ~KitListDao() {}
62 
70  virtual KitModel* get_model() = 0;
71 
80  virtual void save_model(KitModel* model) = 0;
81 
86  m_verbose_flag = verbose_flag;
87  }
88 
92  int is_verbose() { return m_verbose_flag; };
93 
99  virtual Category* get_category(long cat_id, item_choice choice = ALL_ITEMS) = 0;
100 
106  virtual ItemContainer* get_all_items(item_choice choice = ALL_ITEMS) = 0;
107 
112  virtual long add_item(const std::string name) = 0;
113 
118  virtual long add_item(const std::string name, long cat_id) = 0;
119 
128  virtual void append_items_to_category(long to_cat_id, long from_cat_id = -1, item_choice choice = ALL_ITEMS) = 0;
129 
136  virtual void associate_item_with_category(long id, long cat_id) = 0;
137 
141  virtual CategoryContainer get_categories() = 0;
142 
147  virtual long new_category(const std::string name) = 0;
148 
153  virtual void delete_item(long id) = 0;
154 
158  virtual void update_item_checked_state(ItemContainer& items) = 0;
159 
166  virtual void remove_item_from_category(long id, long cat_id) = 0;
167 
171  virtual long get_next_item_id() = 0;
172 
176  virtual long get_next_category_id() = 0;
177 
181  virtual void delete_category(long id) = 0;
182 
187  virtual void set_item_flag(long id) = 0;
188 
192  virtual void unset_item_flag(long id) = 0;
193 
197  virtual void set_category_flag(long id) = 0;
198 
202  virtual void unset_category_flag(long id) = 0;
203 
207  virtual void set_all_flags() = 0;
208 
212  virtual void unset_all_flags() = 0;
213 
225  virtual bool require_filename() { return false; }
226 };
227 #endif //KIT_LIST_DAO_H
virtual void save_model(KitModel *model)=0
Saves the current data model.
virtual CategoryContainer get_categories()=0
virtual long get_next_category_id()=0
void set_verbose(int verbose_flag)
Definition: kitlistdao.hpp:85
virtual ~KitListDao()
Definition: kitlistdao.hpp:61
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.
virtual void unset_item_flag(long id)=0
std::vector< Item * > ItemContainer
Definition: item.hpp:91
virtual void delete_category(long id)=0
virtual void set_category_flag(long id)=0
virtual bool require_filename()
Indicates whether the implementation of the data model requires a filename.
Definition: kitlistdao.hpp:225
virtual KitModel * get_model()=0
Loads the data model.
int m_verbose_flag
Definition: kitlistdao.hpp:50
virtual long get_next_item_id()=0
Defines the methods that an implementation of this class must implement.
Definition: kitlistdao.hpp:46
virtual void set_all_flags()=0
virtual Category * get_category(long cat_id, item_choice choice=ALL_ITEMS)=0
Loads a category.
virtual void update_item_checked_state(ItemContainer &items)=0
Persists the state of the &#39;checked&#39; flag of each item.
virtual void associate_item_with_category(long id, long cat_id)=0
Associates an existing item with an existing category.
virtual void delete_item(long id)=0
virtual void set_item_flag(long id)=0
static int verbose_flag
Flag set by `–verbose&#39;.
Definition: main.cpp:66
KitListDao(int verbose=0)
Constructor which will use default database connection parameters.
Definition: kitlistdao.hpp:59
Represents a Category.
Definition: category.hpp:37
virtual void remove_item_from_category(long id, long cat_id)=0
Holds a rich graph of objects representing the application&#39;s data model.
Definition: kitmodel.hpp:135
virtual long new_category(const std::string name)=0
Creates a new category.
virtual ItemContainer * get_all_items(item_choice choice=ALL_ITEMS)=0
Returns a list of all items.
virtual void unset_category_flag(long id)=0
std::vector< Category * > CategoryContainer
Definition: category.hpp:84
virtual long add_item(const std::string name)=0
item_choice
Definition: kitlistdao.hpp:36
int is_verbose()
Definition: kitlistdao.hpp:92
virtual void unset_all_flags()=0

Copyright 2008-2021 Frank Dean