]> SALOME platform Git repositories - modules/gui.git/blob - src/Session/InquireServersQThread.h
Salome HOME
Bugs with warnings (unexpected NULL receiver) are fixed.
[modules/gui.git] / src / Session / InquireServersQThread.h
1 //  Copyright (C) 2003  CEA/DEN, EDF R&D
2 //
3 //
4 //
5 //  File   : InquireServersQThread.h
6 //  Author : Vasily RUSYAEV
7 //  Module : SALOME
8 //  $Header$
9
10 #include <qthread.h> 
11 #include <qvbox.h> 
12 #include <qprogressbar.h> 
13 #include <qlabel.h> 
14 #include <qguardedptr.h> 
15
16 /**********************************************************
17 **  Class:   InquireEvent
18 **  Descr:   Contains QCustomEvents for posting to InquireServersQThread
19 **  Level:   Private
20 ***********************************************************/
21
22 class InquireEvent : public QCustomEvent
23 {
24 public:
25
26   enum myCustomEvents{ ProgressEvent = QEvent::User + 10, ProgressEventLabel, ProgressEventError };
27   
28   InquireEvent( QEvent::Type type , void* data = 0 )
29         : QCustomEvent( type, data ) {}
30   ~InquireEvent() 
31       {
32         type() == (QEvent::Type)ProgressEvent ?
33           delete ( int* )data() : delete ( QString* )data();
34       }
35 };
36
37 class InquireServersGUI;
38
39 class InquireServersQThread : public QThread
40 {
41 public:
42   InquireServersQThread( InquireServersGUI* r );
43   virtual ~InquireServersQThread();
44
45   //the main loop of this thread
46   virtual void run() ;
47   //stop to ask servers
48   void stop() 
49     {
50       IsChecking = false;
51       myExitStatus = 1;
52     }
53   //return exit status: 0 - OK, >0 - BAD (some servers doesn't exists or user click cancel button) 
54   int getExitStatus() { return myExitStatus;}
55   //return count of inquired servers
56   int getInquiredServers() { return myServersCount; }
57
58 private:
59
60 //functions:
61
62   bool AskServer(int iteration, QString ** message);
63   bool pingServer(int iteration, QString& errMessage);
64
65 //variables:
66
67   QGuardedPtr<InquireServersGUI> receiver;
68   int _argc ;
69   char ** _argv;
70   //this variable is true if we are checking servers
71   bool IsChecking;
72   //count of inquired servers
73   int myServersCount;
74   //how many times we should repeat attempt to get response from all needed for launching SALOME servers
75   int myRepeat;
76   //define delay time between two attempts in microseconds
77   int myDelay;
78   //this strings' array contains messages for each server (e.g. "Loading: SALOMEDS_Server") 
79   QString myMessages[8];
80   //exit status: 0 - OK, >0 - BAD (some servers doesn't exists or user click cancel button) 
81   int myExitStatus;
82
83 } ;
84
85 class InquireServersGUI : public QVBox
86 {
87     Q_OBJECT
88
89 public:
90   InquireServersGUI() ;
91   ~InquireServersGUI();
92
93   //returns arguments of QApplication
94   //they are needed for CORBA servers initialization
95   void getArgs(  int& _argc, char *** _argv);
96   //return exit status: 0 - OK, >0 - BAD (some servers doesn't exists or user click cancel button) 
97   int getExitStatus();
98   //launch IAPP
99   //  bool withGUI() { return myGUI; }
100   //  void withGUI(bool gui) { myGUI = gui; }
101
102   void setPixmap( QPixmap );
103
104 protected:
105   virtual void customEvent( QCustomEvent* ); 
106   virtual void closeEvent ( QCloseEvent * );
107
108 private:
109   InquireServersQThread* myThread;
110   QProgressBar* myPrgBar;
111   //this string contains description of currently asked server
112   QLabel* myLabel;
113   QLabel* mySplash;
114   //  bool myGUI;
115
116 private slots:
117
118     void ClickOnCancel();
119 } ;