USGS

Isis 3.0 Application Source Code Reference

Home

prtloganalyzer.cpp
Go to the documentation of this file.
1 // $Id$
2 #include "Isis.h"
3 #include "FileList.h"
4 #include "FileName.h"
5 #include "Pvl.h"
6 #include "Process.h"
7 #include "ProgramAnalyzer.h"
8 #include "iTime.h"
9 #include "IException.h"
10 
11 using namespace std;
12 using namespace Isis;
13 
14 void IsisMain() {
15  Process p;
16  ProgramAnalyzer analyzer;
17 
18  // Get the list of names of input CCD cubes to stitch together
19  UserInterface &ui = Application::GetUserInterface();
20 
21  // Add program exclusions
22  if (ui.WasEntered("EXCLUDE")) analyzer.setExclude(ui.GetString("EXCLUDE"));
23  if (ui.WasEntered("EXCLUDEFROM") ) {
24  FileList elist(ui.GetFileName("EXCLUDEFROM"));
25  for (int i = 0 ; i < elist.size() ; i++ ) {
26  analyzer.exclude(elist[i].toString());
27  }
28  }
29 
30  // Add program inclusions
31  if (ui.WasEntered("INCLUDE")) analyzer.setInclude(ui.GetString("INCLUDE"));
32  if (ui.WasEntered("INCLUDEFROM") ) {
33  FileList ilist(ui.GetFileName("INCLUDEFROM"));
34  for (int i = 0 ; i < ilist.size() ; i++ ) {
35  analyzer.include(ilist[i].toString());
36  }
37  }
38 
39  // Add the file
40  analyzer.add(ui.GetFileName("FROM"));
41 
42  // Log results
43  PvlGroup logger = analyzer.review();
44  Application::GuiLog(logger);
45  Application::Log(logger);
46 
47  logger = analyzer.cumulative();
48  Application::GuiLog(logger);
49  Application::Log(logger);
50 
51 
52  // Write the output file if requested for individual unique program summaries
53  if(ui.WasEntered("SUMMARY")) {
54  Pvl temp;
55  temp.addGroup(analyzer.review());
56  temp.addGroup(analyzer.cumulative());
57  for (int i = 0 ; i < analyzer.Programs() ; i++) {
58  temp.addGroup(analyzer.summarize(i));
59  }
60  temp.write(ui.GetFileName("SUMMARY"));
61  }
62 
63  // Write the output file if requested of CSV formatted data
64  if(ui.WasEntered("LOG")) {
65  // Set up for opening
66  FileName temp(ui.GetFileName("LOG"));
67  QString file = temp.expanded();
68  ofstream ostm;
69 
70  // Open the file
71  ostm.open(file.toLatin1().data(), std::ios::out);
72  if(!ostm) {
73  QString message = "Cannot open/create output file " + file;
74  throw IException(IException::Io, message, _FILEINFO_);
75  }
76 
77  analyzer.header(ostm);
78  analyzer.listify(ostm);
79  ostm.close();
80  }
81 
82  p.EndProcess();
83 }
PvlGroup cumulative(const QString &name="ProgramTotals") const
Reports cumulative runtime performance statistics for programs.
std::ostream & header(std::ostream &out) const
Writes a header in CVS format to a ostream.
void IsisMain()
Definition: apollo2isis.cpp:42
void exclude(const QString &exclude)
Loads a list of excluded program names from a file.
std::ostream & listify(std::ostream &out) const
Writes the analysis to the stream in CSV format.
void setInclude(const QString &name)
Set the list of program inclusions.
A ProgramAnalyzer accumulates print log runtime statistics.
void include(const QString &include)
Loads a list of included program names from a file.
PvlGroup summarize(const QString &name) const
Reports analysis for a specific program.
Cube * out
Definition: lrowac2pds.cpp:50
PvlGroup review(const QString &name="Results") const
Reports program counters for the current state.
void setExclude(const QString &name)
Set the list of program exclusions.
int Programs() const
Returns total number of unique programs.
void add(const QString &logfile)
Adds a print.prt file to the analysis.