Salome HOME
af7d7f5b2f993855a6350df43d34141b676bda7b
[modules/kernel.git] / src / DSC / DSC_Basic / DSC_interface.hxx
1 //  Copyright (C) 2007-2008  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 //  File   : DSC_interface.hxx
23 //  Author : AndrĂ© RIBES (EDF)
24 //  Module : KERNEL
25 //
26 #ifndef _DSC_INTERFACE_HXX_
27 #define _DSC_INTERFACE_HXX_
28
29 #include <iostream>
30 #include <map>
31 #include <string.h>
32 #include <assert.h>
33
34 #include "DSC_Callbacks.hxx"
35
36 /*! \class Engines_DSC_interface
37  *  \brief This class implements the interface Engines::DSC
38  *
39  *  This class is used by the sequential DSC implementation
40  *  and the parallel DSC implementation.
41  */
42 class Engines_DSC_interface: 
43   public DSC_Callbacks
44 {
45 public:
46   Engines_DSC_interface();
47   virtual ~Engines_DSC_interface();
48
49   /*!
50    * \see Engines::DSC::add_provides_port
51    */
52   virtual void add_provides_port(Ports::Port_ptr ref, 
53                                  const char* provides_port_name,
54                                  Ports::PortProperties_ptr port_prop) 
55     throw (Engines::DSC::PortAlreadyDefined,
56            Engines::DSC::NilPort,
57            Engines::DSC::BadProperty);
58
59   /*!
60    * \see Engines::DSC::add_uses_port
61    */
62   virtual void add_uses_port(const char* repository_id, 
63                              const char* uses_port_name,
64                              Ports::PortProperties_ptr port_prop)
65     throw (Engines::DSC::PortAlreadyDefined,
66            Engines::DSC::BadProperty);
67
68   /*!
69    * \see Engines::DSC::get_provides_port
70    */
71   virtual Ports::Port_ptr get_provides_port(const char* provides_port_name,
72                                             const CORBA::Boolean connection_error) 
73     throw (Engines::DSC::PortNotDefined,
74            Engines::DSC::PortNotConnected,
75            Engines::DSC::BadPortType);
76
77   /*!
78    * \see Engines::DSC::get_uses_port
79    */
80   virtual Engines::DSC::uses_port * get_uses_port(const char* uses_port_name)
81     throw (Engines::DSC::PortNotDefined,
82            Engines::DSC::PortNotConnected,
83            Engines::DSC::BadPortType);
84
85   /*!
86    * \see Engines::DSC::connect_provides_port
87    *
88    * \note This method uses Callbacks mechanism to inform the provides
89    * port how much uses ports are connected with. Currently, the provides
90    * port doesn't know its uses ports references. It's framework or application role
91    * to manage connections between ports.
92    */
93   virtual void connect_provides_port(const char* provides_port_name)
94     throw (Engines::DSC::PortNotDefined);
95
96   /*!
97    * \see Engines::DSC::connect_uses_port
98    *
99    * \note This method uses Callbacks mechanism to inform the uses
100    * port how much provides ports are connected with.
101    */
102   virtual void connect_uses_port(const char* uses_port_name,
103                                  Ports::Port_ptr provides_port_ref) 
104   throw (Engines::DSC::PortNotDefined,
105          Engines::DSC::BadPortType,
106          Engines::DSC::NilPort);
107
108   /*!
109    * \see Engines::DSC::is_connected
110    */
111   virtual CORBA::Boolean is_connected(const char* port_name)
112     throw (Engines::DSC::PortNotDefined);
113
114    /*!
115    * \see Engines::DSC::disconnect_provides_port
116    *
117    * \note This method uses Callbacks mechanism to inform the provides
118    * port how much uses ports are connected with. Currently, the provides
119    * port doesn't know its uses ports references. It's framework or application role
120    * to manage connections between ports.
121    */
122   virtual void disconnect_provides_port(const char* provides_port_name,
123                                         const Engines::DSC::Message message)
124     throw (Engines::DSC::PortNotDefined,
125            Engines::DSC::PortNotConnected);
126
127    /*!
128    * \see Engines::DSC::disconnect_uses_port
129    *
130    *
131    * \note This method uses Callbacks mechanism to inform the uses
132    * port how much provides ports are connected with. 
133    *
134    * \warning The new sequence of the uses port is sended by the callback. 
135    * The old sequence is not destoyed. Is uses port user's role to destroy 
136    * the sequence.
137    */
138   virtual void disconnect_uses_port(const char* uses_port_name,
139                                     Ports::Port_ptr provides_port_ref,
140                                     const Engines::DSC::Message message)
141     throw (Engines::DSC::PortNotDefined,
142            Engines::DSC::PortNotConnected,
143            Engines::DSC::BadPortReference);
144
145   /*!
146    * \see Engines::DSC::get_port_properties
147    */
148   virtual Ports::PortProperties_ptr get_port_properties(const char* port_name)
149     throw (Engines::DSC::PortNotDefined);
150
151 protected:
152
153   /*-------------------------------------------------*/
154   /* Definition des types pour le stockage des ports */
155   
156   enum port_type {uses, provides, none};
157
158   struct port_t {
159     port_type type;
160     int connection_nbr;
161     
162     // Specifique aux uses port
163     Engines::DSC::uses_port uses_port_refs;
164     std::string repository_id;
165
166     // Specifique aux provides port;
167     Ports::Port_var provides_port_ref;
168
169     Ports::PortProperties_var port_prop;
170   };
171
172   typedef std::map<std::string, port_t *> ports;
173
174   /*-------------------------------------------------*/
175   /*-------------------------------------------------*/
176  
177   ports my_ports;
178   ports::iterator my_ports_it;
179 };
180
181 #endif