Jpp  16.0.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JLine.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 
4 #include "TROOT.h"
5 #include "TFile.h"
6 #include "TLine.h"
7 
8 #include "Jeep/JProperties.hh"
9 #include "Jeep/JParser.hh"
10 #include "Jeep/JMessage.hh"
11 
12 
13 /**
14  * Auxiliary data structure for line.
15  */
16 struct JLine {
17 
18  /**
19  * Read line from input stream.
20  *
21  * \param in input stream
22  * \param line line
23  * \return input stream
24  */
25  friend inline std::istream& operator>>(std::istream& in, JLine& line)
26  {
27  return in >> line.x1 >> line.y1 >> line.x2 >> line.y2;
28  }
29 
30  /**
31  * Write line to output stream.
32  *
33  * \param out output stream
34  * \param line line
35  * \return output stream
36  */
37  friend inline std::ostream& operator<<(std::ostream& out, const JLine& line)
38  {
39  return out << line.x1 << ' ' << line.y1 << ' ' << line.x2 << ' ' << line.y2;
40  }
41 
42  double x1;
43  double y1;
44  double x2;
45  double y2;
46 };
47 
48 
49 /**
50  * \file
51  * Auxiliary program to create TLine.
52  * \author mdejong
53  */
54 int main(int argc, char **argv)
55 {
56  using namespace std;
57 
58  string outputFile;
60  Color_t color = kBlack;
61  Style_t style = kSolid;
62  Width_t width = 2;
63  int debug;
64 
65  try {
66 
67  JProperties properties;
68 
69  properties.insert(gmake_property(color));
70  properties.insert(gmake_property(style));
71  properties.insert(gmake_property(width));
72 
73  JParser<> zap("Auxiliary program to create TLine.");
74 
75  zap['o'] = make_field(outputFile);
76  zap['p'] = make_field(parameters, "x1 y1 x2 y2");
77  zap['@'] = make_field(properties, "line attributes") = JPARSER::initialised();
78  zap['d'] = make_field(debug) = 1;
79 
80  zap(argc, argv);
81  }
82  catch(const exception &error) {
83  FATAL(error.what() << endl);
84  }
85 
86 
87  TFile out(outputFile.c_str(), "recreate");
88 
89  TLine* p = new TLine(parameters.x1, parameters.y1, parameters.x2, parameters.y2);
90 
91  p->SetLineColor(color);
92  p->SetLineStyle(style);
93  p->SetLineWidth(width);
94 
95  out.WriteTObject(p);
96 
97  out.Write();
98  out.Close();
99 }
Utility class to parse command line options.
Definition: JParser.hh:1500
int main(int argc, char *argv[])
Definition: Main.cc:15
double y1
Definition: JLine.cc:43
#define gmake_property(A)
macro to convert (template) parameter to JPropertiesElement object
double y2
Definition: JLine.cc:45
Utility class to parse parameter values.
Definition: JProperties.hh:496
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
double x2
Definition: JLine.cc:44
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:66
string outputFile
Utility class to parse parameter values.
friend std::istream & operator>>(std::istream &in, JLine &line)
Read line from input stream.
Definition: JLine.cc:25
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
int debug
debug level
Definition: JSirene.cc:63
double x1
Definition: JLine.cc:42
General purpose messaging.
friend std::ostream & operator<<(std::ostream &out, const JLine &line)
Write line to output stream.
Definition: JLine.cc:37
#define FATAL(A)
Definition: JMessage.hh:67
Auxiliary data structure for line.
Definition: JLine.cc:16
Utility class to parse command line options.
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 source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:42