Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JRootClass.cc File Reference

Program to test JROOT::JRootClass. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "JROOT/JRootClass.hh"
#include "km3net-dataformat/offline/Head.hh"
#include "JAAnet/JHead.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Macros

#define PRINT(OUT, T)
 Print data member.
 
#define TEST(T)
 Test data member.
 

Functions

int main (int argc, char **argv)
 

Detailed Description

Program to test JROOT::JRootClass.

Author
mdejong

Definition in file JRootClass.cc.

Macro Definition Documentation

◆ PRINT

#define PRINT ( OUT,
T )
Value:
do { OUT \
<< std::setw(24) << left << #T << " --> " \
<< std::setw(16) << left << (getDataMember(T) != NULL ? getDataMember(T)->GetName() : "?") << std::endl; } while (0)
const TDataMember * getDataMember(const JRootClass &parent, const JRootClass &member)
Get ROOT data member for given parent and member class.

Print data member.

Parameters
OUToutput stream
Tdata member

Definition at line 24 of file JRootClass.cc.

24#define PRINT(OUT, T) \
25 do { OUT \
26 << std::setw(24) << left << #T << " --> " \
27 << std::setw(16) << left << (getDataMember(T) != NULL ? getDataMember(T)->GetName() : "?") << std::endl; } while (0)

◆ TEST

#define TEST ( T)
Value:
(getClassname(#T) == (getDataMember(T) != NULL ? getDataMember(T)->GetName() : "?"))
std::string getClassname(const std::string &type_name)
Get type name, i.e. part after JEEP::TYPENAME_SEPARATOR.

Test data member.

Parameters
Tdata member

Definition at line 35 of file JRootClass.cc.

35#define TEST(T) \
36 (getClassname(#T) == (getDataMember(T) != NULL ? getDataMember(T)->GetName() : "?"))

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 45 of file JRootClass.cc.

46{
47 using namespace std;
48 using namespace JPP;
49
50 int debug;
51
52 try {
53
54 JParser<> zap("Program to test JRootClass.");
55
56 zap['d'] = make_field(debug) = 3;
57
58 zap(argc, argv);
59 }
60 catch(const exception& error) {
61 FATAL(error.what() << endl);
62 }
63
64 if (debug >= debug_t) {
65 PRINT(cout, &JHead::start_run);
66 PRINT(cout, &JHead::detector);
67 PRINT(cout, &JHead::physics);
68 PRINT(cout, &JHead::simul);
71 PRINT(cout, &JHead::spectrum);
72 PRINT(cout, &JHead::can);
73 PRINT(cout, &JHead::genvol);
75 PRINT(cout, &JHead::livetime);
76 PRINT(cout, &JHead::seabottom);
77 }
78
91
92 {
93 const JType<JHead> type;
94
95 const JRootClass cls(type);
96
97 for (const string key : { "start_run", "detector", "physics", "simul", "cut_primary", "cut_seamuon", "spectrum", "can", "genvol", "coord_origin", "livetime", "seabottom" }) {
98 ASSERT( cls.find(key.c_str()).is_valid(), "check validity of " << key);
99 ASSERT(!cls.find(to_upper(key).c_str(), true) .is_valid(), "check invalidity of " << to_upper(key));
100 ASSERT( cls.find(to_upper(key).c_str(), false).is_valid(), "check validity of " << to_upper(key));
101 }
102 }
103
104 return 0;
105}
#define ASSERT(A,...)
Assert macro.
Definition JMessage.hh:90
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
#define PRINT(OUT, T)
Print data member.
Definition JRootClass.cc:24
#define TEST(T)
Test data member.
Definition JRootClass.cc:35
JAANET::spectrum spectrum
Definition JHead.hh:1597
std::vector< JAANET::simul > simul
Definition JHead.hh:1591
JAANET::seabottom seabottom
Definition JHead.hh:1605
JAANET::start_run start_run
Definition JHead.hh:1583
JAANET::coord_origin coord_origin
Definition JHead.hh:1601
JAANET::livetime livetime
Definition JHead.hh:1604
JAANET::genvol genvol
Definition JHead.hh:1600
std::vector< JAANET::detector > detector
Definition JHead.hh:1587
JAANET::cut_seamuon cut_seamuon
Definition JHead.hh:1594
JAANET::can can
Definition JHead.hh:1598
std::vector< JAANET::physics > physics
Definition JHead.hh:1590
JAANET::cut_primary cut_primary
Definition JHead.hh:1593
Utility class to parse command line options.
Definition JParser.hh:1698
@ debug_t
debug
Definition JMessage.hh:29
std::string to_upper(const std::string &value)
Convert all character to upper case.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
bool is_valid(const json &js)
Check validity of JSon data.
Auxiliary class for a type holder.
Definition JType.hh:19
Auxiliary class to manage access to base classes and data members of ROOT class.
Definition JRootClass.hh:44