source: pacpusframework/branches/0.1.x/src/PacpusLib/PacpusApplication.cpp

Last change on this file was 165, checked in by Marek Kurdej, 11 years ago

Major: changed plugins section name to plugings. Parameters section will be used for something else.

  • Property svn:executable set to *
File size: 3.5 KB
Line 
1// %pacpus:license{
2// This file is part of the PACPUS framework distributed under the
3// CECILL-C License, Version 1.0.
4// %pacpus:license}
5/// @file
6/// @author Marek Kurdej <firstname.surname@utc.fr>
7/// @date March, 2013
8/// @version $Id$
9/// @copyright Copyright (c) UTC/CNRS Heudiasyc 2006 - 2013. All rights reserved.
10
11#include <csignal>
12#include <Pacpus/kernel/Log.h>
13#include <Pacpus/kernel/PacpusApplication.h>
14#include <Pacpus/kernel/PacpusException.h>
15#include <sstream>
16#include <string>
17
18using namespace pacpus;
19
20DECLARE_STATIC_LOGGER("pacpus.core.PacpusApplication");
21
22PacpusApplication::PacpusApplication(int & argc, char ** argv
23#ifndef Q_QDOC
24 , int _internal
25#endif
26 )
27 : QApplication(argc, argv, _internal)
28{
29 //installSignalHandler();
30}
31
32//PacpusApplication::PacpusApplication(int & argc, char ** argv, bool GUIenabled
33//#ifndef Q_QDOC
34// , int _internal
35//#endif
36// )
37// : QApplication(argc, argv, GUIenabled, _internal)
38//{
39//}
40
41//PacpusApplication::PacpusApplication(int & argc, char ** argv, Type type
42//#ifndef Q_QDOC
43// , int _internal
44//#endif
45// )
46// : QApplication(argc, argv, type, _internal)
47//{
48//}
49
50#if defined(Q_WS_X11)
51PacpusApplication::PacpusApplication(Display * display, Qt::HANDLE visual, Qt::HANDLE colormap
52#ifndef Q_QDOC
53 , int _internal
54#endif
55 )
56 : QApplication(display, visual, colormap, _internal)
57{
58}
59
60PacpusApplication::PacpusApplication(Display * display, int & argc, char ** argv, Qt::HANDLE visual , Qt::HANDLE colormap
61#ifndef Q_QDOC
62 , int _internal
63#endif
64 )
65 : QApplication(display, argc, argv, visual, colormap, _internal)
66{
67}
68#endif
69
70#if defined(Q_OS_SYMBIAN)
71PacpusApplication::PacpusApplication(QApplication::QS60MainApplicationFactory factory, int & argc, char ** argv
72#ifndef Q_QDOC
73 , int _internal
74#endif
75 )
76 : QApplication(factory, argc, argv, _internal)
77{
78}
79#endif
80
81PacpusApplication::~PacpusApplication()
82{
83}
84
85bool PacpusApplication::notify(QObject * receiver, QEvent * ev)
86{
87 try {
88 return QApplication::notify(receiver, ev);
89 } catch(PacpusException & e) {
90 (void) e; // unused
91 LOG_ERROR("PacpusException thrown:" << e.what());
92 } catch(std::exception & e) {
93 (void) e; // unused
94 LOG_ERROR("std::exception thrown:" << e.what());
95 }
96 return false;
97}
98
99void signalHandler(int signal);
100
101void PacpusApplication::installSignalHandler()
102{
103 LOG_INFO("installing signal handler...");
104
105 typedef void (*SignalHandlerType)(int);
106
107 //std::signal(SIGABRT, &signalHandler);
108 //std::signal(SIGFPE, &signalHandler);
109 //std::signal(SIGILL, &signalHandler);
110 std::signal(SIGINT, &signalHandler); // interrupt (CTRL-C)
111 //std::signal(SIGSEGV, &signalHandler);
112 //std::signal(SIGTERM, &signalHandler);
113
114 LOG_INFO("successfully installed signal handler");
115}
116
117void signalHandler(int signal)
118{
119 LOG_FATAL("signal received: sig = " << signal);
120 std::stringstream errorMessage;
121 errorMessage << "received signal number " << signal;
122 throw PacpusException(errorMessage.str());
123}
Note: See TracBrowser for help on using the repository browser.