Jpp  18.5.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  try {
216  data.load(inputFile.c_str());
217  }
218  catch(const exception&) {}
219 
220  if (squash) {
221  data.comment.clear();
222  }
223 
224  data.comment.add(JMeta(argc, argv));
225 
226  for (vector<JHydrophone>::const_iterator i = add.begin(); i != add.end(); ++i) {
227  data.push_back(*i);
228  }
229 
230  for (vector<JModifier>::const_iterator i = mod.begin(); i != mod.end(); ++i) {
231 
232  for (container_type::iterator target = data.begin(); target != data.end(); ++target) {
233 
234  if (target->getString() == i->id) {
235 
236  DEBUG("Modifier" << ' '
237  << "(" << FILL(4,'0') << target->getString() << "," << FILL(2,'0') << target->getFloor() << FILL() << ")" << ' '
238  << "action" << ' ' << i->action << JEEPZ() << i->data << endl);
239 
240  if (!i->apply(*target)) {
241  ERROR("No valid action: " << *i << endl);
242  }
243  }
244  }
245  }
246 
247  for (container_type::iterator i = data.begin(); i != data.end(); ) {
248 
249  if ((keep.empty() || keep.count(i->getString()) != 0) &&
250  (rm .empty() || rm .count(i->getString()) == 0))
251  ++i;
252  else
253  i = data.erase(i);
254  }
255 
256  data.store(outputFile.c_str());
257 }
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:1514
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:83
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:1989
#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