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

Auxiliary program to modify tripod configuration. More...

#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <vector>
#include <set>
#include "JDetector/JTripod.hh"
#include "Jeep/JComment.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 tripod configuration.

Syntax:

    -T "<tripod identifier>     (setx|addx|subx) East"
    -T "<tripod identifier>     (sety|addy|suby) North"
    -T "<tripod identifier>     (setz|addz|subz) depth"
Author
mdejong

Definition in file JMoveTripod.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 125 of file JMoveTripod.cc.

126 {
127  using namespace std;
128  using namespace JPP;
129 
130  string tripodFile;
131  vector<JModifier> mod;
132  size_t size;
133  int debug;
134 
135  try {
136 
137  JParser<> zap("Auxiliary program to modify tripod configuration.");
138 
139  zap['f'] = make_field(tripodFile, "tripod file I/O");
140  zap['T'] = make_field(mod, "tripod modifier") = JPARSER::initialised();
141  zap['N'] = make_field(size, "internal buffer size") = 500000;
142  zap['d'] = make_field(debug, "debug level") = 2;
143 
144  zap(argc, argv);
145  }
146  catch(const exception &error) {
147  FATAL(error.what() << endl);
148  }
149 
150 
151  fstream io;
152 
153  io.open(tripodFile.c_str(), ios_base::in | ios_base::out);
154 
155  if (!io) {
156  FATAL("Error opening file " << tripodFile << endl);
157  }
158 
159  typedef vector<JTripod> container_type;
160 
161  JComment comment;
162  container_type tripods;
163 
164  io >> comment;
165 
166  for (JTripod tripod; io >> tripod; ) {
167  tripods.push_back(tripod);
168  }
169 
170  if (debug >= debug_t) {
171 
172  cout << comment << endl;
173 
174  for (container_type::const_iterator i = tripods.begin(); i != tripods.end(); ++i) {
175  cout << *i << endl;
176  }
177  }
178 
179  for (vector<JModifier>::const_iterator i = mod.begin(); i != mod.end(); ++i) {
180 
181  for (container_type::iterator target = tripods.begin(); target != tripods.end(); ++target) {
182 
183  if (target->getID() == i->id || i->id == WILDCARD) {
184 
185  DEBUG("Modifier" << ' '
186  << "(" << FILL(2,'0') << target->getID() << FILL() << ")" << ' '
187  << i->action << ' ' << i->value << endl);
188 
189  if (!i->apply(*target)) {
190  ERROR("No valid action: " << *i << endl);
191  }
192  }
193  }
194  }
195 
196  //io.clear();
197  //io.seekp(0, ios_base::beg);
198  io.close();
199  io.open(tripodFile.c_str(), ios_base::trunc | ios_base::out);
200 
201  for (container_type::const_iterator i = tripods.begin(); i != tripods.end(); ++i) {
202  io << *i << endl;
203  }
204 
205  io.close();
206 }
Utility class to parse command line options.
Definition: JParser.hh:1514
debug
Definition: JMessage.hh:29
Target.
Definition: JHead.hh:298
then fatal Number of tripods
Definition: JFootprint.sh:45
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:83
#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 sequence of same character.
Definition: JManip.hh:328
#define FATAL(A)
Definition: JMessage.hh:67
Auxiliary class for comment.
Definition: JComment.hh:41
Data structure for tripod.
Definition: JTripod.hh:32
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62