]> SALOME platform Git repositories - modules/visu.git/blob - src/VISU_I/VISUConfig.hh
Salome HOME
dd9f4c6afe8b6a4c889fad6e96f5e21eb5be5bc6
[modules/visu.git] / src / VISU_I / VISUConfig.hh
1 //  VISU OBJECT : interactive object for VISU entities implementation
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //  File   : VISUConfig.hh
24 //  Author : Alexey PETROV
25 //  Module : VISU
26
27 #ifndef __VISU_CONFIG_H__
28 #define __VISU_CONFIG_H__
29
30 // standard C++ headers
31 #include <stdio.h>
32 #include <iostream>
33 #include <string>
34 #include <qstring.h> 
35 #include <qthread.h> 
36 #include <qfileinfo.h>
37 #include <qapplication.h>
38
39 // IDL headers
40 #include "SALOMEconfig.h"
41 #include CORBA_SERVER_HEADER(VISU_Gen)
42 #include CORBA_SERVER_HEADER(MED)
43 #include CORBA_SERVER_HEADER(SALOMEDS)
44 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
45 #include "SALOME_NamingService.hxx"
46 #include "SALOME_LifeCycleCORBA.hxx"
47 #include "Utils_CorbaException.hxx"
48 #include "utilities.h"
49
50 #include <stdexcept>
51 #include <sstream>      
52
53 namespace VISU{
54   //===========================================================================
55   class VISU_Gen_i;
56
57   class Base_i : public virtual POA_VISU::Base,
58                  public virtual PortableServer::RefCountServantBase
59   {
60   public:
61     Base_i();
62     virtual ~Base_i();
63     virtual char* GetID();
64     virtual VISU::VISUType GetType() = 0;
65
66   protected:
67     std::string myID;
68
69   protected:
70     static QMutex* myMutex;
71     static CORBA::ORB_var myOrb;
72     static PortableServer::POA_var myPoa;
73     static SALOME_NamingService* myNamingService;
74     static VISU_Gen_i* myVisuGenImpl;
75     static SALOME_LifeCycleCORBA* myEnginesLifeCycle;
76
77   public:
78     static CORBA::ORB_var GetORB() { return myOrb;}
79     static PortableServer::POA_var GetPOA() { return myPoa;}
80     static SALOME_NamingService* GetNS() { return myNamingService;}
81     static SALOME_LifeCycleCORBA* GetLCC() { return myEnginesLifeCycle;}
82     static VISU_Gen_i* GetVisuGenImpl() { return myVisuGenImpl;}
83   };
84
85
86   //===========================================================================
87   class Mutex{
88     QMutex* myMutex;
89     QApplication* myQApp;
90     int isQAppLocked, isSessionLocked, myDelay;
91   public:
92     Mutex(QMutex* theMutex, QApplication* theQApp, int theDelay = 0);
93     ~Mutex();
94   };
95
96
97   //===========================================================================
98   class Storable : public virtual Base_i {
99   protected:
100     virtual void ToStream(std::ostringstream& theStr) = 0;
101   public:
102     std::string ToString();
103     virtual const char* GetComment() const = 0;
104     typedef std::map<std::string,QString> TRestoringMap;
105     typedef Storable* (*TStorableEngine)(SALOMEDS::SObject_ptr theSObject, 
106                                          const std::string& thePrefix, const TRestoringMap& theMap);
107     typedef std::map<string,TStorableEngine> TCallbackMap;
108     static void Registry(const char* theComment, TStorableEngine theEngine) 
109       throw(std::logic_error&);
110     static Storable* Create(SALOMEDS::SObject_ptr, const std::string& thePrefix, const std::string& theString) 
111       throw(std::runtime_error&);
112     static const QString& FindValue(const TRestoringMap& theMap, const std::string& theArg, bool* isFind = NULL)
113       throw(std::logic_error&);
114     static void StrToMap(const QString& theStr, VISU::Storable::TRestoringMap& theMap);
115     static SALOMEDS::SObject_ptr GetResultSO(SALOMEDS::SObject_ptr theSObject);
116     static void DataToStream(std::ostringstream& theStr, const QString& theName, const QString& theVal);
117     static void DataToStream(std::ostringstream& theStr, const QString& theName, const int theVal);
118     static void DataToStream(std::ostringstream& theStr, const QString& theName, const double theVal);
119   };
120
121
122   //===========================================================================
123   const CORBA::Boolean IsMultifile();
124   QString GenerateName(const string& theFmt, int theId);
125
126   PortableServer::ServantBase_var GetServant(CORBA::Object_ptr theObject);
127   CORBA::Object_var SObjectToObject(SALOMEDS::SObject_ptr theSObject);
128
129   SALOMEDS::SComponent_var FindOrCreateVisuComponent(SALOMEDS::Study_ptr theStudyDocument);
130
131   std::string CreateAttributes(SALOMEDS::Study_ptr theStudyDocument, 
132                                const char* theFatherEntry, const char* theRefFatherEntry,
133                                const char* theIOR, const char* theName, 
134                                const char* thePersistentRef, const char* theComment,
135                                CORBA::Boolean theCreateNew = true);
136
137   std::string FindEntryWithComment(SALOMEDS::Study_ptr theStudyDocument, const char* theStartEntry,
138                                    const char* theComment, int IsAllLevels = true);
139 }
140
141 #endif