Salome HOME
PAL10125 - by double click on reference original object becomes selected
[modules/gui.git] / src / SUIT / SUIT_Session.h
1 #ifndef SUIT_SESSION_H
2 #define SUIT_SESSION_H
3
4 #include "SUIT.h"
5
6 #include "SUIT_Application.h"
7 #include "SUIT_ResourceMgr.h"
8
9 #include <qobject.h>
10 #include <qptrlist.h>
11 #include <qptrvector.h>
12 #include <qstringlist.h>
13
14 #ifdef WIN32
15 #define LIB_HANDLE HINSTANCE
16 #else
17 #define LIB_HANDLE void*
18 #endif
19
20 class SUIT_ResourceMgr;
21 class SUIT_ExceptionHandler;
22
23 #ifdef WNT
24 #pragma warning( disable:4251 )
25 #endif
26 /*!
27   The class Sesssion manages launching of Applications. Application must be returned \n
28   by static function "createApplication" in external library. The Library must be loaded with \n
29   loadLibrary method and after that application can be started.
30 */
31 class SUIT_EXPORT SUIT_Session: public QObject
32 {
33   Q_OBJECT
34
35 public:
36   typedef LIB_HANDLE AppLib;
37
38   enum { ASK = 0, SAVE, DONT_SAVE } CloseMode;
39   enum { FROM_GUI = 0, FROM_CORBA_SESSION } ExitStatus;
40
41 public:
42   SUIT_Session();
43   virtual ~SUIT_Session();
44
45   static SUIT_Session*         session();
46
47   SUIT_Application*            startApplication( const QString&, int = 0, char** = 0 );
48
49   QPtrList<SUIT_Application>   applications() const;
50   SUIT_Application*            activeApplication() const;
51
52   SUIT_ResourceMgr*            resourceMgr() const;
53
54   void                         closeSession( int mode = ASK );
55
56   SUIT_ExceptionHandler*       handler() const;
57
58 signals:
59   void                         applicationClosed( SUIT_Application* );
60
61 protected:
62   virtual SUIT_ResourceMgr*    createResourceMgr( const QString& ) const;
63
64 private slots:
65   void                         onApplicationClosed( SUIT_Application* );
66   void                         onApplicationActivated( SUIT_Application* ); 
67
68 private:
69   typedef QPtrList<SUIT_Application>         AppList;
70   typedef QMap<QString, AppLib>              AppLibMap;
71   typedef QPtrListIterator<SUIT_Application> AppListIterator;
72
73 private:
74   QString                      lastError() const;
75   AppLib                       loadLibrary( const QString& );
76   QString                      applicationName( const QString& ) const;
77
78 private:
79   SUIT_ResourceMgr*            myResMgr;
80   AppList                      myAppList;
81   AppLibMap                    myAppLibs;
82   SUIT_Application*            myActiveApp;
83
84   SUIT_ExceptionHandler*       myHandler;
85   static SUIT_Session*         mySession;
86
87   int                          myExitStatus;
88 };
89
90 #endif