Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JGroup.cc
Go to the documentation of this file.
1
2#include <string>
3#include <iostream>
4#include <iomanip>
5
6#include "JLang/JGroup.hh"
7
8#include "Jeep/JParser.hh"
9#include "Jeep/JMessage.hh"
10
11namespace JLANG {
12
13 template<>
14 const double JGroup<double>::group[] = {
15 0.0,
16 1.0,
17 2.0,
18 3.0
19 };
20
22}
23
24
25/**
26 * \file
27 *
28 * Example program to test JLANG::JGroup class.
29 * \author mdejong
30 */
31int main(int argc, char **argv)
32{
33 using namespace std;
34 using namespace JPP;
35
36 int debug;
37
38 try {
39
40 JParser<> zap("Example program to test groups.");
41
42 zap['d'] = make_field(debug) = 3;
43
44 zap(argc, argv);
45 }
46 catch(const exception &error) {
47 FATAL(error.what() << endl);
48 }
49
50 DEBUG("Size of group " << JGroup<double>::size << endl);
51
52 const int N = 4;
53
54 for (int i = 0; i != N; ++i) {
55 DEBUG(i << ' ' << getElement(i) << endl);
56 }
57
58 ASSERT(JGroup<double>::size == N, "Test size of group.");
59
60 for (int i = 0; i != N; ++i) {
61 ASSERT(getElement(i) == (double) i, "Test element access.");
62 }
63
64 return 0;
65}
int main(int argc, char **argv)
Definition JGroup.cc:31
General purpose messaging.
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define ASSERT(A,...)
Assert macro.
Definition JMessage.hh:90
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Utility class to parse command line options.
Definition JParser.hh:1698
Auxiliary classes and methods for language specific functionality.
static const JGroup< double > & getElement
Definition JGroup.cc:21
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary class for a fixed group of objects.
Definition JGroup.hh:31
static const JGroup & getInstance()
Get unique instance.
Definition JGroup.hh:51