Version: 9.12.0
SUIT_Session.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library 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 GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 
23 #ifndef SUIT_SESSION_H
24 #define SUIT_SESSION_H
25 
26 #include "SUIT.h"
27 #include "SUIT_Application.h"
28 
29 #include <QList>
30 #include <QObject>
31 #include <QString>
32 #include <QStringList>
33 
34 #ifdef WIN32
35 #include <windows.h>
36 #endif
37 
38 #ifdef WIN32
39 #define LIB_HANDLE HINSTANCE
40 #else
41 #define LIB_HANDLE void*
42 #endif
43 
44 class SUIT_ResourceMgr;
46 
47 #ifdef WIN32
48 #pragma warning( disable:4251 )
49 #endif
56 {
57  Q_OBJECT
58 
59 public:
60  typedef LIB_HANDLE AppLib;
61 
62  enum { ASK = 0, SAVE, DONT_SAVE } CloseMode;
63  enum { NORMAL = 0, FORCED } ExitStatus;
64 
65 public:
66  SUIT_Session();
67  virtual ~SUIT_Session();
68 
69  static SUIT_Session* session();
70 
71  SUIT_Application* startApplication( const QString&, int = 0, char** = 0 );
72 
73  QList<SUIT_Application*> applications() const;
74  SUIT_Application* activeApplication() const;
75 
76  SUIT_ResourceMgr* resourceMgr() const;
77 
78  void closeSession( int mode = ASK, int flags = 0 );
79  int exitFlags() const;
80 
81  SUIT_ExceptionHandler* handler() const;
82 
83  void insertApplication( SUIT_Application* );
84 
85 signals:
87 
88 protected:
89  virtual SUIT_ResourceMgr* createResourceMgr( const QString& ) const;
90 
91 private slots:
92  void onApplicationClosed( SUIT_Application* );
93  void onApplicationActivated( SUIT_Application* );
94 
95 private:
97  typedef QMap<QString, AppLib> AppLibMap;
98 
99 private:
100  QString lastError() const;
101  AppLib loadLibrary( const QString&, QString& );
102  QString applicationName( const QString& ) const;
103 
104 private:
109 
112 
115 };
116 
117 #endif
#define SUIT_EXPORT
Definition: SUIT.h:36
#define LIB_HANDLE
Definition: SUIT_Session.h:41
For more information see QT documentation.
Definition: SUIT_Application.h:42
Definition: SUIT_Application.h:61
Definition: SUIT_ExceptionHandler.h:37
Definition: SUIT_ResourceMgr.h:31
Definition: SUIT_Session.h:56
AppList myAppList
Definition: SUIT_Session.h:106
SUIT_ExceptionHandler * myHandler
Definition: SUIT_Session.h:110
void * AppLib
Definition: SUIT_Session.h:60
SUIT_ResourceMgr * myResMgr
Definition: SUIT_Session.h:105
void applicationClosed(SUIT_Application *)
AppLibMap myAppLibs
Definition: SUIT_Session.h:107
QMap< QString, AppLib > AppLibMap
Definition: SUIT_Session.h:97
static SUIT_Session * mySession
Definition: SUIT_Session.h:111
int myExitFlags
Definition: SUIT_Session.h:114
SUIT_Application * myActiveApp
Definition: SUIT_Session.h:108
int myExitStatus
Definition: SUIT_Session.h:113
QList< SUIT_Application * > AppList
Definition: SUIT_Session.h:96