#! /bin/sh

#
# $Id: Hash_Map_Manager_Helper 80826 2008-03-04 14:51:23Z wotte $
#

#
# This script uses Hash_Map_Manager.pl.
#

#
# This script helps in fixing the template instantiations changes
# required by the new design of ACE_Hash_Map_Manager.  
#
# Note that this script is not a 100% fool proof: 
#
# (a) It uses commas to delimit the types in ACE_Hash_Map_Manager<X,
# Y, Z>.  If X, Y, or Z are complicated types containing commas (e.g.,
# T<a, b>), this script will not work. Also, all template parameters
# are assumed to be on the same line.
#
# In the case where this script will not work, here are the cookbook,
# do-it-yourself instructions: 
#
# ACE_Hash_Map_Entry<X, Y>
#
# changes to:
#
# ACE_Hash_Map_Entry<X, Y>
# ACE_Hash<X>
# ACE_Equal_To<X>
#
#
# ACE_Hash_Map_Iterator_Base<X, Y, Z>
#
# changes to:
#
# ACE_Hash_Map_Iterator_Base_Ex<X, Y, ACE_Hash<X>, ACE_Equal_To<X>, Z>
#
#
# ACE_Hash_Map_Manager<X, Y, Z>
#
# changes to:
#
# ACE_Hash_Map_Manager<X, Y, Z>
# ACE_Hash_Map_Manager_Ex<X, Y, ACE_Hash<X>, ACE_Equal_To<X>, Z>
#
#
# ACE_Hash_Map_Iterator<X, Y, Z>
#
# changes to:
#
# ACE_Hash_Map_Iterator<X, Y, Z>
# ACE_Hash_Map_Iterator_Ex<X, Y, ACE_Hash<X>, ACE_Equal_To<X>, Z>
#
#
# ACE_Hash_Map_Reverse_Iterator<X, Y, Z>
#
# changes to:
#
# ACE_Hash_Map_Reverse_Iterator<X, Y, Z>
# ACE_Hash_Map_Reverse_Iterator_Ex<X, Y, ACE_Hash<X>, ACE_Equal_To<X>, Z>


# (b) The second problem is for g++ users (version lower than
# 2.8). g++ is broken such that if you explicitly instantiate
# templates, it will ignore template specialization.  Therefore if you
# are using the template instantiation provided in ACE for ACE_Hash
# and ACE_Equal_To, don't instantiate those templates.

for file in `find . -type f \( -name "*.i" -o -name "*.h" -o -name "*.cpp" \) -print | xargs egrep -l "template[ \t]*class[ \t]*ACE_Hash_Map_Manager"`
do
    echo Fixing template instantiations in $file
    perl $ACE_ROOT/bin/Hash_Map_Manager.pl $file > $file.new
    mv $file.new $file
done
