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>
6 #ifndef __VISU_CONFIG_H__
7 #define __VISU_CONFIG_H__
9 // standard C++ headers
15 #include <qfileinfo.h>
16 #include <qapplication.h>
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"
35 //===========================================================================
37 class Base_i : public virtual POA_VISU::Base,
38 public virtual PortableServer::RefCountServantBase
42 virtual char* GetID();
43 virtual VISU::VISUType GetType()=0;
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;
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();
59 //===========================================================================
63 int isQAppLocked, isSessionLocked;
65 Mutex(QMutex* theMutex, QApplication* theQApp);
68 //===========================================================================
69 class Storable : public virtual Base_i {
71 virtual void ToStream(ostrstream& theStr) = 0;
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);
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);