OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
RadialPeak.h
Go to the documentation of this file.
1#ifndef __RADIALPEAK_H__
2#define __RADIALPEAK_H__
3
4#include <string>
5
6#include "boost/type_traits/remove_cv.hpp"
7#include "boost/variant/get.hpp"
8#include "boost/variant/variant.hpp"
9
10#include "Util/Types.h"
11#include "Util/PeakReader.h"
13
18struct RadialPeak {
19
20 static const std::string name;
21
23 if (args.size() != 2) {
24 throw OptPilotException("RadialPeak::operator()",
25 "radialPeak expects 2 arguments, " + std::to_string(args.size()) + " given");
26 }
27
28 peak_filename_ = boost::get<std::string>(args[0]);
29 turn_number_ = boost::get<double>(args[1]);
30
31 bool is_valid = true;
32
33 const std::unique_ptr<PeakReader> sim_peaks(new PeakReader(peak_filename_));
34 try {
35 sim_peaks->parseFile();
36 } catch (OptPilotException &ex) {
37 std::cout << "Caught exception: " << ex.what() << std::endl;
38 is_valid = false;
39 }
40
41 double sim_radius = 0.0;
42 try {
43 sim_peaks->getPeak(turn_number_, sim_radius);
44 } catch(OptPilotException &e) {
45 std::cout << "Exception while getting value "
46 << "from peak file: " << e.what()
47 << std::endl;
48 is_valid = false;
49 }
50
51 return boost::make_tuple(sim_radius, is_valid);
52 }
53
54private:
55
56 std::string peak_filename_;
58
59 // define a mapping to arguments in argument vector
60 boost::tuple<std::string, int> argument_types;
61 // :FIXME: remove unused enum
62#if 0
63 enum {
64 peak_filename
65 , turn_number
66 } argument_type_id;
67#endif
68};
69
70#endif
boost::tuple< double, bool > Result_t
Definition Expression.h:66
std::vector< argument_t > arguments_t
Definition function.hpp:19
std::string peak_filename_
Definition RadialPeak.h:56
Expressions::Result_t operator()(client::function::arguments_t args)
Definition RadialPeak.h:22
static const std::string name
Definition RadialPeak.h:20
boost::tuple< std::string, int > argument_types
Definition RadialPeak.h:60
int turn_number_
Definition RadialPeak.h:57
virtual const char * what() const