00001 /* 00002 00003 This file is part of Kitlist, a program to maintain a simple list 00004 of items and assign items to one or more categories. 00005 00006 Copyright (C) 2008,2009 Frank Dean 00007 00008 Kitlist is free software: you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation, either version 3 of the License, or 00011 (at your option) any later version. 00012 00013 Kitlist is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with Kitlist. If not, see <http://www.gnu.org/licenses/>. 00020 00021 */ 00022 00023 #ifndef KIT_LIST_DAO_H 00024 #define KIT_LIST_DAO_H 1 00025 00026 #include "category.hpp" 00027 #include "item.hpp" 00028 #include "kitmodel.hpp" 00029 #include <string> 00030 00031 00036 enum item_choice { 00037 ALL_ITEMS, 00038 CHECKED_ITEMS, 00039 UNCHECKED_ITEMS }; 00040 00041 00046 class KitListDao { 00047 protected : 00050 int m_verbose_flag; 00051 public : 00059 KitListDao(int verbose = 0) : m_verbose_flag(verbose) {} 00060 00061 virtual ~KitListDao() {} 00062 00070 virtual KitModel* get_model() = 0; 00071 00080 virtual void save_model(KitModel* model) = 0; 00081 00085 void set_verbose(int verbose_flag) { 00086 m_verbose_flag = verbose_flag; 00087 } 00088 00092 int is_verbose() { return m_verbose_flag; }; 00093 00099 virtual Category* get_category(long cat_id, item_choice choice = ALL_ITEMS) = 0; 00100 00106 virtual ItemContainer* get_all_items(item_choice choice = ALL_ITEMS) = 0; 00107 00112 virtual long add_item(const std::string name) = 0; 00113 00118 virtual long add_item(const std::string name, long cat_id) = 0; 00119 00128 virtual void append_items_to_category(long to_cat_id, long from_cat_id = -1, item_choice choice = ALL_ITEMS) = 0; 00129 00136 virtual void associate_item_with_category(long id, long cat_id) = 0; 00137 00141 virtual CategoryContainer get_categories() = 0; 00142 00147 virtual long new_category(const std::string name) = 0; 00148 00153 virtual void delete_item(long id) = 0; 00154 00158 virtual void update_item_checked_state(ItemContainer& items) = 0; 00159 00166 virtual void remove_item_from_category(long id, long cat_id) = 0; 00167 00171 virtual long get_next_item_id() = 0; 00172 00176 virtual long get_next_category_id() = 0; 00177 00181 virtual void delete_category(long id) = 0; 00182 00187 virtual void set_item_flag(long id) = 0; 00188 00192 virtual void unset_item_flag(long id) = 0; 00193 00197 virtual void set_category_flag(long id) = 0; 00198 00202 virtual void unset_category_flag(long id) = 0; 00203 00207 virtual void set_all_flags() = 0; 00208 00212 virtual void unset_all_flags() = 0; 00213 00225 virtual bool require_filename() { return false; } 00226 }; 00227 #endif //KIT_LIST_DAO_H