diff inst/private/generate_mf_header.m @ 261:f22588ae37af

Improve template meshfunction implementation * inst/import_meshfunction_type.m: provide to the auxiliary functions a type name and a valid identifier * inst/private/generate_mf_*.m: add space before closing angle bracket to avoid parse errors
author Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
date Thu, 07 Aug 2014 11:13:54 +0200
parents 1e2a9be8083a
children 61830a4f9ab9
line wrap: on
line diff
--- a/inst/private/generate_mf_header.m	Wed Aug 06 19:52:03 2014 +0200
+++ b/inst/private/generate_mf_header.m	Thu Aug 07 11:13:54 2014 +0200
@@ -18,30 +18,30 @@
 ## function for internal usage only
 ## @end deftypefn
 
-function output = generate_mf_header (typename)
+function output = generate_mf_header (typename, label)
 
 STRING ="\n\
-#ifndef _MESHFUNCTION_@@TYPENAME@@_OCTAVE_\n\
-#define _MESHFUNCTION_@@TYPENAME@@_OCTAVE_\n\
+#ifndef _MESHFUNCTION_@@LABEL@@_OCTAVE_\n\
+#define _MESHFUNCTION_@@LABEL@@_OCTAVE_\n\
 \n\
 #include <dolfin.h>\n\
 #include <octave/oct.h>\n\
 #include <fem-fenics/dolfin_compat.h>\n\
 \n\
-class meshfunction_@@TYPENAME@@ : public octave_base_value\n\
+class meshfunction_@@LABEL@@ : public octave_base_value\n\
 {\n\
   public:\n\
 \n\
-  meshfunction_@@TYPENAME@@ (void)\n\
+  meshfunction_@@LABEL@@ (void)\n\
     : octave_base_value () {}\n\
 \n\
-  meshfunction_@@TYPENAME@@ (dolfin::MeshFunction <@@TYPENAME@@> const & _mf)\n\
-    : octave_base_value (), pmf (new dolfin::MeshFunction <@@TYPENAME@@> (_mf)) {}\n\
+  meshfunction_@@LABEL@@ (dolfin::MeshFunction <@@TYPENAME@@ > const & _mf)\n\
+    : octave_base_value (), pmf (new dolfin::MeshFunction <@@TYPENAME@@ > (_mf)) {}\n\
 \n\
-  meshfunction_@@TYPENAME@@ (SHARED_PTR <dolfin::Mesh const> mesh,\n\
+  meshfunction_@@LABEL@@ (SHARED_PTR <dolfin::Mesh const> mesh,\n\
                              std::string const & filename)\n\
     : octave_base_value (),\n\
-      pmf (new dolfin::MeshFunction <@@TYPENAME@@> (mesh, filename)) {}\n\
+      pmf (new dolfin::MeshFunction <@@TYPENAME@@ > (mesh, filename)) {}\n\
 \n\
   bool\n\
   is_defined (void) const\n\
@@ -49,36 +49,42 @@
 \n\
   void\n\
   print (std::ostream& os, bool pr_as_read_syntax = false) const\n\
-    { os << ""MeshFunction <@@TYPENAME@@>: ""\n\
-         << get_pmf ()->str (false) << std::endl; }\n\
+    { os << ""MeshFunction <@@TYPENAME@@ >: ""\n\
+         << get_pmf ()->str (@@VERBOSE@@) << std::endl; }\n\
 \n\
-  dolfin::MeshFunction <@@TYPENAME@@> const &\n\
+  dolfin::MeshFunction <@@TYPENAME@@ > const &\n\
   get_mf (void) const\n\
     { return *pmf; }\n\
 \n\
-  SHARED_PTR <dolfin::MeshFunction <@@TYPENAME@@> const> const &\n\
+  SHARED_PTR <dolfin::MeshFunction <@@TYPENAME@@ > const> const &\n\
   get_pmf (void) const\n\
     { return pmf; }\n\
 \n\
   private:\n\
 \n\
-  SHARED_PTR <dolfin::MeshFunction <@@TYPENAME@@> const> pmf;\n\
+  SHARED_PTR <dolfin::MeshFunction <@@TYPENAME@@ > const> pmf;\n\
 \n\
   DECLARE_OCTAVE_ALLOCATOR;\n\
   DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA;\n\
 };\n\
 \n\
-static bool meshfunction_@@TYPENAME@@_type_loaded = false;\n\
+static bool meshfunction_@@LABEL@@_type_loaded = false;\n\
 \n\
-DEFINE_OCTAVE_ALLOCATOR (meshfunction_@@TYPENAME@@);\n\
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (meshfunction_@@TYPENAME@@,\n\
-""meshfunction_@@TYPENAME@@"", ""meshfunction_@@TYPENAME@@"");\n\
+DEFINE_OCTAVE_ALLOCATOR (meshfunction_@@LABEL@@);\n\
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (meshfunction_@@LABEL@@,\n\
+""meshfunction_@@LABEL@@"", ""meshfunction_@@LABEL@@"");\n\
 \n\
 #endif";
 
-STRING =  strrep (STRING, "@@TYPENAME@@", typename);
+STRING = strrep (STRING, "@@TYPENAME@@", typename);
+STRING = strrep (STRING, "@@LABEL@@", label);
+verbose = "false";
+if (strcmp (typename, "double"))
+  verbose = "true";
+endif
+STRING = strrep (STRING, "@@VERBOSE@@", verbose);
 
-fid = fopen (["meshfunction_", typename, ".h"], "w");
+fid = fopen (["meshfunction_", label, ".h"], "w");
 if (is_valid_file_id (fid))
   fputs (fid, STRING);
   output = fclose (fid);