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