Salome HOME
4ca0a05c5c6247025a58a2b79efed64a43c10427
[modules/geom.git] / src / AdvancedEngine / AdvancedEngine_OperationsCreator.cxx
1 // Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  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, or (at your option) any later version.
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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #include "AdvancedEngine_OperationsCreator.hxx"
24 #include "AdvancedEngine_IOperations_i.hh"
25 #include "AdvancedEngine_IOperations.hxx"
26 #include <AdvancedEngine_PipeTShapeDriver.hxx>
27 #include <AdvancedEngine_DividedDiskDriver.hxx>
28 #include <AdvancedEngine_SmoothingSurfaceDriver.hxx>
29
30 #include <TFunction_Driver.hxx>
31 #include <TFunction_DriverTable.hxx>
32
33 #include "Utils_ExceptHandlers.hxx"
34 #include "utilities.h"
35
36 std::map <int, AdvancedEngine_IOperations*>  AdvancedEngine_OperationsCreator::_mapOfOperations;
37
38 AdvancedEngine_OperationsCreator::AdvancedEngine_OperationsCreator()
39 {
40   // Register drivers
41   TFunction_DriverTable::Get()->AddDriver(AdvancedEngine_PipeTShapeDriver::GetID(),
42                                           new AdvancedEngine_PipeTShapeDriver());
43   TFunction_DriverTable::Get()->AddDriver(AdvancedEngine_DividedDiskDriver::GetID(),
44                                           new AdvancedEngine_DividedDiskDriver());
45   TFunction_DriverTable::Get()->AddDriver(AdvancedEngine_SmoothingSurfaceDriver::GetID(),
46                                           new AdvancedEngine_SmoothingSurfaceDriver());
47 }
48
49 AdvancedEngine_OperationsCreator::~AdvancedEngine_OperationsCreator()
50 {
51 }
52
53 GEOM_IOperations_i* AdvancedEngine_OperationsCreator::Create (PortableServer::POA_ptr thePOA,
54                                                               int                     theStudyId,
55                                                               GEOM::GEOM_Gen_ptr      theEngine,
56                                                               ::GEOMImpl_Gen*         theGenImpl)
57 {
58   Unexpect aCatch(SALOME_SalomeException);
59   MESSAGE( "AdvancedEngine_OperationsCreator::Create" );
60   return new AdvancedEngine_IOperations_i( thePOA, theEngine, get( theGenImpl, theStudyId ) );
61 }
62
63 AdvancedEngine_IOperations* AdvancedEngine_OperationsCreator::get( ::GEOMImpl_Gen* theGenImpl,
64                                                                    int             theStudyId )
65 {
66   if (_mapOfOperations.find( theStudyId ) == _mapOfOperations.end() )
67     _mapOfOperations[theStudyId] = new AdvancedEngine_IOperations( theGenImpl, theStudyId );
68   return _mapOfOperations[theStudyId];
69 }