Back to index

salome-kernel  6.5.0
DSC_interface.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  File   : DSC_interface.hxx
00024 //  Author : André RIBES (EDF)
00025 //  Module : KERNEL
00026 //
00027 #ifndef _DSC_INTERFACE_HXX_
00028 #define _DSC_INTERFACE_HXX_
00029 
00030 #include <iostream>
00031 #include <map>
00032 #include <string.h>
00033 #include <assert.h>
00034 
00035 #include "DSC_Callbacks.hxx"
00036 
00043 class Engines_DSC_interface: 
00044   public DSC_Callbacks
00045 {
00046 public:
00047   Engines_DSC_interface();
00048   virtual ~Engines_DSC_interface();
00049 
00053   virtual void add_provides_port(Ports::Port_ptr ref, 
00054                                  const char* provides_port_name,
00055                                  Ports::PortProperties_ptr port_prop) 
00056     throw (Engines::DSC::PortAlreadyDefined,
00057            Engines::DSC::NilPort,
00058            Engines::DSC::BadProperty);
00059 
00063   virtual void add_uses_port(const char* repository_id, 
00064                              const char* uses_port_name,
00065                              Ports::PortProperties_ptr port_prop)
00066     throw (Engines::DSC::PortAlreadyDefined,
00067            Engines::DSC::BadProperty);
00068 
00072   virtual Ports::Port_ptr get_provides_port(const char* provides_port_name,
00073                                             const CORBA::Boolean connection_error) 
00074     throw (Engines::DSC::PortNotDefined,
00075            Engines::DSC::PortNotConnected,
00076            Engines::DSC::BadPortType);
00077 
00081   virtual Engines::DSC::uses_port * get_uses_port(const char* uses_port_name)
00082     throw (Engines::DSC::PortNotDefined,
00083            Engines::DSC::PortNotConnected,
00084            Engines::DSC::BadPortType);
00085 
00094   virtual void connect_provides_port(const char* provides_port_name)
00095     throw (Engines::DSC::PortNotDefined);
00096 
00103   virtual void connect_uses_port(const char* uses_port_name,
00104                                  Ports::Port_ptr provides_port_ref) 
00105   throw (Engines::DSC::PortNotDefined,
00106          Engines::DSC::BadPortType,
00107          Engines::DSC::NilPort);
00108 
00112   virtual CORBA::Boolean is_connected(const char* port_name)
00113     throw (Engines::DSC::PortNotDefined);
00114 
00123   virtual void disconnect_provides_port(const char* provides_port_name,
00124                                         const Engines::DSC::Message message)
00125     throw (Engines::DSC::PortNotDefined,
00126            Engines::DSC::PortNotConnected);
00127 
00139   virtual void disconnect_uses_port(const char* uses_port_name,
00140                                     Ports::Port_ptr provides_port_ref,
00141                                     const Engines::DSC::Message message)
00142     throw (Engines::DSC::PortNotDefined,
00143            Engines::DSC::PortNotConnected,
00144            Engines::DSC::BadPortReference);
00145 
00149   virtual Ports::PortProperties_ptr get_port_properties(const char* port_name)
00150     throw (Engines::DSC::PortNotDefined);
00151 
00152   static void writeEvent(const char* request,const std::string& containerName, const char* instance_name,
00153                          const char* port_name, const char* error, const char* message);
00154 
00155 protected:
00156 
00157   /*-------------------------------------------------*/
00158   /* Definition des types pour le stockage des ports */
00159   
00160   enum port_type {uses, provides, none};
00161 
00162   struct port_t {
00163     port_type type;
00164     int connection_nbr;
00165     
00166     // Specifique aux uses port
00167     Engines::DSC::uses_port uses_port_refs;
00168     std::string repository_id;
00169 
00170     // Specifique aux provides port;
00171     Ports::Port_var provides_port_ref;
00172 
00173     Ports::PortProperties_var port_prop;
00174   };
00175 
00176   typedef std::map<std::string, port_t *> ports;
00177 
00178   /*-------------------------------------------------*/
00179   /*-------------------------------------------------*/
00180  
00181   ports my_ports;
00182   ports::iterator my_ports_it;
00183 };
00184 
00185 #endif