File indexing completed on 2024-04-28 16:08:34

0001 /***************************************************************************
0002  *   Copyright (C) 2005-2008 by Bjoern Erik Nilsen & Fredrik Berg Kjoelstad*
0003  *   bjoern.nilsen@bjoernen.com & fredrikbk@hotmail.com                    *
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 NONGUI_H
0021 #define NONGUI_H
0022 
0023 #include <string>
0024 
0025 #include "src/config.h"
0026 #include "src/presentation/frontends/frontend.h"
0027 
0028 class DomainFacade;
0029 class UiException;
0030 
0031 /**
0032  * Frontend for using the program through command line options.
0033  * 
0034  * @author Bjoern Erik Nilsen & Fredrik Berg Kjoelstad
0035  */
0036 class NonGUIFrontend : public Frontend
0037 {
0038 public:
0039     /**
0040      * Constructs and initializes the object.
0041      * @param facadePtr pointer to the domain facade
0042      */
0043     NonGUIFrontend(DomainFacade *facadePtr);
0044     virtual ~NonGUIFrontend();
0045     
0046     /**
0047      * The run function for starting the application.
0048      * @param argc the argc argument from the environment through main.
0049      * @param argv the argv arguments from the environment through main.
0050      * @return the return status on exit
0051      */
0052     int run(int argc, char **argv);
0053     
0054     void showProgress(ProgressMessage message, int numOperations);
0055     void hideProgress();
0056     void updateProgress(int numOperationsDone);
0057     void setProgressInfo(const char *infoText);
0058     bool isOperationAborted();
0059     
0060     /**
0061      * Function for processing events. This is useful on timeconsuming
0062      * operations which aren't running in separate processes or threads.
0063      * This function is actually not needed in this frontend.
0064      */
0065     void processEvents();
0066     bool askQuestion(Question question);
0067     int runExternalCommand(const char *command);
0068     void reportWarning(const char *message);
0069     void handleException(UiException&);
0070     
0071 private:
0072     DomainFacade *facadePtr;
0073     
0074     int parseArguments(int argc, char **argv);
0075     void addFrames(const char *directory);
0076     void save(const char *directory);
0077     /**
0078      * Sets {@a out} to be the absolute path of {@a path}, always with a
0079      * trailing backslash.
0080      * @param[out] out Receives the path returned.
0081      * @param[in] path The path to make absolute.
0082      */
0083     void getAbsolutePath(std::string& out, const char *path);
0084     int checkFiles(const char *directory);
0085 };
0086 
0087 #endif