2 //=============================================================================
3 // File : SMESH_HypothesisFactory_i.cxx
4 // Created : dim mai 19 22:02:42 CEST 2002
5 // Author : Paul RASCLE, EDF
7 // Copyright : EDF 2002
9 //=============================================================================
12 #include "SMESH_HypothesisFactory_i.hxx"
13 #include "SMESH_Hypothesis_i.hxx"
15 #include "Utils_CorbaException.hxx"
16 #include "utilities.h"
18 // Add new hypothesis here (include file)
19 //---------------------------------------
20 #include "SMESH_LocalLength_i.hxx"
21 #include "SMESH_NumberOfSegments_i.hxx"
22 #include "SMESH_MaxElementArea_i.hxx"
23 #include "SMESH_Regular_1D_i.hxx"
24 #include "SMESH_MEFISTO_2D_i.hxx"
25 #include "SMESH_Quadrangle_2D_i.hxx"
26 #include "SMESH_Hexa_3D_i.hxx"
28 //---------------------------------------
30 //=============================================================================
32 * Specific Hypothesis Creators are generated with a template which inherits a
33 * generic hypothesis creator. Each creator returns an hypothesis of the type
34 * given in the template.
36 //=============================================================================
38 template <class T> class HypothesisCreator_i: public GenericHypothesisCreator_i
41 virtual SMESH_Hypothesis_i* Create (const char* anHyp,
45 return new T(anHyp, studyId, genImpl);
49 //=============================================================================
51 * Constructor: instanciate specific hypothesis creators, fill a private map
52 * indexed by hypothesis names. THIS METHOD MUST BE COMPLETED WHEN A NEW
53 * HYPOTHESIS IS ADDED.
54 * Specific hypothesis creator are defined with the above template.
55 * Hypothesis names are related to the corresponding class names:
56 * prefix = SMESH_ ; suffix = _i .
58 //=============================================================================
60 SMESH_HypothesisFactory_i::SMESH_HypothesisFactory_i()
62 // Add new hypothesis here (creators)
63 //---------------------------------------
64 _creatorMap["LocalLength"] = new HypothesisCreator_i<SMESH_LocalLength_i>;
65 _creatorMap["NumberOfSegments"] = new HypothesisCreator_i<SMESH_NumberOfSegments_i>;
66 _creatorMap["MaxElementArea"] = new HypothesisCreator_i<SMESH_MaxElementArea_i>;
67 _creatorMap["Regular_1D"] = new HypothesisCreator_i<SMESH_Regular_1D_i>;
68 _creatorMap["MEFISTO_2D"] = new HypothesisCreator_i<SMESH_MEFISTO_2D_i>;
69 _creatorMap["Quadrangle_2D"] = new HypothesisCreator_i<SMESH_Quadrangle_2D_i>;
70 _creatorMap["Hexa_3D"] = new HypothesisCreator_i<SMESH_Hexa_3D_i>;
72 //---------------------------------------
75 //=============================================================================
77 * Destructor: deletes specific hypothesis creators instanciated in the
80 //=============================================================================
82 SMESH_HypothesisFactory_i::~SMESH_HypothesisFactory_i()
84 map<string, GenericHypothesisCreator_i*>::iterator it;
85 for (it = _creatorMap.begin(); it != _creatorMap.end(); it++)
92 //=============================================================================
96 //=============================================================================
98 SMESH_Hypothesis_i* SMESH_HypothesisFactory_i::Create(const char* anHyp,
100 ::SMESH_Gen* genImpl)
101 throw (SALOME::SALOME_Exception)
103 MESSAGE("SMESH_HypothesisFactory::Create " << anHyp);
104 if (_creatorMap.find(anHyp) == _creatorMap.end())
106 MESSAGE("levee exception CORBA");
107 THROW_SALOME_CORBA_EXCEPTION("bad hypothesis type name", \
110 SMESH_Hypothesis_i* myHyp = _creatorMap[anHyp]->Create(anHyp,