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

ImLib3DCommandLine.cpp

00001 /*
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
00007  * (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017  *
00018  */
00019 
00020 #include<ImLib3D/ImLib3D.hpp>
00021 #include<ImLib3D/ImageProcessorsDescription.hpp>
00022 #include<ImLib3D/ImageProcessorDescription.hpp>
00023 #include<ImLib3D/PluginManagement.hpp>
00024 #include<ImLib3D/XMLTools.hpp>
00025 #include<ImLib3D/BitImage3D.hpp>
00026 #include<ImLib3D/TypeSafeGenericPointer.hpp>
00027 #include"CallImLib3DImageProcessorByName.hpp"
00028 
00029 
00030 void
00031 Usage()
00032 {
00033     printf("Usage: imlib3d ImageProcessorName --help\n");
00034     printf("       imlib3d --list\n");
00035     printf("       imlib3d ImageProcessorName ImageProcessorArgs\n");
00036     printf("ImLib3D commandline processing\n");
00037 }
00038 int
00039 main(int argc,char **argv)
00040 {
00041     vector<string> args;
00042     for(int i=1;i<argc;i++){args.push_back(argv[i]);}
00043 
00044     PluginManagement allProcessors;
00045 
00046     if(args.size()==0 || args[0]=="-h" || args[0]=="-help" || args[0]=="--help" ){Usage();exit(0);}
00047     if(args[0]=="--query-imlib3d"){printf("imlib3d-main");exit(0);}
00048     if(args[0]=="--list")
00049     {
00050         allProcessors.PrintTree();
00051         exit(0);
00052     }
00053 
00054     string processor=args[0];
00055     if(args.size()==1 || args[1]=="-h" || args[1]=="-help" || args[1]=="--help")
00056     {
00057         if(args.size()==1){Usage();}
00058         ImageProcessorDescription proc(args[0],allProcessors);
00059         proc.PrintHelp();
00060         exit(0);
00061     }
00062     if(args[1]=="--doxy")
00063     {
00064         ImageProcessorDescription proc(args[0],allProcessors);
00065         proc.PrintDoxyDoc();
00066         exit(0);
00067     }
00068     string procName=args[0];
00069     // parse cmdline args
00070     SetErrorManagementType(ERROR_USE_EXCEPTIONS);
00071     vector<string> resArgs;
00072     ImageProcessorDescription imProcDescription(procName,allProcessors);
00073     try
00074     {
00075         resArgs=imProcDescription.ParseCmdLine(args);
00076         imProcDescription.ValidateArguments(resArgs);
00077     }
00078     catch(std::exception& __fail)
00079     {ThrowError("problem in parsing commandline \"%s\"",__fail.what());}
00080 
00081     if(allProcessors.PluginNumber(procName)==0)
00082     {
00083         CallImLib3DImageProcessorByName(procName,resArgs,imProcDescription.ProcTemplateTypeName(resArgs));
00084     }
00085     else
00086     {
00087         allProcessors.ExecuteImageProcessor(imProcDescription.BuildCmdLine(resArgs));
00088     }
00089 }
00090 
00091 

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