1 // Copyright (C) 2003 CEA/DEN, EDF R&D
5 // File : VISU_Common.hh
6 // Author : Alexey PETROV
9 #ifndef __VISU_CONFIG_H__
10 #define __VISU_CONFIG_H__
12 // standard C++ headers
18 #include <qfileinfo.h>
19 #include <qapplication.h>
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"
38 //===========================================================================
40 class Base_i : public virtual POA_VISU::Base,
41 public virtual PortableServer::RefCountServantBase
45 virtual char* GetID();
46 virtual VISU::VISUType GetType() = 0;
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;
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();
62 //===========================================================================
66 int isQAppLocked, isSessionLocked, myDelay;
68 Mutex(QMutex* theMutex, QApplication* theQApp, int theDelay = 0);
71 //===========================================================================
72 class Storable : public virtual Base_i {
74 virtual void ToStream(std::ostringstream& theStr) = 0;
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);
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);