]> SALOME platform Git repositories - modules/visu.git/blob - src/VISU_I/VISUConfig.hh
Salome HOME
NRI : First integration.
[modules/visu.git] / src / VISU_I / VISUConfig.hh
1 // File:        VISU_Common.hh
2 // Created:     Tue Dec 24 17:13:35 2002
3 // Author:      Alexey PETROV
4 //              <apo@ivanox.nnov.matra-dtv.fr>
5
6 #ifndef __VISU_CONFIG_H__
7 #define __VISU_CONFIG_H__
8
9 // standard C++ headers
10 #include <stdio.h>
11 #include <iostream.h>
12 #include <string>
13 #include <qstring.h> 
14 #include <qthread.h> 
15 #include <qfileinfo.h>
16 #include <qapplication.h>
17
18 using namespace std;
19  
20 // IDL headers
21 #include <SALOMEconfig.h>
22 #include CORBA_SERVER_HEADER(VISU_Gen)
23 #include CORBA_SERVER_HEADER(MED)
24 #include CORBA_SERVER_HEADER(SALOMEDS)
25 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
26 #include "SALOME_NamingService.hxx"
27 #include "SALOME_LifeCycleCORBA.hxx"
28 #include "Utils_CorbaException.hxx"
29 #include "utilities.h"
30
31 #include <stdexcept>
32 #include <strstream>    
33
34 namespace VISU{
35   //===========================================================================
36   class VISU_Gen_i;
37   class Base_i : public virtual POA_VISU::Base,
38                  public virtual PortableServer::RefCountServantBase
39   {
40   public:
41     virtual ~Base_i();
42     virtual char* GetID();
43     virtual VISU::VISUType GetType()=0;
44   protected:
45     static QMutex* myMutex;
46     static CORBA::ORB_var myOrb;
47     static PortableServer::POA_var myPOA;
48     static SALOME_NamingService* myNamingService;
49     static VISU_Gen_i* myVisuGenImpl;
50     static SALOME_LifeCycleCORBA* myEnginesLifeCycle;
51   public:
52     static CORBA::ORB_ptr GetORB() { return myOrb;}
53     static PortableServer::POA_ptr GetPOA() { return myPOA;}
54     static SALOME_NamingService* GetNS() { return myNamingService;}
55     static SALOME_LifeCycleCORBA* GetLCC() { return myEnginesLifeCycle;}
56     static VISU_Gen_i* GetVisuGenImpl() { return myVisuGenImpl;}
57     static VISU_Gen_var GetVisuGenInter();
58   };
59   //===========================================================================
60   class Mutex{
61     QMutex* myMutex;
62     QApplication* myQApp;
63     int isQAppLocked, isSessionLocked;
64   public:
65     Mutex(QMutex* theMutex, QApplication* theQApp);
66     ~Mutex();
67   };
68   //===========================================================================
69   class Storable : public virtual Base_i {
70   protected:
71     virtual void ToStream(ostrstream& theStr) = 0;
72   public:
73     string ToString();
74     virtual const char* GetComment() const = 0;
75     typedef map<string,QString> TRestoringMap;
76     typedef Storable* (*TStorableEngine)(SALOMEDS::SObject_ptr theSObject, 
77                                          const string& thePrefix, const TRestoringMap& theMap);
78     typedef map<string,TStorableEngine> TCallbackMap;
79     static void Registry(const char* theComment, TStorableEngine theEngine) 
80       throw(std::logic_error&);
81     static Storable* Create(SALOMEDS::SObject_ptr, const string& thePrefix, const string& theString) 
82       throw(std::runtime_error&);
83     static const QString& FindValue(const TRestoringMap& theMap, const string& theArg, bool* isFind = NULL)
84       throw(std::logic_error&);
85     static void StrToMap(const QString& theStr, VISU::Storable::TRestoringMap& theMap);
86     static SALOMEDS::SObject_ptr GetResultSO(SALOMEDS::SObject_ptr theSObject);
87     static void DataToStream(ostrstream& theStr, const QString& theName, const QString& theVal);
88     static void DataToStream(ostrstream& theStr, const QString& theName, const int theVal);
89     static void DataToStream(ostrstream& theStr, const QString& theName, const double theVal);
90   };
91   //===========================================================================
92   const CORBA::Boolean IsMultifile();
93   PortableServer::Servant GetServant(CORBA::Object_ptr theObject);
94   CORBA::Object_var SObjectToObject(SALOMEDS::SObject_ptr theSObject);
95   SALOMEDS::SComponent_var FindOrCreateVisuComponent(SALOMEDS::Study_ptr theStudyDocument);
96   string CreateAttributes(SALOMEDS::Study_ptr theStudyDocument, 
97                           const char* theFatherEntry, const char* theRefFatherEntry,
98                           const char* theIOR, const char* theName, 
99                           const char* thePersistentRef, const char* theComment,
100                           CORBA::Boolean theCreateNew = true);
101   string FindEntryWithComment(SALOMEDS::Study_ptr theStudyDocument, const char* theStartEntry,
102                               const char* theComment, int IsAllLevels = true);
103 }
104
105 #endif