OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
FromFile.h
Go to the documentation of this file.
1 #ifndef __FROMFILE_H__
2 #define __FROMFILE_H__
3 
4 #include <string>
5 #include <map>
6 #include <set>
7 #include <fstream>
8 #include <iterator>
9 
10 #include "boost/tuple/tuple.hpp"
11 #include "boost/variant/get.hpp"
12 #include "boost/variant/variant.hpp"
13 #include "boost/smart_ptr.hpp"
14 
15 #include "Util/Types.h"
16 #include "Util/OptPilotException.h"
18 
19 
27 struct FromFile {
28 
29  static const std::string name;
30 
32  if (args.size() != 1) {
33  throw OptPilotException("FromFile::operator()",
34  "fromFile expects 1 arguments, " + std::to_string(args.size()) + " given");
35  }
36 
37  filename_ = boost::get<std::string>(args[0]);
38 
39  double sum = 0;
40  bool is_valid = true;
41 
42  try {
43  readValues();
44  } catch(const OptPilotException& e) {
45  return boost::make_tuple(0.0, false);
46  }
47 
48  for(double obj_value : values_)
49  sum += obj_value;
50 
51  return boost::make_tuple(sum, is_valid);
52  }
53 
54 
55 private:
56 
57  std::vector<double> values_;
58 
59  std::string filename_;
60 
61  void readValues();
62 
63 };
64 
65 #endif
constexpr double e
The value of .
Definition: Physics.h:40
void readValues()
reads a simple list of double values
Definition: FromFile.cpp:4
T::PETE_Expr_t::PETE_Return_t sum(const PETE_Expr< T > &expr)
Definition: PETE.h:1213
boost::tuple< double, bool > Result_t
Definition: Expression.h:37
Expressions::Result_t operator()(client::function::arguments_t args)
Definition: FromFile.h:31
std::vector< argument_t > arguments_t
Definition: function.hpp:19
std::vector< double > values_
Definition: FromFile.h:57
static const std::string name
Definition: FromFile.h:29
std::string filename_
Definition: FromFile.h:59