General KERNEL Documentation     End User KERNEL Services  


src/Container/SALOME_Component_i.hxx

Go to the documentation of this file.
00001 //  SALOME Container : implementation of container and engine for Kernel
00002 //
00003 //  Copyright (C) 2003  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 //
00024 //  File   : SALOME_Component_i.hxx
00025 //  Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA
00026 //  Module : SALOME
00027 //  $Header: /home/server/cvs/KERNEL/KERNEL_SRC/src/Container/SALOME_Component_i.hxx,v 1.11.2.1 2006/09/04 05:27:15 prascle Exp $
00028 
00029 #ifndef _SALOME_COMPONENT_I_HXX_
00030 #define _SALOME_COMPONENT_I_HXX_
00031 
00032 #include <iostream>
00033 #include <signal.h>
00034 #include <stdlib.h>
00035 #ifndef WNT
00036 #include <unistd.h>
00037 #endif
00038 #include <sys/types.h>
00039 #include <string>
00040 #include <map>
00041 #include <SALOMEconfig.h>
00042 #include CORBA_SERVER_HEADER(SALOME_Component)
00043 #include "NOTIFICATION.hxx"
00044 
00045 class RegistryConnexion;
00046 class Engines_Container_i;
00047 
00048 #if defined CONTAINER_EXPORTS
00049 #if defined WIN32
00050 #define CONTAINER_EXPORT __declspec( dllexport )
00051 #else
00052 #define CONTAINER_EXPORT
00053 #endif
00054 #else
00055 #if defined WNT
00056 #define CONTAINER_EXPORT __declspec( dllimport )
00057 #else
00058 #define CONTAINER_EXPORT
00059 #endif
00060 #endif
00061 
00062 class CONTAINER_EXPORT Engines_Component_i: 
00063   public virtual POA_Engines::Component,
00064   public virtual PortableServer::RefCountServantBase
00065 {
00066 public:
00067   Engines_Component_i();
00068   Engines_Component_i(CORBA::ORB_ptr orb,
00069                 PortableServer::POA_ptr poa,
00070                 PortableServer::ObjectId * contId, 
00071                 const char *instanceName, 
00072                 const char *interfaceName,
00073                       bool notif = false);
00074   // Consructeur pour composant parallele: ne pas faire appel au registry
00075   Engines_Component_i(CORBA::ORB_ptr orb,
00076                 PortableServer::POA_ptr poa,
00077                 PortableServer::ObjectId * contId, 
00078                 const char *instanceName, 
00079                 const char *interfaceName,
00080                 int flag,
00081                       bool notif = false);
00082 
00083   virtual ~Engines_Component_i();
00084 
00085   // --- CORBA methods
00086 
00087   char* instanceName();
00088   char* interfaceName();
00089 
00090   void ping();
00091   void destroy();
00092 
00093   CORBA::Long getStudyId();
00094   Engines::Container_ptr GetContainerRef();
00095 
00096   void setProperties(const Engines::FieldsDict& dico);
00097   Engines::FieldsDict* getProperties();
00098 
00099   void Names( const char * graphName , const char * nodeName ) ;
00100   bool Kill_impl();
00101   bool Stop_impl();
00102   bool Suspend_impl();
00103   bool Resume_impl();
00104   CORBA::Long CpuUsed_impl() ;
00105 
00106  virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
00107                           CORBA::Boolean isPublished,
00108                           CORBA::Boolean& isValidScript);
00109 
00110 
00111   // --- local C++ methods
00112 
00113   PortableServer::ObjectId * getId(); 
00114   Engines_Container_i *GetContainerPtr();
00115 
00116   bool setStudyId(CORBA::Long studyId);
00117   static bool isMultiStudy();
00118   static bool isMultiInstance();
00119   static std::string GetDynLibraryName(const char *componentName);
00120 
00121   void beginService(const char *serviceName);
00122   void endService(const char *serviceName);
00123   void sendMessage(const char *event_type, const char *message);
00124   char * graphName() ;
00125   char * nodeName() ;
00126   bool Killer( pthread_t ThreadId , int signum );
00127   void SetCurCpu() ;
00128   long CpuUsed() ;
00129   void CancelThread() ;
00130 
00131 protected:
00132   int _studyId; // -1: not initialised; 0: multiStudy; >0: study
00133   static bool _isMultiStudy;
00134   static bool _isMultiInstance;
00135 
00136   std::string _instanceName ;
00137   std::string _interfaceName ;
00138 
00139   CORBA::ORB_ptr _orb;
00140   PortableServer::POA_ptr _poa;
00141   PortableServer::ObjectId * _id;
00142   PortableServer::ObjectId * _contId;
00143   Engines_Component_i * _thisObj ;
00144   RegistryConnexion *_myConnexionToRegistry;
00145   NOTIFICATION_Supplier* _notifSupplier;
00146   std::map<std::string,CORBA::Any>_fieldsDict;
00147 
00148   std::string _serviceName ;
00149   std::string _graphName ;
00150   std::string _nodeName ;
00151 
00152 private:
00153 #ifndef WNT
00154   pthread_t _ThreadId ;
00155 #else
00156   pthread_t* _ThreadId ;
00157 #endif
00158   long      _StartUsed ;
00159   long      _ThreadCpuUsed ;
00160   bool      _Executed ;
00161   bool      _CanceledThread ;
00162 };
00163 
00164 #endif