Salome HOME
DCQ : Merge with Ecole_Ete_a6.
[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   // Persistence
71   virtual char* SaveTo();
72   virtual void  LoadFrom( const char* theStream );
73   
74 protected:
75   ::SMESH_Hypothesis* myBaseImpl;    // base hypothesis implementation
76 };
77
78 // ======================================================
79 // Generic hypothesis creator
80 // ======================================================
81 class GenericHypothesisCreator_i
82 {
83 public:
84   // Create a hypothesis
85   virtual SMESH_Hypothesis_i* Create(PortableServer::POA_ptr thePOA,
86                                      int                     theStudyId,
87                                      ::SMESH_Gen*            theGenImpl) = 0;
88 };
89
90 //=============================================================================
91 //
92 // Specific Hypothesis Creators are generated with a template which inherits a
93 // generic hypothesis creator. Each creator returns an hypothesis of the type
94 // given in the template. 
95 //
96 //=============================================================================
97 template <class T> class HypothesisCreator_i: public GenericHypothesisCreator_i
98 {
99 public:
100   virtual SMESH_Hypothesis_i* Create (PortableServer::POA_ptr thePOA,
101                                       int                     theStudyId,
102                                       ::SMESH_Gen*            theGenImpl) 
103   {
104     return new T (thePOA, theStudyId, theGenImpl);
105   };
106 };
107
108 #endif