Salome HOME
#BOS 37851: include string for compilation on FD38
[modules/yacs.git] / src / runtime / ConnectionManager.hxx
1 // Copyright (C) 2007-2023  CEA, EDF
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef _CONNECTION_MANAGER_HXX_
21 #define _CONNECTION_MANAGER_HXX_
22
23 #include "YACSRuntimeSALOMEExport.hxx"
24 #include "DSC_Basic.hxx"
25
26 #include <map>
27 #include <mutex>
28
29 #include <string>
30
31 #include <SALOMEconfig.h>
32 #include CORBA_SERVER_HEADER(DSC_Engines)
33
34 /*! \class ConnectionManager
35  *  \brief This class implements the interface Engines::ConnectionManager.
36  * It is used to make connections between CALCIUM ports.
37  */
38 class YACSRUNTIMESALOME_EXPORT ConnectionManager
39 {
40   public :
41     ConnectionManager();
42     ~ConnectionManager();
43     
44     typedef short connectionId;
45
46     /*!
47      * connect two CALCIUM ports of two components.
48      */
49     ConnectionManager::connectionId connect(Engines::DSC_ptr uses_component, 
50                                             const char* uses_port_name, 
51                                             Engines::DSC_ptr provides_component, 
52                                             const char* provides_port_name);
53
54     /*!
55      * releases a connection performed with ConnectionManager::connect.
56      */
57     void disconnect(ConnectionManager::connectionId id,
58                     Engines::DSC::Message message);
59
60     /*!
61        Shutdown the ConnectionManager process.
62      */
63     void ShutdownWithExit();
64
65   private :
66
67     struct connection_infos {
68       Engines::DSC_var uses_component; 
69       std::string uses_port_name;
70       Engines::DSC_var provides_component;
71       std::string provides_port_name;
72       Ports::Port_var provides_port;
73     };
74
75     typedef std::map<Engines::ConnectionManager::connectionId, 
76             connection_infos *> ids_type;
77     typedef std::map<Engines::ConnectionManager::connectionId, 
78             connection_infos *>::iterator ids_it_type;
79
80     ids_type _ids;
81     int _current_id;
82     std::mutex _mutex;
83 };
84
85 #endif