Back to index

salome-smesh  6.5.0
SMESH_Hypothesis_i.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 //  SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
00024 //  File   : SMESH_Hypothesis_i.hxx
00025 //  Author : Paul RASCLE, EDF
00026 //  Module : SMESH
00027 //
00028 #ifndef _SMESH_HYPOTHESIS_I_HXX_
00029 #define _SMESH_HYPOTHESIS_I_HXX_
00030 
00031 #include "SMESH.hxx"
00032 
00033 #include <SALOMEconfig.h>
00034 #include CORBA_SERVER_HEADER(SMESH_Hypothesis)
00035 
00036 #include "SMESH_Hypothesis.hxx"
00037 #include "SALOME_GenericObj_i.hh"
00038 
00039 #include "SMESH_Gen.hxx"
00040 
00041 #include <map>
00042 #include <string>
00043 
00044 class TCollection_AsciiString;
00045 
00046 // ======================================================
00047 // Generic hypothesis
00048 // ======================================================
00049 class SMESH_I_EXPORT SMESH_Hypothesis_i:
00050   public virtual POA_SMESH::SMESH_Hypothesis,
00051   public virtual SALOME::GenericObj_i
00052 {
00053 public:
00054   // Constructor : placed in protected section to prohibit creation of generic class instance
00055   SMESH_Hypothesis_i( PortableServer::POA_ptr thePOA );
00056 
00057 public:
00058   // Destructor
00059   virtual ~SMESH_Hypothesis_i();
00060 
00061   // Get type name of hypothesis
00062   char* GetName();
00063 
00064   // Get plugin library name of hypothesis
00065   char* GetLibName();
00066 
00067   // Set plugin library name of hypothesis
00068   void SetLibName( const char* theLibName );
00069 
00070   // Get unique id of hypothesis
00071   CORBA::Long GetId();
00072   
00073   // Set the variable parameter; method is a name of method setting this parameter.
00074   // This method must be called by the hypothesis creator just before calling hyp->method()
00075   void SetVarParameter (const char* parameter, const char* method);
00076 
00077   // Return the variable parameter used for Hypothesis creation by name of method
00078   // setting this parameter
00079   char* GetVarParameter (const char* methodName);
00080 
00081   // Set list of parameters  separated by ":" symbol, used for Hypothesis creation
00082   void SetParameters (const char* theParameters);
00083   
00084   // Return list of notebook variables used for Hypothesis creation separated by ":" symbol
00085   char* GetParameters();
00086 
00087   //Return list of last notebook variables used for Hypothesis creation.
00088   SMESH::ListOfParameters* GetLastParameters();
00089 
00090   //Set last parameters for not published hypothesis
00091   
00092   void SetLastParameters(const char* theParameters);
00093   
00094   // Clear parameters list
00095   void ClearParameters();
00096 
00097   //Return true if hypothesis was published in study
00098   bool IsPublished();
00099 
00100   // Get implementation
00101   ::SMESH_Hypothesis* GetImpl();
00102   
00103   // Persistence
00104   virtual char* SaveTo();
00105   virtual void  LoadFrom( const char* theStream );
00106   virtual void  UpdateAsMeshesRestored(); // for hyps needing full data restored
00107 
00108 protected:
00109   ::SMESH_Hypothesis*          myBaseImpl;    // base hypothesis implementation
00110 
00111   std::map< std::string, std::string > myMethod2VarParams; // variable parameters
00112 
00113 
00114  public:
00115   // Methods for backward compatibility of notebook variables
00116   
00117   // restore myMethod2VarParams by parameters stored in an old study
00118   virtual void setOldParameters (const char* theParameters);
00119 
00120   // method used to convert variable parameters stored in an old study
00121   // into myMethod2VarParams. It should return a method name for an index of
00122   // variable parameters. Index is countered from zero
00123   virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const { return ""; }
00124 
00125   // method intended to remove explicit treatment of Netgen hypotheses from SMESH_NoteBook
00126   virtual int getParamIndex(const TCollection_AsciiString& method, int nbVars) const { return -1; }
00127 };
00128 
00129 // ======================================================
00130 // Generic hypothesis creator
00131 // ======================================================
00132 class SMESH_I_EXPORT GenericHypothesisCreator_i
00133 {
00134 public:
00135   // Create a hypothesis
00136   virtual SMESH_Hypothesis_i* Create(PortableServer::POA_ptr thePOA,
00137                                      int                     theStudyId,
00138                                      ::SMESH_Gen*            theGenImpl) = 0;
00139   // return the name of IDL module
00140   virtual std::string GetModuleName() = 0;
00141 };
00142 
00143 //=============================================================================
00144 //
00145 // Specific Hypothesis Creators are generated with a template which inherits a
00146 // generic hypothesis creator. Each creator returns an hypothesis of the type
00147 // given in the template. 
00148 //
00149 //=============================================================================
00150 template <class T> class HypothesisCreator_i: public GenericHypothesisCreator_i
00151 {
00152 public:
00153   virtual SMESH_Hypothesis_i* Create (PortableServer::POA_ptr thePOA,
00154                                       int                     theStudyId,
00155                                       ::SMESH_Gen*            theGenImpl)
00156   {
00157     return new T (thePOA, theStudyId, theGenImpl);
00158   };
00159 };
00160 
00161 #endif