USGS

Isis 3.0 Application Source Code Reference

Home

prtloganalyzer.cpp

Go to the documentation of this file.
00001 // $Id$
00002 #include "Isis.h"
00003 #include "FileList.h"
00004 #include "FileName.h"
00005 #include "Pvl.h"
00006 #include "Process.h"
00007 #include "ProgramAnalyzer.h"
00008 #include "iTime.h"
00009 #include "IException.h"
00010 
00011 using namespace std;
00012 using namespace Isis;
00013 
00014 void IsisMain() {
00015   Process p;
00016   ProgramAnalyzer analyzer;
00017 
00018   // Get the list of names of input CCD cubes to stitch together
00019   UserInterface &ui = Application::GetUserInterface();
00020 
00021   //  Add program exclusions
00022   if (ui.WasEntered("EXCLUDE")) analyzer.setExclude(ui.GetString("EXCLUDE"));
00023   if (ui.WasEntered("EXCLUDEFROM") ) {
00024     FileList elist(ui.GetFileName("EXCLUDEFROM"));
00025     for (int i = 0 ; i < elist.size() ; i++ ) {
00026       analyzer.exclude(elist[i].toString());
00027     }
00028   }
00029 
00030   // Add program inclusions
00031   if (ui.WasEntered("INCLUDE")) analyzer.setInclude(ui.GetString("INCLUDE"));
00032   if (ui.WasEntered("INCLUDEFROM") ) {
00033     FileList ilist(ui.GetFileName("INCLUDEFROM"));
00034     for (int i = 0 ; i < ilist.size() ; i++ ) {
00035       analyzer.include(ilist[i].toString());
00036     }
00037   }
00038 
00039   // Add the file
00040   analyzer.add(ui.GetFileName("FROM"));
00041 
00042   //  Log results
00043   PvlGroup logger = analyzer.review();
00044   Application::GuiLog(logger);
00045   Application::Log(logger);
00046 
00047   logger = analyzer.cumulative();
00048   Application::GuiLog(logger);
00049   Application::Log(logger);
00050 
00051 
00052   // Write the output file if requested for individual unique program summaries
00053   if(ui.WasEntered("SUMMARY")) {
00054     Pvl temp;
00055     temp.addGroup(analyzer.review());
00056     temp.addGroup(analyzer.cumulative());
00057     for (int i = 0 ; i < analyzer.Programs() ; i++) {
00058       temp.addGroup(analyzer.summarize(i));
00059     }
00060     temp.write(ui.GetFileName("SUMMARY"));
00061   }
00062 
00063   // Write the output file if requested of CSV formatted data
00064   if(ui.WasEntered("LOG")) {
00065    // Set up for opening
00066     FileName temp(ui.GetFileName("LOG"));
00067     QString file = temp.expanded();
00068     ofstream ostm;
00069 
00070     // Open the file
00071     ostm.open(file.toAscii().data(), std::ios::out);
00072     if(!ostm) {
00073       QString message = "Cannot open/create output file " + file;
00074       throw IException(IException::Io, message, _FILEINFO_);
00075     }
00076 
00077     analyzer.header(ostm);
00078     analyzer.listify(ostm);
00079     ostm.close();
00080   }
00081 
00082   p.EndProcess();
00083 }