Salome HOME
Merge from V5_1_main 14/05/2010
[modules/kernel.git] / src / ParallelContainer / SALOME_ParallelContainerProxy_i.hxx
1 //  Copyright (C) 2007-2010  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.
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 //  SALOME_ParallelContainerProxy : implementation of container and engine for Parallel Kernel
24 //  File   : SALOME_ParallelContainerProxy_i.hxx
25 //  Author : André RIBES, EDF
26 //
27 #ifndef _SALOME_PARALLEL_CONTAINER_PROXY_I_HXX_
28 #define _SALOME_PARALLEL_CONTAINER_PROXY_I_HXX_
29
30 #include "utilities.h"
31 #include "Basics_Utils.hxx"
32 #include "SALOME_PACOExtensionPaCO_Engines_PACO_Container_server.hxx"
33 #include "SALOME_ParallelGlobalProcessVar_i.hxx"
34 #include "SALOME_NamingService.hxx"
35 #include "RegistryConnexion.hxx"
36 #include <map>
37 #include <dlfcn.h>
38 #include <paco_omni.h>
39
40 #include <Python.h>
41 #include "Container_init_python.hxx"
42
43 class Container_proxy_impl_final :
44   virtual public Engines::PACO_Container_proxy_impl,
45   virtual public ParallelGlobalProcessVar_i
46 {
47   public:
48     Container_proxy_impl_final(CORBA::ORB_ptr orb, 
49                                paco_fabrique_thread * fab_thread,
50                                PortableServer::POA_ptr poa,
51                                std::string containerName,
52                                bool is_a_return_proxy = false);
53
54     virtual ~Container_proxy_impl_final();
55
56     virtual void Shutdown();
57
58     virtual ::CORBA::Boolean load_component_Library(const char* componentName,CORBA::String_out reason);
59     virtual Engines::Component_ptr create_component_instance(const char* componentName, ::CORBA::Long studyId);
60     virtual Engines::Component_ptr create_component_instance_env( const char* componentName,
61                                                                   CORBA::Long studyId,          // 0 for multiStudy
62                                                                   const Engines::FieldsDict& env,
63                                                                   CORBA::String_out reason);
64
65   private:
66     std::map<std::string, std::string> _libtype_map; // libname -> libtype (seq ou par)
67
68     struct proxy_object
69     {
70       Engines::Component_var     proxy_corba_ref;
71       PortableServer::ObjectId * proxy_id;
72       RegistryConnexion *        proxy_regist;
73     };
74
75     // Cette liste contient les references vers les différentes
76     // instances d'objets parallèles.
77     std::list<Container_proxy_impl_final::proxy_object> _par_obj_inst_list;
78
79     // Fonction de test pour savoir si les objets de la bib sont
80     // parallèles ou sequentiels
81     typedef void (*PACO_TEST_FUNCTION) ();
82     typedef PortableServer::ObjectId * (*FACTORY_FUNCTION) (CORBA::ORB_ptr,
83                                                             paco_fabrique_thread *,
84                                                             PortableServer::POA_ptr,
85                                                             PortableServer::ObjectId *,
86                                                             RegistryConnexion **,
87                                                             const char *,
88                                                             int);
89     int _numInstance;
90     std::string _hostname;
91     std::string _containerName;
92     PortableServer::POA_var _poa;
93     PortableServer::ObjectId * _id;
94     SALOME_NamingService *_NS;
95
96     paco_fabrique_thread * _fab_thread; 
97 };
98
99 #endif