[Bio] / SoftRelTools / newModule Repository:
ViewVC logotype

View of /SoftRelTools/newModule

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (download) (annotate) (vendor branch)
Fri Dec 20 20:20:56 2002 UTC (15 years, 11 months ago) by efrank
Branch: BobJacobsen, MAIN
CVS Tags: Head-20-Dec-2002, HEAD
Changes since 1.1: +0 -0 lines

Import from SLAC.  Not sure this is going to serve us, but there is a ton
of experience in this package.

#!/bin/sh
#
# newModule: Make a new module.
#
# Takes the name of a package and a name to be used for a new module
# and creates the skeleton for a new AppModule of that name.  The
# output is a .hh file and a .cc file which may be used right away
# without having to hack out the old names from a prototype and stick
# in new names.
#
# Usage:
#    newModule <packageName> <moduleName>
#
# where all arguments shown are required.  This will create files
# <moduleName>.hh and <moduleName>.cc in the current directory. 
# <packageName> will be used in the .cc file via
#    #include "/<packageName>/<moduleName>.hh"
#
# Environment:
#	Software developed for the BaBar Detector at the SLAC B-Factory.
#
# Author List:
#    Ed Frank             University of Pennsylvania
#
# Copyright Information:
#   Copyright (C) 199_
#
# Bugs:
#   -The output is based upon prototypes in the Framework package.
#    The search order for test release/release, etc. for locating
#    Framework probably isn't so good.
###############################################################################

#-> constants
#   Name of the file that we put through sed and the name of
#   the package that holds it.

    debug=0	
    PROTOCC=Framework/src/APPModule.cc.proto
    PROTOHH=Framework/Framework/APPModule.hh.proto
    protocc=
    protohh=

    myname="newModule"

    moduleName=""
    packageName=""

#-> parse arguments
    set -- `getopt t $*`
    if [ $? = 0 ]; then
	while [ $1 != -- ]
	do
	    case $1 in
		-t) debug=1; set -x;;
	    esac
	    shift 
	done
	shift
    fi

#-> check for correct number of arguments
    if [ "$#" -ne 2 ]; then
	echo "Usage:  $myname <packageName>  <moduleName>"
	exit 2
    fi

    packageName=$1
    moduleName=$2

###############################################################
#++ Make sure the script is run from a test release.

    if [ ! -r .current ]; then
        echo "$myname must be run from a test release."
	exit 1
    fi

###############################################################
#++ Make sure the package is already there

    if [ ! -d ./$packageName ]; then
        echo "$packageName does not exist. Do addpkg $packageName first"
	exit 1
    fi

###############################################################
#++ Find the prototype in Framework.  Order of search is
#   1. ./Framework
#   2. ./PARENT/Framework
#   3. $BFDIST/releases/`cat .current`/Framework

    if [ -r ./$PROTOHH ]; then
	protohh=./$PROTOHH
    elif [ -r ./PARENT/$PROTOHH ]; then
	protohh=./PARENT/$PROTOHH
    elif [ -r $BFDIST/releases/`cat .current`/$PROTOHH ]; then
	protohh=$BFDIST/releases/`cat .current`/$PROTOHH
    else
	echo $myname:  could not find prototype file: $PROTOHH
	exit 2
    fi

    if [ -r ./$PROTOCC ]; then
	protocc=./$PROTOCC
    elif [ -r ./PARENT/$PROTOCC ]; then
	protocc=./PARENT/$PROTOCC
    elif [ -r $BFDIST/releases/`cat .current`/$PROTOCC ]; then
	protohh=$BFDIST/releases/`cat .current`/$PROTOCC
    else
	echo $myname:  could not find prototype file: $PROTOCC
	exit 2
    fi

###############################################################
#++ Check if .hh or .cc files already exist.

    if [ -f $packageName/$moduleName.hh ]; then
	echo $myname:  $packageName/$moduleName.hh already exists.  Aborting.
	exit 2
    fi

    if [ -f $packageName/$moduleName.cc ]; then
	echo $myname:  $packageName/$moduleName.cc already exists.  Aborting.
	exit 2
    fi

###############################################################
#++  Make the thing already!
#    replace keyword 'PACKAGE' and 'ModuleName' in APPModuleProto(.hh .cc)

    upper=`echo $moduleName | tr a-z A-Z`

    echo Creating $packageName/$moduleName.hh
    sed -e "s/ModuleName/$moduleName/g" -e "s/MODULENAME/$upper/g" $protohh >  $packageName/$moduleName.hh

    echo Creating $packageName/$moduleName.cc
    sed -e "s/ModuleName/$moduleName/g" -e "s/MODULENAME/$upper/g" -e "s/PACKAGE/$packageName/g" $protocc >  $packageName/$moduleName.cc

###############################################################
#++ Done at last
#

    exit 0

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3