Commit 9b9f7313 authored by Atlas-Software Librarian's avatar Atlas-Software Librarian Committed by Graeme Stewart
Browse files

cvs2svn commit to create tag 'AlgorithmToolSetup-00-00-07'. (AlgorithmToolSetup-00-00-07)

parent 0742cec2
This tool is meant to do the repetitive part in setting up a new Tool or a new Algorithm. It is also set up in a way to encourage clean
programming, following the conventions for software development in Atlas. Just start the shell script corresponding
to your shell (.sh or .csh), it will inquire everything it needs to know interactively. Make sure that your environment is set up properly,
the utility is working in the directory specified by $TestArea. The utility directory is for the time being assumed to be directly under the
$TestArea directory. Please make sure that the utility directory is located correctly. Once the tool is in CVS, the directory will
automatically be located correctly, when it is checked out.
What the utility does:
- If the package directory for the new algorithm specified by the user
does not yet exist, the package directory will be set up, including subdirectories.
Otherwise, the files for the new algorithm or tool will be inserted in the already existing directory.
- It creates all files necessary for the new algorithm/tool to be compiled (Although, of course, the code won't do
much at this stage.) For a new tool, named (by the user) 'NewTool', part of the package 'NewPackage' in the directory
'$TestArea/NewPath' the following files are created :
../NewPath/NewPackage:
ChangeLog
../NewPath/NewPackage/cmt:
requirements
../NewPath/NewPackage/doc:
mainpage.h
../NewPath/NewPackage/NewPackage:
INewTool.h (interface only for Tools, will not be created for algorithms)
NewTool.h
../NewPath/NewPackage/share:
../NewPath/NewPackage/src:
NewTool.cxx
../NewPath/NewPackage/src/components:
NewPackage_entries.cxx
NewPackage_load.cxx
If the new algorithm/tool is inserted into an already existing package, the ChangeLog, the requirements and the mainpage file
as well as the files in the components directory are not created. A standard entry is added to the ChangeLog.
However, the files in the components directory have to be edited by hand, when an algorithm/tool is added to an existing
package in order to make it compile.
Tools created by the utility are always derived from an Interface. The interface is always placed in the same directory
as the Tool's header file.
Martin Siebel <Martin.Siebel@CERN.ch>, May 2006
\ No newline at end of file
package AlgorithmToolSetup
author Martin Siebel <Martin.Siebel@CERN.ch>
# Description:-
#
# AlgorithmToolSetup package sets up the basic files
# for writing new Algorithms or Tools. After calling
# the setupCode shell script, all necessary information
# will be inquired interactively.
use AtlasPolicy AtlasPolicy-01-*
apply_pattern declare_scripts files="-s=../share *.csh *.h *.sh"
apply_pattern declare_runtime files="-s=../src *.templ *.txt"
\ No newline at end of file
#!/usr/local/bin/bash
#
# Basic Utility to create standard athena algorithms or tools
# M.Siebel, 05.2006 <Martin.Siebel@CERN.ch>
#
binDir=`dirname $0`
srcDir=`dirname $binDir`
#
# inquiry section
#
echo
echo
cat $srcDir/introAlgorithmToolSetup.txt
echo
echo " o-----------------------o"
echo " | Do you want to set up |"
echo " | |"
echo " | (1) a Tool |"
echo " | (2) an Algorithm |"
echo " o-----------------------o"
echo
isTool=" "
while [ "${isTool}" != "1" -a "${isTool}" != "2" ]
do
read isTool
if [ "$isTool" != "1" -a "$isTool" != "2" ]
then
echo " Please enter only '1' or '2' "
fi
done
algName=""
while [ "$algName" == "" ]
do
if [ $isTool = 1 ]
then
echo
echo " o-----------------------------o"
echo " | Please enter the TOOL NAME: |"
echo " o-----------------------------o"
echo
else
echo
echo " o----------------------------------o"
echo " | Please enter the ALGORITHM NAME: |"
echo " o----------------------------------o"
echo
fi
read algName
done
packageName=""
while [ "$packageName" == "" ]
do
echo
echo " o---------------------------------------------------o"
echo " | Please enter the PACKAGE NAME (e.g. RecExCommon): |"
echo " o---------------------------------------------------o"
echo
read packageName
done
packageDir=""
while [ "$packageDir" == "" ]
do
echo
echo " o--------------------------------------------------o"
echo " | Please enter the PACKAGE PATH beyond '/offline/' |"
echo " | and without the new package's directory |"
echo " | (e.g. Reconstruction/RecExample ): |"
echo " o--------------------------------------------------o"
echo
read packageDir
done
thisDir=`pwd`
targetDir=$thisDir/$packageDir/$packageName
if [ -d $targetDir ]
then
echo
echo " The Package $packageDir/$packageName does already exist. Do you want to insert $algName into it? (y/n)"
echo
answer=" "
while [ "$answer" != "y" -a "$answer" != "n" ]
do
read answer
if [ $answer = "y" ]
then
if [ -e ${targetDir}/${packageName}/${algName}.h ]
then
echo
echo " The file $targetDir/$packageName/$algName.h already exists. --> Cancel setup"
echo " Have a nice day ..."
exit 1
else
isInsert=1
fi
elif [ "$answer" = "n" ]
then
echo
echo " Have a nice day ... bye!"
exit 1
else
echo " Please answer only with 'y' or 'n' "
fi
done
else
echo
echo " The Package $packageDir/$packageName does not exist. Do you want to create it? (y/n)"
echo
answer=" "
while [ "$answer" != "y" -a "$answer" != "n" ]
do
read answer
if [ "$answer" = "y" ]
then
isInsert=0
elif [ "$answer" = "n" ]
then
echo
echo " Have a nice day ... bye!"
exit 1
else
echo " Please answer only with 'y' or 'n' "
fi
done
fi
answer="n"
nameSpace=""
while [ "$nameSpace" == "" -a "$answer" != "yes" ]
do
echo
echo " o--------------------------------------------------o"
echo " | Please enter the NAMESPACE (e.g. Trk,InDet,...): |"
echo " o--------------------------------------------------o"
echo
read nameSpace
if [ "$nameSpace" == "" ]
then
echo
echo " *###################################################*"
echo " # #"
echo " # W A R N I N G ! #"
echo " # #"
echo " # You did not specify a namespace for your code #"
echo " # The use of namespaces is #"
echo " # ** REQUIRED ** #"
echo " # by ATLAS C++ Coding Standards. #"
echo " # (see coding standards document, par. 2.4/NC4) #"
echo " # #"
echo " # If you are positively sure you want to #"
echo " # proceed without a namespace type yes, #"
echo " # type anything else to return and choose #"
echo " # a namespace. #"
echo " # #"
echo " *###################################################*"
echo
read answer
fi
done
authorName=""
while [ "$authorName" == "" ]
do
echo
echo " o--------------------------o"
echo " | Please enter YOUR NAME: |"
echo " o--------------------------o"
echo
read authorName
done
authorMail=""
while [ "$authorMail" == "" ]
do
echo
echo " o-----------------------------------o"
echo " | Please enter YOUR E-MAIL ADDRESS: |"
echo " o-----------------------------------o"
echo
read authorMail
done
#
# create directories
#
if [ $isInsert -eq 0 ]
then
echo " Setting up directory"
mkdir -p $targetDir
mkdir -p $targetDir/$packageName
mkdir -p $targetDir/src
mkdir -p $targetDir/src/components
mkdir -p $targetDir/cmt
mkdir -p $targetDir/share
mkdir -p $targetDir/doc
fi
#
# copy files
#
echo " Setting up basic files"
if [ $isTool -eq 1 ]
then
type="tool"
cp $srcDir/interface_tool.templ $targetDir/$packageName/I${algName}.h
else
type="alg"
fi
cp $srcDir/source_$type.templ $targetDir/src/$algName.cxx
cp $srcDir/header_$type.templ $targetDir/$packageName/$algName.h
if [ $isInsert -eq 0 ]
then
cp $srcDir/requirements.templ $targetDir/cmt/requirements
cp $srcDir/version.templ $targetDir/cmt/version
cp $srcDir/mainpage.templ $targetDir/doc/mainpage.h
cp $srcDir/entries_$type.templ $targetDir/src/components/${packageName}_entries.cxx
cp $srcDir/load.templ $targetDir/src/components/${packageName}_load.cxx
cp $srcDir/ChangeLog.templ $targetDir/ChangeLog
else
# Add to ChangeLog
mv $targetDir/ChangeLog $targetDir/ChangeLog.tmp
cp $srcDir/ChangeLog.templ $targetDir/ChangeLog
cat $targetDir/ChangeLog.tmp >> $targetDir/ChangeLog
rm -f $targetDir/ChangeLog.tmp
fi
#
# replace keys
#
cppKey=`echo "${nameSpace}${algName}" | tr "[:lower:]" "[:upper:]"`
today=`date +%F`
fileList="$targetDir/src/$algName.cxx $targetDir/$packageName/$algName.h $targetDir/ChangeLog"
if [ $isInsert -eq 0 ]
then
fileList="$fileList $targetDir/cmt/requirements $targetDir/cmt/version.cmt $targetDir/doc/mainpage.h $targetDir/src/components/${packageName}_entries.cxx $targetDir/src/components/${packageName}_load.cxx"
fi
if [ $isTool -eq 1 ]
then
fileList="$fileList $targetDir/$packageName/I${algName}.h"
fi
echo " Editing files: " $fileList
for file in $fileList
do
cat $file |sed s/@algName@/$algName/g > ${file}.tmp ; mv -f ${file}.tmp $file
cat $file |sed s/@packageName@/$packageName/g > ${file}.tmp ; mv -f ${file}.tmp $file
cat $file |sed s/@authorName@/"$authorName"/g > ${file}.tmp ; mv -f ${file}.tmp $file
cat $file |sed s/@CppKey@/$cppKey/g > ${file}.tmp ; mv -f ${file}.tmp $file
if [ "$nameSpace" != "" ]
then
cat $file |sed s/@nameSpace@/$nameSpace/g > ${file}.tmp ; mv -f ${file}.tmp $file
else
cat $file |sed s/@nameSpace@::/" "/g > ${file}.tmp ; mv -f ${file}.tmp $file
cat $file |sed 's#namespace @nameSpace@#// No NameSpace selected#g' > ${file}.tmp ; mv -f ${file}.tmp $file
fi
cat $file |sed s/@authorMail@/"$authorMail"/g > ${file}.tmp ; mv -f ${file}.tmp $file
cat $file |sed s/@date@/$today/g > ${file}.tmp ; mv -f ${file}.tmp $file
cat $file |sed s/@algName@/$algName/g > ${file}.tmp ; mv -f ${file}.tmp $file
done
if [ "$nameSpace" == "" ]
then
if [ $isTool -eq 1 ]
then
file="$targetDir/$packageName/$algName.h"
echo "making adjustments not to use a namespace in $file"
cat $file |sed '52d' > ${file}.tmp ; mv -f ${file}.tmp $file
cat $file |sed '16d' > ${file}.tmp ; mv -f ${file}.tmp $file
cat $file |sed '16,50s/^ //g' > ${file}.tmp ; mv -f ${file}.tmp $file
file="$targetDir/$packageName/I$algName.h"
echo "making adjustments not to use a namespace in $file"
cat $file |sed '29d' > ${file}.tmp ; mv -f ${file}.tmp $file
cat $file |sed '11d' > ${file}.tmp ; mv -f ${file}.tmp $file
cat $file |sed '11,27s/^ //g' > ${file}.tmp ; mv -f ${file}.tmp $file
file="$targetDir/src/components/${packageName}_entries.cxx"
echo "making adjustments not to use a namespace in $file"
cat $file |sed '4c DECLARE_TOOL_FACTORY( @algName@ )' > ${file}.tmp ; mv -f ${file}.tmp $file
cat $file |sed '8c DECLARE_TOOL( @algName@ )' > ${file}.tmp ; mv -f ${file}.tmp $file
cat $file |sed s/@algName@/$algName/g > ${file}.tmp ; mv -f ${file}.tmp $file
else
file="$targetDir/$packageName/$algName.h"
echo "making adjustments not to use a namespace in $file"
cat $file |sed '59d' > ${file}.tmp ; mv -f ${file}.tmp $file
cat $file |sed '18d' > ${file}.tmp ; mv -f ${file}.tmp $file
cat $file |sed '18,57s/^ //g' > ${file}.tmp ; mv -f ${file}.tmp $file
file="$targetDir/src/components/${packageName}_entries.cxx"
echo "making adjustments not to use a namespace in $file"
cat $file |sed '4c DECLARE_ALGORITHM_FACTORY( @algName@ )' > ${file}.tmp ; mv -f ${file}.tmp $file
cat $file |sed '7c DECLARE_ALGORITHM( @algName@ )' > ${file}.tmp ; mv -f ${file}.tmp $file
cat $file |sed s/@algName@/$algName/g > ${file}.tmp ; mv -f ${file}.tmp $file
fi
fi
#
# Printout Goodbye
#
if [ $isInsert -eq 1 ]
then
cat $srcDir/exitAlgorithmToolSetup_insert.txt
else
cat $srcDir/exitAlgorithmToolSetup.txt
fi
This tool is meant to do the repetitive part in setting up a new Tool or a new Algorithm. It is also set up in a way to encourage clean
programming, following the conventions for software development in Atlas. Just start the shell script corresponding
to your shell (.sh or .csh), it will inquire everything it needs to know interactively. Make sure that your environment is set up properly,
the utility is working in the directory specified by $TestArea. The utility directory is for the time being assumed to be directly under the
$TestArea directory. Please make sure that the utility directory is located correctly. Once the tool is in CVS, the directory will
automatically be located correctly, when it is checked out.
What the utility does:
- If the package directory for the new algorithm specified by the user
does not yet exist, the package directory will be set up, including subdirectories.
Otherwise, the files for the new algorithm or tool will be inserted in the already existing directory.
- It creates all files necessary for the new algorithm/tool to be compiled (Although, of course, the code won't do
much at this stage.) For a new tool, named (by the user) 'NewTool', part of the package 'NewPackage' in the directory
'$TestArea/NewPath' the following files are created :
../NewPath/NewPackage:
ChangeLog
../NewPath/NewPackage/cmt:
requirements
../NewPath/NewPackage/doc:
mainpage.h
../NewPath/NewPackage/NewPackage:
INewTool.h (interface only for Tools, will not be created for algorithms)
NewTool.h
../NewPath/NewPackage/share:
../NewPath/NewPackage/src:
NewTool.cxx
../NewPath/NewPackage/src/components:
NewPackage_entries.cxx
NewPackage_load.cxx
If the new algorithm/tool is inserted into an already existing package, the ChangeLog, the requirements and the mainpage file
as well as the files in the components directory are not created. A standard entry is added to the ChangeLog.
However, the files in the components directory have to be edited by hand, when an algorithm/tool is added to an existing
package in order to make it compile.
Tools created by the utility are always derived from an Interface. The interface is always placed in the same directory
as the Tool's header file.
Martin Siebel <Martin.Siebel@CERN.ch>, May 2006
\ No newline at end of file
@date@ @authorName@ <@authorMail@>
Setup of @algName@ (empty) using SetupUtility
#include "GaudiKernel/DeclareFactoryEntries.h"
#include "@packageName@/@algName@.h"
DECLARE_NAMESPACE_ALGORITHM_FACTORY( @nameSpace@ , @algName@ )
DECLARE_FACTORY_ENTRIES( @packageName@ ) {
DECLARE_NAMESPACE_ALGORITHM( @nameSpace@ , @algName@ )
}
#include "GaudiKernel/DeclareFactoryEntries.h"
#include "@packageName@/@algName@.h"
DECLARE_NAMESPACE_TOOL_FACTORY( @nameSpace@, @algName@ )
DECLARE_FACTORY_ENTRIES( @packageName@ )
{
DECLARE_NAMESPACE_TOOL( @nameSpace@, @algName@ )
}
o--------------------------------------------------------o
| The empty files for the Algorithm/Tool are now set up |
| and ready to compile. Remember to type 'cmt config' |
| before 'make' |
| |
| Please do not forget to remove the standard comments |
| from the header file and the doc/mainpage.h file and |
| to replace them with meaningful comments. |
| (Don't forget, your name is already there ... ;-) ) |
| |
o--------------------------------------------------------o
o--------------------------------------------------------o
| The empty files for the Algorithm/Tool are now set up. |
| You still have to add your new Algorithm or Tool to |
| the files in src/components. |
| After that they are ready to compile. |
| |
| Please do not forget to remove the standard comments |
| from the header file and the doc/mainpage.h file and |
| to replace them with meaningful comments. |
| (Don't forget, your name is already there ... ;-) ) |
| |
o--------------------------------------------------------o
///////////////////////////////////////////////////////////////////
// @algName@.h, (c) ATLAS Detector software
///////////////////////////////////////////////////////////////////
#ifndef @CppKey@_H
#define @CppKey@_H
// Gaudi includes
#include "GaudiKernel/Algorithm.h"
#include "GaudiKernel/MsgStream.h"
#include <string>
class AtlasDetectorID;
class Identifier;
class StoreGateSvc;
namespace @nameSpace@
{
/** @class @algName@
This is for the Doxygen-Documentation.
Please delete these lines and fill in information about
the Algorithm!
Please precede every member function declaration with a
short Doxygen comment stating the purpose of this function.
@author @authorName@ <@authorMail@>
*/
class @algName@ : public Algorithm
{
public:
/** Standard Athena-Algorithm Constructor */
@algName@(const std::string& name, ISvcLocator* pSvcLocator);
/** Default Destructor */
~@algName@();
/** standard Athena-Algorithm method */
StatusCode initialize();
/** standard Athena-Algorithm method */
StatusCode execute();
/** standard Athena-Algorithm method */
StatusCode finalize();
private:
/** class member version of retrieving MsgStream */
mutable MsgStream m_log;
/** class member version of retrieving StoreGate */
StoreGateSvc* m_sgSvc;
/** member variables for algorithm properties: */
// int/double/bool m_propertyName;
};
} // end of namespace
#endif
///////////////////////////////////////////////////////////////////
// @algName@.h, (c) ATLAS Detector software
///////////////////////////////////////////////////////////////////
#ifndef @CppKey@_H
#define @CppKey@_H
#include "GaudiKernel/AlgTool.h"
#include "GaudiKernel/MsgStream.h"
#include "@packageName@/I@algName@.h"
class AtlasDetectorID;
class Identifier;
namespace @nameSpace@
{
/** @class @algName@
This is for the Doxygen-Documentation.
Please delete these lines and fill in information about
the Algorithm!
Please precede every member function declaration with a
short Doxygen comment stating the purpose of this function.
@author @authorName@ <@authorMail@>
*/
class @algName@ : virtual public I@algName@, public AlgTool
{
public:
@algName@(const std::string&,const std::string&,const IInterface*);
/** default destructor */
virtual ~@algName@ ();
/** standard Athena-Algorithm method */
virtual StatusCode initialize();
/** standard Athena-Algorithm method */
virtual StatusCode finalize ();
private:
/** class member version of retrieving MsgStream */
mutable MsgStream m_log;
/** member variables for algorithm properties: */
// int/double/bool m_propertyName;
};
} // end of namespace
#endif
///////////////////////////////////////////////////////////////////
// I@algName@.h, (c) ATLAS Detector software
///////////////////////////////////////////////////////////////////
#ifndef I@CppKey@_H
#define I@CppKey@_H
#include "GaudiKernel/IAlgTool.h"
namespace @nameSpace@
{
static const InterfaceID IID_I@algName@("@nameSpace@::I@algName@", 1, 0);
class I@algName@ : virtual public IAlgTool {
public:
static const InterfaceID& interfaceID( ) ;
// enter declaration of your interface-defining member functions here
};
inline const InterfaceID& @nameSpace@::I@algName@::interfaceID()
{
return IID_I@algName@;
}
} // end of namespace
#endif
o--------------------------------------------------------o
| |
| This tool sets up the basic files needed to write new |