src/MED/Med_Gen_i.hxx

Go to the documentation of this file.
00001 //  MED MED : implemetation of MED idl descriptions
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   : Med_Gen_i.hxx
00025 //  Author : Paul RASCLE, EDF
00026 //  Module : MED
00027 //  $Header: /home/server/cvs/MED/MED_SRC/src/MED/Med_Gen_i.hxx,v 1.8.2.2 2006/09/01 10:01:45 eap Exp $
00028 
00029 #ifndef _MED_GEN_I_HXX_
00030 #define _MED_GEN_I_HXX_
00031 
00032 #include <SALOMEconfig.h>
00033 #include <map>
00034 #include CORBA_SERVER_HEADER(MED_Gen)
00035 #include CORBA_SERVER_HEADER(MED)
00036 #include CORBA_SERVER_HEADER(SALOME_ModuleCatalog)
00037 
00038 #include "SALOME_Component_i.hxx"
00039 #include "SALOME_NamingService.hxx"
00040 
00041 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
00042 
00043 namespace MEDMEM {
00044   class MED_i;
00045 }
00046 
00047 class Med_Gen_i:
00048   public POA_SALOME_MED::MED_Gen,
00049   public Engines_Component_i 
00050 {
00051 private:
00052   SALOMEDS::Study_var studyName2Study(const char* studyName)
00053     throw(SALOME::SALOME_Exception);
00054   void addInStudy(SALOMEDS::Study_var myStudy)
00055     throw(SALOME::SALOME_Exception);
00056 
00057 public:
00058   Med_Gen_i();
00059   Med_Gen_i(CORBA::ORB_ptr orb,
00060          PortableServer::POA_ptr poa,
00061          PortableServer::ObjectId * contId, 
00062          const char *instanceName, 
00063          const char *interfaceName);
00064   virtual ~Med_Gen_i();
00065 
00066   //
00067   SALOME_MED::MESH_ptr readMeshInFile(const char* fileName,
00068                           const char* studyName,
00069                           const char* meshName)
00070   throw(SALOME::SALOME_Exception);
00071 
00072   SALOME_MED::FIELD_ptr readFieldInFile(const char* fileName,
00073                           const char* studyName,
00074                           const char* fieldName,
00075                           CORBA::Long ordre,
00076                           CORBA::Long iter)
00077   throw(SALOME::SALOME_Exception);
00078 
00079   SALOME_MED::MED_ptr   readStructFile(const char* fileName,
00080                           const char* studyName)
00081   throw(SALOME::SALOME_Exception);
00082 
00083   void    readStructFileWithFieldType(const char* fileName,
00084                           const char* studyName)
00085   throw(SALOME::SALOME_Exception);
00086 
00087   // inherited methods from SALOMEDS::Driver
00088 
00089 //    void Save(const char *IORSComponent, const char *aUrlOfFile);
00090 //    void Load(const char *IORSComponent, const char *aUrlOfFile); 
00091   SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent,
00092                  const char* theURL,
00093                  bool isMultiFile);
00094   SALOMEDS::TMPFile* SaveASCII(SALOMEDS::SComponent_ptr theComponent,
00095                       const char* theURL,
00096                       bool isMultiFile);
00097 
00098   CORBA::Boolean Load(SALOMEDS::SComponent_ptr theComponent,
00099                 const SALOMEDS::TMPFile& theStream,
00100                 const char* theURL,
00101                 bool isMultiFile);
00102   CORBA::Boolean LoadASCII(SALOMEDS::SComponent_ptr theComponent,
00103                   const SALOMEDS::TMPFile& theStream,
00104                   const char* theURL,
00105                   bool isMultiFile);
00106 
00107   void Close(SALOMEDS::SComponent_ptr theComponent);
00108   char* ComponentDataType();
00109     
00110   char* IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
00111                       const char* IORString,
00112                       CORBA::Boolean isMultiFile,
00113                       CORBA::Boolean isASCII);
00114   char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
00115                       const char* aLocalPersistentID,
00116                       CORBA::Boolean isMultiFile,
00117                       CORBA::Boolean isASCII)
00118     throw(SALOME::SALOME_Exception);
00119 
00120   bool CanPublishInStudy(CORBA::Object_ptr theIOR);
00121 
00122   SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::Study_ptr theStudy,
00123                            SALOMEDS::SObject_ptr theSObject,
00124                            CORBA::Object_ptr theObject,
00125                            const char* theName) throw (SALOME::SALOME_Exception) ;
00126 
00127   CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject);
00128   SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID);
00129   CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID);
00130   SALOMEDS::SObject_ptr PasteInto(const SALOMEDS::TMPFile& theStream,
00131                       CORBA::Long theObjectID,
00132                       SALOMEDS::SObject_ptr theObject);
00133   
00134   // Get last created instance of the class
00135   static Med_Gen_i* GetMEDGen() { return _MEDGen; }
00136 
00137   // Get object of the CORBA reference
00138   static PortableServer::ServantBase_var GetServant( CORBA::Object_ptr theObject );
00139 
00140   template<class T>
00141   static T DownCast(CORBA::Object_ptr theArg)
00142   {
00143     return dynamic_cast<T>(GetServant(theArg).in());
00144   }
00145 
00146 private :
00147   static std::map <std::string, std::string>_MedCorbaObj;
00148   static std::string _myFileName;
00149   static std::string _saveFileName;
00150   static Med_Gen_i*  _MEDGen;    // Point to last created instance of the class
00151 
00152   private:
00153   bool   _duringLoad;
00154   int    _myStudyID;
00155   std::string _myStudyName;
00156   
00157   int myCounter;
00158   SALOME_NamingService *_NS;
00159 };
00160 
00161 #endif