Salome HOME
NRI : Correction 1.1a version.
[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 "Utils_CorbaException.hxx"
27 #include "utilities.h"
28
29 #include <stdexcept>
30 #include <strstream>    
31
32 namespace VISU{
33   //===========================================================================
34   class Base_i : public virtual POA_VISU::Base,
35                  public virtual PortableServer::RefCountServantBase
36   {
37   public:
38     virtual ~Base_i();
39     virtual char* GetID();
40     virtual VISU::VISUType GetType()=0;
41   protected:
42     static QMutex* myMutex;
43     static CORBA::ORB_var myOrb;
44     static PortableServer::POA_var myPOA;
45   };
46   //===========================================================================
47   class Mutex{
48     QMutex* myMutex;
49     QApplication* myQApp;
50     int isQAppLocked, isSessionLocked;
51   public:
52     Mutex(QMutex* theMutex, QApplication* theQApp);
53     ~Mutex();
54   };
55   //===========================================================================
56   class Storable : public virtual Base_i {
57   protected:
58     virtual void ToStream(ostrstream& theStr) = 0;
59   public:
60     const char* ToString();
61     virtual const char* GetComment() const = 0;
62     typedef map<string,QString> TRestoringMap;
63     typedef Storable* (*TStorableEngine)(SALOMEDS::SObject_ptr theSObject, 
64                                          const string& thePrefix, const TRestoringMap& theMap);
65     typedef map<string,TStorableEngine> TCallbackMap;
66     static void Registry(const char* theComment, TStorableEngine theEngine) 
67       throw(std::logic_error&);
68     static Storable* Create(SALOMEDS::SObject_ptr, const string& thePrefix, const string& theString) 
69       throw(std::runtime_error&);
70     static const QString& FindValue(const TRestoringMap& theMap, const string& theArg, bool* isFind = NULL)
71       throw(std::logic_error&);
72     static void StrToMap(const QString& theStr, VISU::Storable::TRestoringMap& theMap);
73     static SALOMEDS::SObject_ptr GetResultSO(SALOMEDS::SObject_ptr theSObject);
74     static void DataToStream(ostrstream& theStr, const QString& theName, const QString& theVal);
75     static void DataToStream(ostrstream& theStr, const QString& theName, const int theVal);
76     static void DataToStream(ostrstream& theStr, const QString& theName, const double theVal);
77   };
78   //===========================================================================
79   CORBA::ORB_var GetORB();
80   PortableServer::POA_var GetPOA();
81   VISU_Gen_var GetVisu();
82   PortableServer::Servant GetServant(CORBA::Object_ptr theObject);
83   CORBA::Object_var SObjectToObject(SALOMEDS::SObject_ptr theSObject);
84   SALOMEDS::SComponent_var FindOrCreateVisuComponent(SALOMEDS::Study_ptr theStudyDocument);
85   string CreateAttributes(SALOMEDS::Study_ptr theStudyDocument, 
86                           const char* theFatherEntry, const char* theRefFatherEntry,
87                           const char* theIOR, const char* theName, 
88                           const char* thePersistentRef, const char* theComment,
89                           CORBA::Boolean theCreateNew = true);
90   string FindEntryWithComment(SALOMEDS::Study_ptr theStudyDocument, const char* theStartEntry,
91                               const char* theComment, int IsAllLevels = true);
92   const CORBA::Boolean IsMultifile();
93 }
94
95 #endif