Kitlist  1.1.0
kitlistpgsqldao.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_PGSQL_DAO_H
24 #define KIT_LIST_PGSQL_DAO_H 1
25 
26 #include <config.h>
27 #ifdef HAVE_LIBPQXX
28 
29 #include <pqxx/pqxx>
30 #include "kitlistdao.hpp"
31 #include "kitmodel.hpp"
32 
37 class KitListPgsqlDao : public KitListDao {
38  pqxx::connection* m_db_connection;
39  void connect();
40  std::string generate_uuid();
41 protected:
42  std::string m_dbname;
43  std::string m_user;
44  std::string m_port;
45 public :
46  KitListPgsqlDao(int verbose = 0);
47 
61  KitListPgsqlDao(const std::string dbname, int verbose = 0);
62 
78  KitListPgsqlDao(const std::string dbname, const std::string user, const std::string port, int verbose = 0);
79 
80  ~KitListPgsqlDao();
81 
83 
84  void save_model(KitModel* model);
85 
86  Category* get_category(long cat_id, item_choice choice);
87 
89 
90  long add_item(const std::string name);
91 
92  long add_item(const std::string name, long cat_id);
93 
94  void append_items_to_category(long to_cat_id, long from_cat_id, item_choice choice);
95 
96  void associate_item_with_category(long id, long cat_id);
97 
99 
100  long new_category(const std::string name);
101 
102  void delete_item(long id);
103 
105 
106  void remove_item_from_category(long id, long cat_id);
107 
108  long get_next_item_id();
109 
110  long get_next_category_id();
111 
112  void delete_category(long id);
113 
114  void set_item_flag(long id);
115 
116  void unset_item_flag(long id);
117 
118  void set_category_flag(long id);
119 
120  void unset_category_flag(long id);
121 
122  void set_all_flags();
123 
124  void unset_all_flags();
125 
126 };
127 #endif //HAVE_LIBPQXX
128 #endif //KIT_LIST_PGSQL_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
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 KitModel * get_model()=0
Loads the data model.
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
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
virtual void unset_all_flags()=0

Copyright 2008-2021 Frank Dean