Jpp  18.3.0-209-g56ce19a
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JEditDisable.cc File Reference
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include "JAcoustics/JTransmission_t.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JModuleRouter.hh"
#include "JSupport/JMeta.hh"
#include "Jeep/JContainer.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

int main ( int  argc,
char **  argv 
)
Author
mdejong

Auxiliary program to merge disable files.

Definition at line 25 of file JEditDisable.cc.

26 {
27  using namespace std;
28  using namespace JPP;
29 
30  typedef JContainer< vector<JTransmission_t> > disable_container;
31 
32  string inputFile;
33  string outputFile;
34  string detectorFile;
35  int debug;
36 
37  try {
38 
39  JParser<> zap("Auxiliary program to merge disable files.");
40 
41  zap['f'] = make_field(inputFile, "disable input file");
42  zap['o'] = make_field(outputFile, "disable output file");
43  zap['a'] = make_field(detectorFile, "detector file") = "";
44  zap['d'] = make_field(debug) = 1;
45 
46  zap(argc, argv);
47  }
48  catch(const exception &error) {
49  FATAL(error.what() << endl);
50  }
51 
52 
53  disable_container disable;
54 
55  disable.comment.add(JMeta(argc, argv));
56 
57  disable.load(inputFile.c_str());
58 
59  if (!disable.empty()) {
60 
61  if (detectorFile != "") {
62 
63  JDetector detector;
64 
65  try {
66  load(detectorFile, detector);
67  }
68  catch(const JException& error) {
69  FATAL(error);
70  }
71 
72  const JModuleRouter router(detector);
73 
74  for (disable_container::iterator i = disable.begin(); i != disable.end(); ) {
75  if (router.hasModule(i->rx))
76  ++i;
77  else
78  i = disable.erase(i);
79  }
80  }
81  }
82 
83  disable.store(outputFile.c_str());
84 }
Utility class to parse command line options.
Definition: JParser.hh:1711
string outputFile
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2158
#define FATAL(A)
Definition: JMessage.hh:67
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
do set_variable DETECTOR_TXT $WORKDIR detector
int debug
debug level