SALOME documentation central

src/DSC/DSC_Basic/DSC_interface.hxx

00001 //  Copyright (C) 2007-2008  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 //  File   : DSC_interface.hxx
00023 //  Author : André RIBES (EDF)
00024 //  Module : KERNEL
00025 //
00026 #ifndef _DSC_INTERFACE_HXX_
00027 #define _DSC_INTERFACE_HXX_
00028 
00029 #include <iostream>
00030 #include <map>
00031 #include <string.h>
00032 #include <assert.h>
00033 
00034 #include "DSC_Callbacks.hxx"
00035 
00042 class Engines_DSC_interface: 
00043   public DSC_Callbacks
00044 {
00045 public:
00046   Engines_DSC_interface();
00047   virtual ~Engines_DSC_interface();
00048 
00052   virtual void add_provides_port(Ports::Port_ptr ref, 
00053                      const char* provides_port_name,
00054                      Ports::PortProperties_ptr port_prop) 
00055     throw (Engines::DSC::PortAlreadyDefined,
00056         Engines::DSC::NilPort,
00057         Engines::DSC::BadProperty);
00058 
00062   virtual void add_uses_port(const char* repository_id, 
00063                     const char* uses_port_name,
00064                     Ports::PortProperties_ptr port_prop)
00065     throw (Engines::DSC::PortAlreadyDefined,
00066         Engines::DSC::BadProperty);
00067 
00071   virtual Ports::Port_ptr get_provides_port(const char* provides_port_name,
00072                              const CORBA::Boolean connection_error) 
00073     throw (Engines::DSC::PortNotDefined,
00074         Engines::DSC::PortNotConnected,
00075         Engines::DSC::BadPortType);
00076 
00080   virtual Engines::DSC::uses_port * get_uses_port(const char* uses_port_name)
00081     throw (Engines::DSC::PortNotDefined,
00082         Engines::DSC::PortNotConnected,
00083         Engines::DSC::BadPortType);
00084 
00093   virtual void connect_provides_port(const char* provides_port_name)
00094     throw (Engines::DSC::PortNotDefined);
00095 
00102   virtual void connect_uses_port(const char* uses_port_name,
00103                      Ports::Port_ptr provides_port_ref) 
00104   throw (Engines::DSC::PortNotDefined,
00105       Engines::DSC::BadPortType,
00106       Engines::DSC::NilPort);
00107 
00111   virtual CORBA::Boolean is_connected(const char* port_name)
00112     throw (Engines::DSC::PortNotDefined);
00113 
00122   virtual void disconnect_provides_port(const char* provides_port_name,
00123                          const Engines::DSC::Message message)
00124     throw (Engines::DSC::PortNotDefined,
00125         Engines::DSC::PortNotConnected);
00126 
00138   virtual void disconnect_uses_port(const char* uses_port_name,
00139                         Ports::Port_ptr provides_port_ref,
00140                         const Engines::DSC::Message message)
00141     throw (Engines::DSC::PortNotDefined,
00142         Engines::DSC::PortNotConnected,
00143         Engines::DSC::BadPortReference);
00144 
00148   virtual Ports::PortProperties_ptr get_port_properties(const char* port_name)
00149     throw (Engines::DSC::PortNotDefined);
00150 
00151   static void writeEvent(const char* request,const std::string& containerName, const char* instance_name,
00152                          const char* port_name, const char* error, const char* message);
00153 
00154 protected:
00155 
00156   /*-------------------------------------------------*/
00157   /* Definition des types pour le stockage des ports */
00158   
00159   enum port_type {uses, provides, none};
00160 
00161   struct port_t {
00162     port_type type;
00163     int connection_nbr;
00164     
00165     // Specifique aux uses port
00166     Engines::DSC::uses_port uses_port_refs;
00167     std::string repository_id;
00168 
00169     // Specifique aux provides port;
00170     Ports::Port_var provides_port_ref;
00171 
00172     Ports::PortProperties_var port_prop;
00173   };
00174 
00175   typedef std::map<std::string, port_t *> ports;
00176 
00177   /*-------------------------------------------------*/
00178   /*-------------------------------------------------*/
00179  
00180   ports my_ports;
00181   ports::iterator my_ports_it;
00182 };
00183 
00184 #endif