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 "Utils_CorbaException.hxx"
27 #include "utilities.h"
33 //===========================================================================
34 class Base_i : public virtual POA_VISU::Base,
35 public virtual PortableServer::RefCountServantBase
39 virtual char* GetID();
40 virtual VISU::VISUType GetType()=0;
42 static QMutex* myMutex;
43 static CORBA::ORB_var myOrb;
44 static PortableServer::POA_var myPOA;
46 //===========================================================================
50 int isQAppLocked, isSessionLocked;
52 Mutex(QMutex* theMutex, QApplication* theQApp);
55 //===========================================================================
56 class Storable : public virtual Base_i {
58 virtual void ToStream(ostrstream& theStr) = 0;
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);
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();