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

Auxiliary program to modify transmitter configuration. More...

#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include "JDetector/JTransmitter.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 transmitter 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 "<identifier> <string number> <floor> x y z"
    -r "<string number>"

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

Author
mdejong

Definition in file JEditTransmitter.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 171 of file JEditTransmitter.cc.

172 {
173  using namespace std;
174  using namespace JPP;
175 
176  typedef JContainer< vector<JTransmitter> > 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 transmitter configuration.");
190 
191  zap['f'] = make_field(inputFile, "transmitter input file");
192  zap['o'] = make_field(outputFile, "transmitter output file");
193  zap['S'] = make_field(mod, "transmitter modifier") = JPARSER::initialised();
194  zap['A'] = make_field(add, "add transmitter") = JPARSER::initialised();
195  zap['k'] = make_field(keep, "keep transmitter[s]") = JPARSER::initialised();
196  zap['r'] = make_field(rm, "remove transmitter[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  container_type data;
207 
208  try {
209  data.load(inputFile.c_str());
210  }
211  catch(const exception&) {}
212 
213  if (squash) {
214  data.comment.clear();
215  }
216 
217  data.comment.add(JMeta(argc, argv));
218 
219  for (vector<JTransmitter>::const_iterator i = add.begin(); i != add.end(); ++i) {
220  data.push_back(*i);
221  }
222 
223  for (vector<JModifier>::const_iterator i = mod.begin(); i != mod.end(); ++i) {
224 
225  for (container_type::iterator target = data.begin(); target != data.end(); ++target) {
226 
227  if (target->getString() == i->id) {
228 
229  DEBUG("Modifier" << ' '
230  << "(" << FILL(4,'0') << target->getString() << "," << FILL(2,'0') << target->getFloor() << FILL() << ")" << ' '
231  << "action" << ' ' << i->action << JEEPZ() << i->data << endl);
232 
233  if (!i->apply(*target)) {
234  ERROR("No valid action: " << *i << endl);
235  }
236  }
237  }
238  }
239 
240  for (container_type::iterator i = data.begin(); i != data.end(); ) {
241 
242  if ((keep.empty() || keep.count(i->getString()) != 0) &&
243  (rm .empty() || rm .count(i->getString()) == 0))
244  ++i;
245  else
246  i = data.erase(i);
247  }
248 
249  data.store(outputFile.c_str());
250 }
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
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