OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
NumberOfPeaks.h
Go to the documentation of this file.
1 #ifndef __NUMBER_OF_PEAKS_H__
2 #define __NUMBER_OF_PEAKS_H__
3 
4 #include <string>
5 
6 #include <cmath>
7 
8 #include "boost/type_traits/remove_cv.hpp"
9 #include "boost/variant/get.hpp"
10 #include "boost/variant/variant.hpp"
11 #include "boost/smart_ptr.hpp"
12 
13 #include "Util/Types.h"
14 #include "Util/PeakReader.h"
16 
21 struct NumberOfPeaks {
22 
23  static const std::string name;
24 
26  if (args.size() != 1) {
27  throw OptPilotException("NumberOfPeaks::operator()",
28  "numberOfPeaks expects 1 arguments, " + std::to_string(args.size()) + " given");
29  }
30 
31  sim_filename_ = boost::get<std::string>(args[0]);
32 
33  bool is_valid = true;
34 
35  boost::scoped_ptr<PeakReader> sim_peaks(new PeakReader(sim_filename_));
36  std::size_t nPeaks = 0;
37 
38  try {
39  sim_peaks->parseFile();
40  nPeaks = sim_peaks->getNumberOfPeaks();
41  } catch (OptPilotException &ex) {
42  std::cout << "Caught exception: " << ex.what() << std::endl;
43  is_valid = false;
44  }
45 
46 
47  return boost::make_tuple(nPeaks, is_valid);
48  }
49 
50 private:
51  std::string sim_filename_;
52 
53  // define a mapping to arguments in argument vector
54  boost::tuple<std::string> argument_types;
55 };
56 
57 #endif
58 // vi: set et ts=4 sw=4 sts=4:
59 // Local Variables:
60 // mode:c
61 // c-basic-offset: 4
62 // indent-tabs-mode:nil
63 // End:
virtual const char * what() const
static const std::string name
Definition: NumberOfPeaks.h:23
boost::tuple< double, bool > Result_t
Definition: Expression.h:37
std::vector< argument_t > arguments_t
Definition: function.hpp:19
Implements a parser and value extractor for peak files (*.peaks)
Definition: PeakReader.h:13
std::string sim_filename_
Definition: NumberOfPeaks.h:51
Expressions::Result_t operator()(client::function::arguments_t args)
Definition: NumberOfPeaks.h:25
boost::tuple< std::string > argument_types
Definition: NumberOfPeaks.h:54
Inform & endl(Inform &inf)
Definition: Inform.cpp:42