File indexing completed on 2024-05-12 16:23:35

0001 /***************************************************************************
0002  *   Copyright (C) 2005-2014 by Linuxstopmotion contributors;              *
0003  *   see the AUTHORS file for details.                                     *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  *                                                                         *
0010  *   This program is distributed in the hope that it will be useful,       *
0011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0013  *   GNU General Public License for more details.                          *
0014  *                                                                         *
0015  *   You should have received a copy of the GNU General Public License     *
0016  *   along with this program; if not, write to the                         *
0017  *   Free Software Foundation, Inc.,                                       *
0018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
0019  ***************************************************************************/
0020 #ifndef FRONTEND_H
0021 #define FRONTEND_H
0022 
0023 #include <exception>
0024 
0025 class UiException;
0026 
0027 /**
0028  * The frontend interface to be used by the implemented frontend.
0029  *
0030  * @author Bjoern Erik Nilsen & Fredrik Berg Kjoelstad
0031 */
0032 class Frontend {
0033 public:
0034     enum ProgressMessage {
0035         connectingCamera,
0036         importingFramesFromDisk,
0037         exporting,
0038         restoringProject,
0039         savingScenesToDisk
0040     };
0041     enum Question {
0042         useNewerPreferences
0043     };
0044 
0045     virtual ~Frontend();
0046     
0047     /**
0048      * Abstract function for starting the application through the frontend.
0049      * @param argc the argc argument from the environment through main.
0050      * @param argv the argv arguments from the environment through main.
0051      * @return the return status on exit
0052      */
0053     virtual int run(int argc, char **argv) = 0;
0054     
0055     /**
0056      * Abstract function for displaying progress on timeconsuming operations.
0057      * @param message Indicates the message to display to the user.
0058      * @param numOperations The number of calculated operations to do.
0059      */
0060     virtual void showProgress(ProgressMessage message, int numOperations = 0) = 0;
0061     
0062     /**
0063      * Abstract function for hiding the progress info.
0064      */
0065     virtual void hideProgress() = 0;
0066     
0067     /**
0068      * Abstract function for updating the progress.
0069      * @param numOperationsDone the number of operations done
0070      */
0071     virtual void updateProgress(int numOperationsDone) = 0;
0072     
0073     /**
0074      * Abstract function for checking if the user has aborted the operation 
0075      * (eg pressed cancel)
0076      * @return true if the the operation is aborted, false otherwise
0077      */
0078     virtual bool isOperationAborted() = 0;
0079     
0080     /**
0081      * Abstract function for processing GUI events. This is useful on timeconsuming
0082      * operations which aren't running in separate processes or threads.
0083      */
0084     virtual void processEvents() = 0;
0085 
0086     /**
0087      * Displays an error to the user. This sort of error does not crash the program.
0088      */
0089     virtual void reportWarning(const char *message) = 0;
0090 
0091     /**
0092      * Displays an error to the user, ending the program if it is serious enough.
0093      */
0094     virtual void handleException(UiException&) = 0;
0095 
0096     /**
0097      * Abstract function for asking the user a yes/no question.
0098      * @param question The question to ask
0099      * @return true if the user answer yes, false if no
0100      */
0101     virtual bool askQuestion(Question question) = 0;
0102 
0103     virtual int runExternalCommand(const char *command) = 0;
0104 
0105     class CriticalError : public std::exception {
0106     public:
0107         CriticalError();
0108         ~CriticalError() throw();
0109         const char* what() const throw();
0110     };
0111 };
0112 
0113 #endif