Salome HOME
ConnectionManager in no corba mode.
[modules/yacs.git] / src / runtime / ConnectionManager.hxx
1 // Copyright (C) 2007-2021  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 #ifndef _CONNECTION_MANAGER_HXX_
24 #define _CONNECTION_MANAGER_HXX_
25
26 #include "YACSRuntimeSALOMEExport.hxx"
27 #include "DSC_Basic.hxx"
28
29 #include <map>
30 #include <mutex>
31
32 #include <SALOMEconfig.h>
33 #include CORBA_SERVER_HEADER(DSC_Engines)
34
35 /*! \class ConnectionManager
36  *  \brief This class implements the interface Engines::ConnectionManager.
37  * It is used to make connections between CALCIUM ports.
38  */
39 class YACSRUNTIMESALOME_EXPORT ConnectionManager
40 {
41   public :
42     ConnectionManager();
43     ~ConnectionManager();
44     
45     typedef short connectionId;
46
47     /*!
48      * connect two CALCIUM ports of two components.
49      */
50     ConnectionManager::connectionId connect(Engines::DSC_ptr uses_component, 
51                                             const char* uses_port_name, 
52                                             Engines::DSC_ptr provides_component, 
53                                             const char* provides_port_name);
54
55     /*!
56      * releases a connection performed with ConnectionManager::connect.
57      */
58     void disconnect(ConnectionManager::connectionId id,
59                     Engines::DSC::Message message);
60
61     /*!
62        Shutdown the ConnectionManager process.
63      */
64     void ShutdownWithExit();
65
66   private :
67
68     struct connection_infos {
69       Engines::DSC_var uses_component; 
70       std::string uses_port_name;
71       Engines::DSC_var provides_component;
72       std::string provides_port_name;
73       Ports::Port_var provides_port;
74     };
75
76     typedef std::map<Engines::ConnectionManager::connectionId, 
77             connection_infos *> ids_type;
78     typedef std::map<Engines::ConnectionManager::connectionId, 
79             connection_infos *>::iterator ids_it_type;
80
81     ids_type _ids;
82     int _current_id;
83     std::mutex _mutex;
84 };
85
86 #endif