Jpp  master_rocky
the software that should make you happy
JStatic.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <iomanip>
4 
5 #include "JLang/JStatic.hh"
6 
7 #include "JTools/JQuantile.hh"
8 
9 #include "Jeep/JParser.hh"
10 #include "Jeep/JMessage.hh"
11 
12 namespace {
13 
14  using JLANG::JStatic;
15  using JTOOLS::JQuantile;
16 
17  struct __A__ {
18 
19  static JStatic<int, __COUNTER__> A;
20  static JStatic<int, __COUNTER__> B;
21  static JStatic<int, __COUNTER__> C;
22 
23  STATIC_DATA_MEMBER(double) D;
24  STATIC_DATA_MEMBER(int) E;
25  STATIC_DATA_MEMBER(std::string) F;
26  STATIC_DATA_MEMBER(JQuantile) Q;
27  };
28 }
29 
30 /**
31  * \file
32  *
33  * Example program to test JLANG::JStatic class.
34  * \author mdejong
35  */
36 int main(int argc, char **argv)
37 {
38  using namespace std;
39  using namespace JPP;
40 
41  int debug;
42 
43  try {
44 
45  JParser<> zap("Example program to test static data member.");
46 
47  zap['d'] = make_field(debug) = 3;
48 
49  zap(argc, argv);
50  }
51  catch(const exception &error) {
52  FATAL(error.what() << endl);
53  }
54 
55  __A__::A = 888;
56  __A__::B = 0;
57  __A__::C = 100;
58  __A__::D = -11.11;
59  __A__::E = 1;
60  __A__::F = "hello world";
61 
62  int i = __A__::A;
63 
64  DEBUG(i << endl);
65 
66  __A__::B++;
67  __A__::B += 2;
68 
69  DEBUG(__A__::B << endl);
70  DEBUG(__A__::C << endl);
71  DEBUG(__A__::D << endl);
72  DEBUG(__A__::E << endl);
73  DEBUG(__A__::F << endl);
74 
75  for (int i = 1; i != 10; ++i) {
76  __A__::Q->put(i);
77  }
78 
79  DEBUG(__A__::Q->getMean() << endl);
80 
81  {
82  __A__ a;
83 
84  DEBUG(a.F << endl);
85  }
86 }
double getMean(vector< double > &v)
get mean of vector content
General purpose messaging.
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2142
int main(int argc, char **argv)
Definition: JStatic.cc:36
#define STATIC_DATA_MEMBER(TYPE)
Static data member declaration.
Definition: JStatic.hh:243
Utility class to parse command line options.
Definition: JParser.hh:1698
const double a
Definition: JQuadrature.cc:42
static const double C
Physics constants.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JSTDTypes.hh:14
Template data structure for static member declaration.
Definition: JStatic.hh:22
Auxiliary data structure for running average, standard deviation and quantiles.
Definition: JQuantile.hh:46