Mercurial > fem-fenics-eugenio
comparison inst/private/generate_mf_header.m @ 260:1e2a9be8083a
Support template dolfin::MeshFunction
author | Eugenio Gianniti <eugenio.gianniti@mail.polimi.it> |
---|---|
date | Wed, 06 Aug 2014 19:52:03 +0200 |
parents | |
children | f22588ae37af |
comparison
equal
deleted
inserted
replaced
259:598c5e9e0a9e | 260:1e2a9be8083a |
---|---|
1 ## Copyright (C) 2014 Eugenio Gianniti <eugenio.gianniti@mail.polimi.it> | |
2 ## | |
3 ## This program is free software; you can redistribute it and/or modify it under | |
4 ## the terms of the GNU General Public License as published by the Free Software | |
5 ## Foundation; either version 3 of the License, or (at your option) any later | |
6 ## version. | |
7 ## | |
8 ## This program is distributed in the hope that it will be useful, but WITHOUT | |
9 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
10 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
11 ## details. | |
12 ## | |
13 ## You should have received a copy of the GNU General Public License along with | |
14 ## this program; if not, see <http://www.gnu.org/licenses/>. | |
15 | |
16 | |
17 ## -*- texinfo -*- | |
18 ## function for internal usage only | |
19 ## @end deftypefn | |
20 | |
21 function output = generate_mf_header (typename) | |
22 | |
23 STRING ="\n\ | |
24 #ifndef _MESHFUNCTION_@@TYPENAME@@_OCTAVE_\n\ | |
25 #define _MESHFUNCTION_@@TYPENAME@@_OCTAVE_\n\ | |
26 \n\ | |
27 #include <dolfin.h>\n\ | |
28 #include <octave/oct.h>\n\ | |
29 #include <fem-fenics/dolfin_compat.h>\n\ | |
30 \n\ | |
31 class meshfunction_@@TYPENAME@@ : public octave_base_value\n\ | |
32 {\n\ | |
33 public:\n\ | |
34 \n\ | |
35 meshfunction_@@TYPENAME@@ (void)\n\ | |
36 : octave_base_value () {}\n\ | |
37 \n\ | |
38 meshfunction_@@TYPENAME@@ (dolfin::MeshFunction <@@TYPENAME@@> const & _mf)\n\ | |
39 : octave_base_value (), pmf (new dolfin::MeshFunction <@@TYPENAME@@> (_mf)) {}\n\ | |
40 \n\ | |
41 meshfunction_@@TYPENAME@@ (SHARED_PTR <dolfin::Mesh const> mesh,\n\ | |
42 std::string const & filename)\n\ | |
43 : octave_base_value (),\n\ | |
44 pmf (new dolfin::MeshFunction <@@TYPENAME@@> (mesh, filename)) {}\n\ | |
45 \n\ | |
46 bool\n\ | |
47 is_defined (void) const\n\ | |
48 { return true; }\n\ | |
49 \n\ | |
50 void\n\ | |
51 print (std::ostream& os, bool pr_as_read_syntax = false) const\n\ | |
52 { os << ""MeshFunction <@@TYPENAME@@>: ""\n\ | |
53 << get_pmf ()->str (false) << std::endl; }\n\ | |
54 \n\ | |
55 dolfin::MeshFunction <@@TYPENAME@@> const &\n\ | |
56 get_mf (void) const\n\ | |
57 { return *pmf; }\n\ | |
58 \n\ | |
59 SHARED_PTR <dolfin::MeshFunction <@@TYPENAME@@> const> const &\n\ | |
60 get_pmf (void) const\n\ | |
61 { return pmf; }\n\ | |
62 \n\ | |
63 private:\n\ | |
64 \n\ | |
65 SHARED_PTR <dolfin::MeshFunction <@@TYPENAME@@> const> pmf;\n\ | |
66 \n\ | |
67 DECLARE_OCTAVE_ALLOCATOR;\n\ | |
68 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA;\n\ | |
69 };\n\ | |
70 \n\ | |
71 static bool meshfunction_@@TYPENAME@@_type_loaded = false;\n\ | |
72 \n\ | |
73 DEFINE_OCTAVE_ALLOCATOR (meshfunction_@@TYPENAME@@);\n\ | |
74 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (meshfunction_@@TYPENAME@@,\n\ | |
75 ""meshfunction_@@TYPENAME@@"", ""meshfunction_@@TYPENAME@@"");\n\ | |
76 \n\ | |
77 #endif"; | |
78 | |
79 STRING = strrep (STRING, "@@TYPENAME@@", typename); | |
80 | |
81 fid = fopen (["meshfunction_", typename, ".h"], "w"); | |
82 if (is_valid_file_id (fid)) | |
83 fputs (fid, STRING); | |
84 output = fclose (fid); | |
85 else | |
86 error ("cannot open file"); | |
87 output = 1; | |
88 endif | |
89 | |
90 endfunction |