| 1 | /* -*- c-basic-offset: 2 -*- */ |
| 2 | /* |
| 3 | Copyright(C) 2010 Tetsuro IKEDA |
| 4 | Copyright(C) 2010-2013 Kentoku SHIBA |
| 5 | Copyright(C) 2011-2014 Kouhei Sutou <kou@clear-code.com> |
| 6 | |
| 7 | This library is free software; you can redistribute it and/or |
| 8 | modify it under the terms of the GNU Lesser General Public |
| 9 | License as published by the Free Software Foundation; either |
| 10 | version 2.1 of the License, or (at your option) any later version. |
| 11 | |
| 12 | This library is distributed in the hope that it will be useful, |
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | Lesser General Public License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU Lesser General Public |
| 18 | License along with this library; if not, write to the Free Software |
| 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | */ |
| 21 | |
| 22 | #ifndef MRN_DATABASE_MANAGER_HPP_ |
| 23 | #define MRN_DATABASE_MANAGER_HPP_ |
| 24 | |
| 25 | #include "mrn_database.hpp" |
| 26 | |
| 27 | #include <groonga.h> |
| 28 | |
| 29 | namespace mrn { |
| 30 | class DatabaseManager { |
| 31 | public: |
| 32 | DatabaseManager(grn_ctx *ctx, mysql_mutex_t *mutex); |
| 33 | ~DatabaseManager(void); |
| 34 | bool init(void); |
| 35 | int open(const char *path, Database **db); |
| 36 | void close(const char *path); |
| 37 | bool drop(const char *path); |
| 38 | int clear(void); |
| 39 | const char *error_message(); |
| 40 | |
| 41 | private: |
| 42 | grn_ctx *ctx_; |
| 43 | grn_hash *cache_; |
| 44 | mysql_mutex_t *mutex_; |
| 45 | |
| 46 | void mkdir_p(const char *directory); |
| 47 | void ensure_database_directory(void); |
| 48 | int ensure_normalizers_registered(grn_obj *db); |
| 49 | }; |
| 50 | } |
| 51 | |
| 52 | #endif /* MRN_DATABASE_MANAGER_HPP_ */ |
| 53 | |