1 /* 2 Copyright (C) 2012 Andrew Caudwell (acaudwell@gmail.com) 3 4 This program is free software; you can redistribute it and/or 5 modify it under the terms of the GNU General Public License 6 as published by the Free Software Foundation; either version 7 3 of the License, or (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License 15 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #ifndef LOGMILL_H 19 #define LOGMILL_H 20 21 #include <boost/filesystem.hpp> 22 23 #include "SDL_thread.h" 24 25 #include "core/sdlapp.h" 26 #include "core/display.h" 27 28 #include "formats/commitlog.h" 29 30 #if defined(HAVE_PTHREAD) && !defined(_WIN32) 31 #include <signal.h> 32 #endif 33 34 enum { 35 LOGMILL_STATE_STARTUP, 36 LOGMILL_STATE_FETCHING, 37 LOGMILL_STATE_SUCCESS, 38 LOGMILL_STATE_FAILURE 39 }; 40 41 class RLogMill { 42 SDL_Thread* thread; 43 SDL_mutex* mutex; 44 SDL_cond* cond; 45 46 int logmill_thread_state; 47 48 std::string logfile; 49 RCommitLog* clog; 50 51 std::string error; 52 53 bool findRepository(boost::filesystem::path& dir, std::string& log_format); 54 RCommitLog* fetchLog(std::string& log_format); 55 public: 56 RLogMill(const std::string& logfile); 57 ~RLogMill(); 58 59 void run(); 60 61 void abort(); 62 63 std::string getError(); 64 65 int getStatus(); 66 bool isFinished(); 67 68 RCommitLog* getLog(); 69 }; 70 71 #endif 72