MEPP2 Project
SimpleApplication.h
Go to the documentation of this file.
1 // Copyright (c) 2012-2019 University of Lyon and CNRS (France).
2 // All rights reserved.
3 //
4 // This file is part of MEPP2; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published
6 // by the Free Software Foundation; either version 3 of the License,
7 // or (at your option) any later version.
8 //
9 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
10 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11 #pragma once
12 
13 #if(FEVV_USE_QT5)
14 #include <QtWidgets/QApplication>
15 #else
16 #include <QtGui/QApplication>
17 #endif
18 
19 #include <iostream>
20 
21 namespace FEVV {
22 
30 class SimpleApplication : public QApplication
31 {
32 public:
36  SimpleApplication(int &_argc, char **_argv) : QApplication(_argc, _argv)
37  {
38 #ifdef DEBUG_VISU2
39  std::cout << "*** this=" << this << " entering " << __func__ << std::endl;
40 #endif
41 
42 #ifdef DEBUG_VISU2
43  std::cout << "*** this=" << this << " leaving " << __func__ << std::endl;
44 #endif
45  }
46 
48  {
49 #ifdef DEBUG_VISU2
50  std::cout << "*** this=" << this << " entering " << __func__ << std::endl;
51 #endif
52 
53 #ifdef DEBUG_VISU2
54  std::cout << "*** this=" << this << " leaving " << __func__ << std::endl;
55 #endif
56  }
57 
58 private:
63  bool notify(QObject *_receiver, QEvent *_event)
64  {
65 #ifdef DEBUG_VISU2
66  std::cout << "*** SimpleApplication notify event type=" << _event->type()
67  << " receiver=" << _receiver << std::endl;
68 #endif
69 
70  try
71  {
72  return QApplication::notify(_receiver, _event);
73  }
74  catch(std::exception &e)
75  {
76  // catch anything thrown within try block that derives from std::exception
77  std::cerr << "std::exception was caught: " << e.what() << std::endl;
78 
79  return false;
80  }
81  }
82 };
83 
84 } // namespace FEVV
FEVV::SimpleApplication
SimpleApplication is a specialization of QApplication. This is useful if we want to catch exception.
Definition: SimpleApplication.h:31
FEVV
Interfaces for plugins These interfaces will be used for different plugins.
Definition: Assert.h:16
FEVV::SimpleApplication::~SimpleApplication
~SimpleApplication()
Definition: SimpleApplication.h:47
FEVV::SimpleApplication::SimpleApplication
SimpleApplication(int &_argc, char **_argv)
Definition: SimpleApplication.h:36
FEVV::SimpleApplication::notify
bool notify(QObject *_receiver, QEvent *_event)
Definition: SimpleApplication.h:63