Jpp  pmt_effective_area_update_2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JFind_if.cc File Reference

Auxiliary program to test JLANG::JPredicate class and helper methods. More...

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <iterator>
#include "JLang/JFind_if.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Auxiliary program to test JLANG::JPredicate class and helper methods.

Author
mdejong

Definition in file JFind_if.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 68 of file JFind_if.cc.

69 {
70  using namespace std;
71  using namespace JPP;
72 
73  int debug;
74 
75  try {
76 
77  JParser<> zap("Auxiliary program to test object selection methods.");
78 
79  zap['d'] = make_field(debug) = 3;
80 
81  zap(argc, argv);
82  }
83  catch(const exception &error) {
84  FATAL(error.what() << endl);
85  }
86 
87  vector<__A__> buffer;
88 
89  buffer.push_back(__A__(3));
90  buffer.push_back(__A__(4));
91  buffer.push_back(__A__(2));
92  buffer.push_back(__A__(1));
93  buffer.push_back(__A__(5));
94 
95 
96  print(cout, debug, "data:", buffer.begin(), buffer.end());
97 
98  JPredicate_t predicate(3);
99 
100  {
101  vector<__A__>::const_iterator p = find_if(buffer.begin(), buffer.end(), make_find_if(&__A__::a, predicate));
102 
103  DEBUG("has " << predicate.value << "? " << (p != buffer.end() ? "yes" : "no") << endl);
104 
105  ASSERT(p != buffer.end() && p->a == predicate.value);
106  }
107 
108  {
109  vector<__A__>::const_iterator p = find_if(buffer.begin(), buffer.end(), make_find_if(&__A__::get, predicate));
110 
111  DEBUG("has " << predicate.value << "? " << (p != buffer.end() ? "yes" : "no") << endl);
112 
113  ASSERT(p != buffer.end() && p->get() == predicate.value);
114  }
115 
116  return 0;
117 }
Utility class to parse command line options.
Definition: JParser.hh:1500
T get(const JHead &header)
Get object from header.
#define ASSERT(A,...)
Assert macro.
Definition: JMessage.hh:90
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
int debug
debug level
Definition: JSirene.cc:63
print
Definition: JConvertDusj.sh:44
#define FATAL(A)
Definition: JMessage.hh:67
JFind_if< JResult_t T::*, JPredicate_t > make_find_if(JResult_t T::*member, const JPredicate_t &predicate)
Helper method to create find_if for data member.
Definition: JFind_if.hh:119
then JCalibrateToT a
Definition: JTuneHV.sh:116
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG