#! /bin/bash
#
#    file: FilterCollector
#    Project: miniGrail
#    License: LGPLv2.1 http://www.gnu.org/licenses/lgpl-2.1.html
#
#    Created by: by Rui Zhou
#   Maintainer: Cezar Campeanu <ccampeanu@upei.ca>
#
#   Modified by Brandon Stewart July 2015
#   - Added namespace minigrail
#
#This collects the filters

 rm -rf Filters.h

 echo "/* " > Filters.h
 echo " file: Filters.h " >> Filters.h
 echo " Project: miniGrail   " >> Filters.h
 echo " License: LGPLv2.1 http://www.gnu.org/licenses/lgpl-2.1.html " >> Filters.h
 echo " Created by: by Rui Zhou " >> Filters.h
 echo " Maintainer: Cezar Campeanu <ccampeanu@upei.ca> " >> Filters.h
 echo "                     ">> Filters.h
 echo "*/" >> Filters.h
 echo "                     ">> Filters.h

 echo "//This piece of code is generated by the script FilterCollector" >>Filters.h;

 for i in `ls */*.h`;
 do echo "#include \"$i\"" >>Filters.h;
 done

 for i in `ls */*.cpp`;
 do echo "#include \"$i\"" >>Filters.h;
 done


echo "namespace minigrail" >>Filters.h;
echo "{" >>Filters.h;
 #add the dictionary of filters
 echo "map<string,void (*)()> mG_filters;" >>Filters.h;

 #the function which loads all the filters
 echo "void load_filters()"  >>Filters.h;
 echo "{" >>Filters.h;

# echo "cout <<\"start mG-filters\n\";" >>Filters.h;

 #add the filter to the dictionary
 for i in `ls */*.h`;
 do ii="${i/#*\//}"
 echo  "mG_filters[\"${ii/%.h/}\"]=${ii/%.h/};" >>Filters.h;
 done

# echo "cout <<\"ok mG-filters\n\";" >>Filters.h;

 echo "}" >>Filters.h;


 echo "} //namespace minigrail" >>Filters.h;
