#!/bin/csh -f
#------------------------------------------------------------------------------
# =========                 |
# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
#  \\    /   O peration     |
#   \\  /    A nd           | Copyright (C) 1991-2005 OpenCFD Ltd.
#    \\/     M anipulation  |
#-------------------------------------------------------------------------------
# License
#     This file is part of OpenFOAM.
#
#     OpenFOAM is free software; you can redistribute it and/or modify it
#     under the terms of the GNU General Public License as published by the
#     Free Software Foundation; either version 2 of the License, or (at your
#     option) any later version.
#
#     OpenFOAM 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 General Public License
#     for more details.
#
#     You should have received a copy of the GNU General Public License
#     along with OpenFOAM; if not, write to the Free Software Foundation,
#     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# Script
#     foamNew
#
# Description
#     Create a new standard foam source file
#
#------------------------------------------------------------------------------

if ( $# != 2 ) then
    echo $0 : wrong number of arguments, expected 2
    echo Usage: $0 "<type [H|C|I|IO|App]> <class name>"
    exit 1
endif

if ( $1 == "H" ) then
    set template = foamTemplate
    set ext = 
    set type = H
else if ( $1 == "C" ) then
    set template = foamTemplate
    set ext = 
    set type = C
else if ( $1 == "I" ) then
    set template = foamTemplateI
    set ext = I
    set type = H
else if ( $1 == "IO" ) then
    set template = foamTemplateIO
    set ext = IO
    set type = C
else if ( $1 == "App" ) then
    set template = foamAppTemplate
    set ext = 
    set type = C
else if ( $1 == "cfg" ) then
    set template = foamUtilTemplate
    set ext = 
    set type = cfg
endif

set fileName = $2$ext.$type

if (-e $fileName) then

    echo "Cannot make " $fileName ", file file already exists"
    exit 1

endif

echo $0 : Creating new interface file $fileName

cp $WM_PROJECT_DIR/bin/foamTemplates/$template.$type $fileName

sed s/className/$2/g $fileName > temp.$$

mv temp.$$ $fileName

#------------------------------------------------------------------------------
