Privacy
An open-source, flexible 3D physical simulation framework
MyApp.h
Go to the documentation of this file.
1 /*
2  * Copyright 2012, DFKI GmbH Robotics Innovation Center
3  *
4  * This file is part of the MARS simulation framework.
5  *
6  * MARS is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License
8  * as published by the Free Software Foundation, either version 3
9  * of the License, or (at your option) any later version.
10  *
11  * MARS is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with MARS. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
27 #ifndef MY_APP_H
28 #define MY_APP_H
29 
30 #ifndef NO_GUI
31 #include <QApplication>
32 #else
33 #include <stdlib.h>
34 #endif
35 
36 namespace mars {
37 
38  namespace app {
39 
45 #ifdef NO_GUI
46  class MyApp {
47  public:
48  MyApp(int &argc, char **argv) {}
49  int exec() {
50  abort();
51  return 0;
52  }
53  void processEvents() {
54  abort();
55  }
56  };
57 #else
58  class MyApp : public QApplication {
59  public:
60  MyApp(int &argc, char **argv) : QApplication(argc, argv) {}
61  virtual bool notify( QObject *receiver, QEvent *event ) {
62  try {
63  return QApplication::notify(receiver, event);
64  } catch (const std::exception &e) {
65  std::cerr << e.what() << std::endl;
66  throw(e);
67  }
68  }
69  };
70 #endif
71 
72  } // end of namespace app
73 } // end of namespace mars
74 
75 #endif // end of namespace MARS_H
This function provides a clean exit of the simulation in case of a kill-signal.
Definition: MyApp.h:58
Copyright 2012, DFKI GmbH Robotics Innovation Center.
MyApp(int &argc, char **argv)
Definition: MyApp.h:60
virtual bool notify(QObject *receiver, QEvent *event)
Definition: MyApp.h:61