#include #include #include #include "JLang/JTypeList.hh" #include "JLang/JTypeID.hh" #include "JLang/JEnumeration.hh" #include "JROOT/JRootLabel.hh" #include "JDAQ/JDAQTimesliceIO.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" template<> struct JTypeID : public JLabel<1> {}; template<> struct JTypeID : public JLabel<1> {}; // will give compile error if also included in type list template<> struct JTypeID : public JLabel<2> {}; template<> struct JTypeID : public JLabel<3> {}; struct __A__; // user class without ID; requires specialisation of class JTypeID. template<> struct JTypeID<__A__> : public JLabel<4> {}; struct __B__ { // user class with ID; does not require specialisation of class JTypeID. static const int ID = 9; static const char* getName() { return "__B__"; } // optional name static int getVersion() { return 123; } // optional version }; template<> // template specialisation for class with ROOT dictionary struct JTypeID : public JROOT::JRootLabel<11, KM3NETDAQ::JDAQTimeslice> {}; #define PRINT(OUT, ENUMERATION, CLASS) \ OUT << setw(10) << left << #CLASS << " --> " << ENUMERATION.getLabel(JLANG::JType()).getID() << endl; /** * \file * * Example program to test JLANG::JEnumeration class. * \author mdejong */ int main(int argc, char **argv) { using namespace std; int debug; try { JParser<> zap("Example program to test class enumeration."); zap['d'] = make_field(debug) = 0; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } using namespace JPP; typedef JTypeList > > > > > JTypelist_t; const JEnumeration enumeration; enumeration.print(cout); PRINT(cout, enumeration, int); PRINT(cout, enumeration, __B__); }