Salome HOME
Copyright update: 2016
[modules/hexablock.git] / src / HEXABLOCK / HexLaw.hxx
index f274a3301d492abb526d0ddd6fb8fc0ff2000163..b079aafbd6e23713311be67920ac8124bcc49aaa 100755 (executable)
@@ -1,17 +1,37 @@
 
 // class : Au nom de la loi
 
-#ifndef __LAW_H
-#define __LAW_H
+// Copyright (C) 2009-2016  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef __LAW_H_
+#define __LAW_H_
 
+#include "HexEltBase.hxx"
 #include "HexXmlWriter.hxx"
 
 BEGIN_NAMESPACE_HEXA
 
-class Law 
+class HexaExport Law : public EltBase  
 {
 public:
    const char* getName ()          { return law_name.c_str() ; }
+   char* getNextName  (pchar buffer);
    int     getNodes ()             { return nbr_nodes ; }
    double  getCoefficient ()       { return law_coefficient ; }
    KindLaw getKind ()              { return law_type ;  }
@@ -19,26 +39,22 @@ public:
    int     setNodes (int  nbre);
    int     setCoefficient (double coeff);
    void    setKind (KindLaw type)  { law_type = type ;  }
-   int     setName (const char* nom);
+   void    setKind (cpchar  type);
+   int     setName (cpchar  nom);
 
-public:
-    Law (cpchar name, int nbnodes);
-    void saveXml (XmlWriter& xml);
+    Law (Document* dad, cpchar name, int nbnodes);
+    Law (Law* other);
+    void saveXml (XmlWriter* xml);
 
 private:
+    int law_id;
+    static int last_law_id;
     std::string law_name;
     int         nbr_nodes;
     KindLaw     law_type;
     double      law_coefficient;
 };
-// ================================================== Constructeur
-inline Law::Law (cpchar name, int nbnodes)
-{
-   nbr_nodes = nbnodes;
-   law_name  = name;
-   law_type  = Uniform;
-   law_coefficient = 0.0;
-}
+
 // ================================================== setNodes
 inline int Law::setNodes (int  nbre)
 {
@@ -52,22 +68,31 @@ inline int Law::setCoefficient (double coeff)
    return HOK;
 }
 // ================================================== setName
-inline int Law::setName (const char* name)
+inline int Law::setName (cpchar name)
 {
    law_name = name;
    return HOK;
 }
 // ================================================== saveXml
-inline void Law::saveXml (XmlWriter& xml)
+inline void Law::saveXml (XmlWriter* xml)
 {
    cpchar kind_law [] = { "Uniform", "Arithmetic", "Geometric" };
 
-   xml.openMark     ("Law");
-   xml.addAttribute ("id",          getName ());
-   xml.addAttribute ("kind",    kind_law [law_type]);
-   xml.addAttribute ("nodes",   nbr_nodes);
-   xml.addAttribute ("coeff", law_coefficient);
-   xml.closeMark ();
+   xml->openMark     ("Law");
+   xml->addAttribute ("id",          getName ());
+   xml->addAttribute ("kind",    kind_law [law_type]);
+   xml->addAttribute ("nodes",   nbr_nodes);
+   xml->addAttribute ("coeff", law_coefficient);
+   xml->closeMark ();
 }
+// ================================================== setKind
+inline void Law::setKind (cpchar type)
+{
+#define VerifKind(t,k) if (strcmp(t,#k)==0) law_type = k
+   VerifKind (type, Uniform);
+   VerifKind (type, Arithmetic);
+   VerifKind (type, Geometric);
+}
+
 END_NAMESPACE_HEXA
 #endif