interface_console.hpp 5.38 KB
Newer Older
1
/*!
2
 *\file interface_console.hpp
3 4
 */

5 6
#ifndef INTERFACE_CONSOLE_HPP
#define INTERFACE_CONSOLE_HPP
7 8


9 10
class Interface_console;

11 12 13 14 15 16 17
#include <QApplication>
#include "interface.hpp"
#include "interface_graphic.hpp"
#include "render_area.hpp"

#include "../../trace/src/Trace.hpp"
#include "../../trace/src/DrawTrace.hpp"
18

19
#include "../../parser/src/ParserPaje.hpp"
20

21
#include "resource.hpp"
22

23 24


25
/*!
26
 *\brief This class is an terminal interface, it inherited from the Interface interface.
27
*/
28
class Interface_console : public Interface{
29

30

31

32
protected:
33

34 35 36 37 38 39 40


    /***********************************
     *
     * Window interface instance.
     *
     **********************************/
41 42

    /*!
43
     * \brief Contains the instance of the window class.
44 45 46
     */
    Interface_graphic* _main_window;

47 48
    Render_area* _render_opengl;

49
    QApplication* app;
50 51 52 53 54 55 56


    /***********************************
     *
     * The command line parameter processing functions.
     *
     **********************************/
57
  
58 59 60
    /*!
     *\brief An error state.
     */
61
    static const int _STATE_UNKNOWN = -1;
62 63 64 65
    
    /*!
     *\brief A state which corresponds to display a help text.
     */
66
    static const int _STATE_DISPLAY_HELP = 0;
67 68 69 70

    /*!
     *\brief A state which corresponds to display the ViTE window.
     */
71
    static const int _STATE_LAUNCH_GRAPHICAL_INTERFACE = 1;
72

73 74 75
    /*!
     *\brief A state which corresponds to display a the ViTE window and opening a file.
     */
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
    static const int _STATE_OPEN_FILE = 2;

    /*!
     *\brief A state which corresponds to display the trace within a time.
     */
    static const int _STATE_OPEN_FILE_IN_AN_INTERVAL = 3;

    /*!
     *\brief A state which corresponds to an export of file.
     */
    static const int _STATE_EXPORT_FILE = 4;

    /*!
     *\brief A state which corresponds to an export of file.
     */
    static const int _STATE_EXPORT_FILE_IN_INTERVAL = 5;
92 93 94 95 96 97

    /*!
     *\brief If a file must be opened, this attributes contains its path.
     */
    char* _file_opened;

98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114

    /*!
     *\brief If a file must be exported, this attributes contains its path.
     */
    char* _path_to_export;

    /*!
     *\brief The time where we start to watch the trace.
     */
    int _time_start;

    /*!
     *\brief The time where we stop to watch the trace.
     */
    int _time_end;


115 116
    /*!
     * \brief Return the state of ViTE according to the arguments.
117 118 119
     * \arg argc : the number of parameters given when the program was called.
     * \arg argv : a set of strings which contains each parameter.
     * \return an integer corresponding to a command which will be processed by ViTE.
120
     */
121
    int get_state(int argc, char** argv);
122 123 124 125 126 127 128
    

    /*!
     * \brief Extracts the times of start and end in the string.
     * \arg name : the string where we extract times.
     */
    void extract_times(const char *name);
129 130 131


    /*!
132 133 134 135 136 137 138 139 140 141
     * \brief Launch an action according to the argument state value.
     * \arg state : an integer corresponding to a kind of action which must be executed.
     *
     * This functions triggers an action of ViTE according to its argument. state can takes some values :
     * <ul><li><b>STATE_DISPLAY_HELP</b> -> this value means that the console interface must be displayed
     * in the terminal the help text, then wait until user specify an other command.</li>
     * <li><b>STATE_LAUNCH_GRAPHICAL_INTERFACE</b> -> this value means that the console interface will let
     * user to use the graphical interface: in that case, ViTE displays the window and all
     * of the warning or error messages will be displayed in dialog boxes.</li>
     * </ul>
142
     */
143
    void launch_action(int state);
144 145

    
146 147 148
    /*!
     * \brief Displays in the terminal the help text.
     */
149 150 151 152
    void display_help();



153 154
 public:

155 156 157 158 159 160 161 162 163



    /***********************************
     *
     * Constructor and destructor.
     *
     **********************************/

164
    /*!
165 166 167
     * \brief The default constructor of the class.
     * \arg argc : the number of parameters given when the program was called.
     *      argv : a set of strings which contains each parameter.
168
     */
169 170
    Interface_console(int argc, char** argv);
    
171
    /*!
172
     * \brief The destructor.
173 174 175 176
     */
    ~Interface_console();


177

178 179 180 181 182 183
    /***********************************
     *
     * Running function.
     *
     **********************************/

184 185 186 187 188 189 190
    /*!
     * \brief This function launch trace drawing.
     * \param filename Path of the trace file.
     */
    bool draw_trace(const std::string & filename, Render_area* render_area);


191 192 193 194 195 196 197
    /*!
     * \brief This function launch Qt event loop.
     */
    int run();



198 199 200 201 202 203
    /***********************************
     *
     * Informative message functions.
     *
     **********************************/
    
204 205 206 207
    /*!
      \arg string : the string to be displayed.
      \brief The function takes a string then displayed it into the terminal, then killed the application.
     */
208
    void error(const std::string) const;
209 210 211 212

    
    /*!
      \arg string : the string to be displayed.
213
      \brief The function takes a string then displayed it into the terminal, then the program go on with an indeterminated behaviour.
214
    */
215
    void warning(const std::string) const;
216

217 218 219 220 221
 
    /*!
      \arg string : the string to be displayed.
      \brief The function takes a strings then displayed it into the terminal, then the program go on.
    */
222
    void information(const std::string) const;
223 224


225 226 227 228
};


#endif