Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

generate_TemplateGroups.cpp

Go to the documentation of this file.
00001 /* ImLib3D
00002  * Copyright (c) 2001, ULP-IPB Strasbourg.
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or (at
00007  * your option) any later version.
00008  * 
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * General Public License for more details.
00013  * 
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017  */
00019 #include<ImLib3D/ImageProcessorsDescription.hpp>
00020 #include<ImLib3D/XMLTools.hpp>
00021 
00022 int
00023 main(int argc,char **argv)
00024 {
00025     vector<string> args;
00026     for(int i=1;i<argc;i++){args.push_back(argv[i]);}
00027     SetErrorManagementType(ERROR_USE_EXCEPTIONS);
00028     string warning="// *************** DO NOT MODIFY!!! ***********\n//  ** AUTOMATICALLY GENERATED SRC CODE **\n\n";
00029     string out=warning;
00030     ImageProcessorsDescription imProcsDescription;
00031     imProcsDescription.Read(args[0]);
00032     vector<string> procNames=imProcsDescription.GetNames(true);
00033 
00034 
00035     // ******************* generate  template group call macros ***********************
00036     printf(" found %d template groups\n",imProcsDescription.templateGroups.size());
00037     string out1=warning;
00038     for(uint i=0;i<imProcsDescription.templateGroups.size();i++)
00039     {
00040         XIPD::TemplateGroup &group=imProcsDescription.templateGroups[i];
00041         uint maxNbArgs=5;
00042         for(uint nbArgs=0;nbArgs<maxNbArgs;nbArgs++)
00043         {
00044             string macroName= "CallWith"+group.name+SPrintf("_%d",nbArgs);
00045             out1+="#define "+macroName+"(fct,typeName";
00046             for(uint j=0;j<nbArgs;j++){out1+=SPrintf(",a%d",j);}
00047             out1+=")\\\n";
00048             for(uint j=0;j<group.types.size();j++)
00049             {           
00050                 string type=group.types[j];
00051                 out1+="    if(typeName==\""+type+"\"){fct< "+type+" >(";
00052                 for(uint k=0;k<nbArgs;k++){out1+=(k>0 ? "," : "")+SPrintf("a%d",k);}
00053                 out1+=");}\\\n";
00054                 out1+="    else\\\n";
00055             }
00056             out1+="    {ThrowError(\""+macroName+" failed, type \\\"%s\\\" is not in template group \\\""+
00057                 group.name+"\\\"\",typeName);}\n";
00058         }
00059     }
00060     WriteStringToFile("TemplateGroups.hpp",out1);
00061 
00062 }

Generated on Fri Jun 17 13:36:03 2005 for ImLib3D by  doxygen 1.4.2