Jpp  19.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JEditHydrophone.cc File Reference

Auxiliary program to modify hydrophone configuration. More...

#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include "JDetector/JHydrophone.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)
 

Detailed Description

Auxiliary program to modify hydrophone configuration.

Syntax:

    -S "<string number>         (set|add|sub) x y z"
    -S "<string number>         (rot) phi"

For option rot, the angle phi refers to an anti-clockwise rotation around the z-axis.
The rotation angle is defined in radians.

The options

    -A "<string number> <floor> x y z"
    -r "<string number>"

can be used to add and remove a hydrophone, respectively.

Author
mdejong

Definition in file JEditHydrophone.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 171 of file JEditHydrophone.cc.

172 {
173  using namespace std;
174  using namespace JPP;
175 
176  typedef JContainer< vector<JHydrophone> > container_type;
177 
178  string inputFile;
179  string outputFile;
180  vector<JModifier> mod;
182  set<int> keep;
183  set<int> rm;
184  bool squash;
185  int debug;
186 
187  try {
188 
189  JParser<> zap("Auxiliary program to modify hydrophone configuration.");
190 
191  zap['f'] = make_field(inputFile, "hydrophone input file") = "";
192  zap['o'] = make_field(outputFile, "hydrophone output file");
193  zap['S'] = make_field(mod, "hydrophone modifier") = JPARSER::initialised();
194  zap['A'] = make_field(add, "add hydrophone") = JPARSER::initialised();
195  zap['k'] = make_field(keep, "keep hydrophone[s]") = JPARSER::initialised();
196  zap['r'] = make_field(rm, "remove hydrophone[s]") = JPARSER::initialised();
197  zap['q'] = make_field(squash, "squash meta data");
198  zap['d'] = make_field(debug, "debug level") = 2;
199 
200  zap(argc, argv);
201  }
202  catch(const exception &error) {
203  FATAL(error.what() << endl);
204  }
205 
206  const int ns = ((keep.empty() ? 0 : 1) +
207  (rm .empty() ? 0 : 1));
208 
209  if (ns > 1) {
210  FATAL("Use either option -k or -r." << endl);
211  }
212 
213  container_type data;
214 
215  if (inputFile != "") {
216  try {
217  data.load(inputFile.c_str());
218  }
219  catch(const exception& error) {
220  //FATAL(error.what() << endl);
221  }
222  }
223 
224  if (squash) {
225  data.comment.clear();
226  }
227 
228  data.comment.add(JMeta(argc, argv));
229 
230  for (vector<JHydrophone>::const_iterator i = add.begin(); i != add.end(); ++i) {
231  data.push_back(*i);
232  }
233 
234  for (vector<JModifier>::const_iterator i = mod.begin(); i != mod.end(); ++i) {
235 
236  for (container_type::iterator target = data.begin(); target != data.end(); ++target) {
237 
238  if (target->getString() == i->id) {
239 
240  DEBUG("Modifier" << ' '
241  << "(" << FILL(4,'0') << target->getString() << "," << FILL(2,'0') << target->getFloor() << FILL() << ")" << ' '
242  << "action" << ' ' << i->action << JEEPZ() << i->data << endl);
243 
244  if (!i->apply(*target)) {
245  ERROR("No valid action: " << *i << endl);
246  }
247  }
248  }
249  }
250 
251  for (container_type::iterator i = data.begin(); i != data.end(); ) {
252 
253  if ((keep.empty() || keep.count(i->getString()) != 0) &&
254  (rm .empty() || rm .count(i->getString()) == 0))
255  ++i;
256  else
257  i = data.erase(i);
258  }
259 
260  data.store(outputFile.c_str());
261 }
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:70
Utility class to parse command line options.
Definition: JParser.hh:1711
Target.
Definition: JHead.hh:298
std::vector< size_t > ns
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:84
string outputFile
then rm
Definition: sftpput.zsh:30
Auxiliary wrapper for I/O of container with optional comment (see JComment).
Definition: JContainer.hh:39
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2158
#define ERROR(A)
Definition: JMessage.hh:66
Auxiliary data structure for streaming of STL containers.
Definition: JPrint.hh:65
Auxiliary data structure for sequence of same character.
Definition: JManip.hh:328
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62