Salome HOME
DCQ:prepare 2.0.0
[modules/smesh.git] / src / SMESH_I / SMESH_Hypothesis_i.hxx
1 //  SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
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 //
24 //  File   : SMESH_Hypothesis_i.hxx
25 //  Author : Paul RASCLE, EDF
26 //  Module : SMESH
27 //  $Header$
28
29 #ifndef _SMESH_HYPOTHESIS_I_HXX_
30 #define _SMESH_HYPOTHESIS_I_HXX_
31
32 #include <SALOMEconfig.h>
33 #include CORBA_SERVER_HEADER(SMESH_Hypothesis)
34
35 #include "SMESH_Hypothesis.hxx"
36 #include "SALOME_GenericObj_i.hh"
37
38 #include "SMESH_Gen.hxx"
39
40 // ======================================================
41 // Generic hypothesis
42 // ======================================================
43 class SMESH_Hypothesis_i:
44   public virtual POA_SMESH::SMESH_Hypothesis,
45   public virtual SALOME::GenericObj_i
46 {
47 public:
48   // Constructor : placed in protected section to prohibit creation of generic class instance
49   SMESH_Hypothesis_i( PortableServer::POA_ptr thePOA );
50
51 public:
52   // Destructor
53   virtual ~SMESH_Hypothesis_i();
54
55   // Get type name of hypothesis
56   char* GetName();
57
58   // Get plugin library name of hypothesis
59   char* GetLibName();
60
61   // Set plugin library name of hypothesis
62   void SetLibName( const char* theLibName );
63
64   // Get unique id of hypothesis
65   CORBA::Long GetId();
66
67   // Get implementation
68   ::SMESH_Hypothesis* GetImpl();
69   
70   // _CS_gbo_ Activate the object using the POA
71   void Activate();
72
73   // Persistence
74   virtual char* SaveTo();
75   virtual void  LoadFrom( const char* theStream );
76   
77 protected:
78   ::SMESH_Hypothesis* myBaseImpl;    // base hypothesis implementation
79
80   // _CS_gbo_070505 To keep the reference and delayed the activation
81   // in the methode Activate().
82   PortableServer::POA_ptr myPOA;
83 };
84
85 // ======================================================
86 // Generic hypothesis creator
87 // ======================================================
88 class GenericHypothesisCreator_i
89 {
90 public:
91   // Create a hypothesis
92   virtual SMESH_Hypothesis_i* Create(PortableServer::POA_ptr thePOA,
93                                      int                     theStudyId,
94                                      ::SMESH_Gen*            theGenImpl) = 0;
95 };
96
97 //=============================================================================
98 //
99 // Specific Hypothesis Creators are generated with a template which inherits a
100 // generic hypothesis creator. Each creator returns an hypothesis of the type
101 // given in the template. 
102 //
103 //=============================================================================
104 template <class T> class HypothesisCreator_i: public GenericHypothesisCreator_i
105 {
106 public:
107   virtual SMESH_Hypothesis_i* Create (PortableServer::POA_ptr thePOA,
108                                       int                     theStudyId,
109                                       ::SMESH_Gen*            theGenImpl) 
110   {
111     return new T (thePOA, theStudyId, theGenImpl);
112   };
113 };
114
115 #endif