2 #------------------------------------------------------------------------------
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
6 # \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd.
8 #-------------------------------------------------------------------------------
10 # This file is part of OpenFOAM.
12 # OpenFOAM is free software: you can redistribute it and/or modify it
13 # under the terms of the GNU General Public License as published by
14 # the Free Software Foundation, either version 3 of the License, or
15 # (at your option) any later version.
17 # OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
18 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 # You should have received a copy of the GNU General Public License
23 # along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
29 # Create a new standard OpenFOAM templated source file
31 #------------------------------------------------------------------------------
33 Template
="$WM_PROJECT_DIR/etc/codeTemplates/template/_TemplateTemplate"
36 while [ "$#" -ge 1 ]; do echo "$1"; shift; done
39 Usage: $Script [OPTION] <type> <ClassName> <Template arguments...>
43 * create a new standard OpenFOAM source file for templated classes
47 A ClassName starting with '-' will simply display the template
53 # this implicitly covers a lone -help
54 [ "$#" -gt 1 ] || usage
60 # for a className starting with '-' simply display the code
61 if [ "${2#-}" != "${2}" ]
81 usage
"unknown type '$1'"
86 if [ "${printOpt:-false}" = true
]
88 [ "$#" -eq 2 ] || usage
"wrong number of arguments"
95 [ "$#" -ge 3 ] || usage
"wrong number of arguments"
98 fileName
="$className$Type"
100 echo "$Script: Creating new template interface file $fileName"
101 if [ -e "$fileName" ]
103 echo " Error: file exists"
109 sed -e "s/CLASSNAME/$className/g" $Template$Type > $fileName.1
112 # process remaining (template) arguments
115 sed -e "s/TemplateClassArgument/class $tArg, TemplateClassArgument/g" \
116 -e "s/TemplateArgument/$tArg, TemplateArgument/g" \
117 $fileName.1 > $fileName.2
119 mv $fileName.2 $fileName.1
123 # remove remaining ", Template .."
124 sed -e "s/, TemplateClassArgument//g" \
125 -e "s/, TemplateArgument//g" \
126 $fileName.1 > $fileName
130 #------------------------------------------------------------------------------