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