ReFRACtor
output.cc
Go to the documentation of this file.
1 #include "output.h"
2 #include <boost/foreach.hpp>
3 
4 using namespace FullPhysics;
5 using namespace blitz;
6 
7 //-----------------------------------------------------------------------
9 //-----------------------------------------------------------------------
10 
11 template<class T>
12 void Output::pass_to_write_t(const std::string& Dataset_name, boost::any* D)
13 {
14  typedef typename boost::function<T ()> T2;
15  if(boost::any_cast<T2>(D)) {
16  T2* t = boost::any_cast<T2>(D);
17  write_data(Dataset_name, (*t)());
18  }
19 }
20 
21 //-----------------------------------------------------------------------
23 //-----------------------------------------------------------------------
24 
25 void Output::pass_to_write(const std::string& Dataset_name, boost::any* D)
26 {
27 //-----------------------------------------------------------------------
30 //-----------------------------------------------------------------------
31 
32  pass_to_write_t<int>(Dataset_name, D);
33  pass_to_write_t<std::string>(Dataset_name, D);
34  pass_to_write_t<const char*>(Dataset_name, D);
35  pass_to_write_t<int64_t>(Dataset_name, D);
36  pass_to_write_t<double>(Dataset_name, D);
37 
38  pass_to_write_t<Array<int, 1> >(Dataset_name, D);
39  pass_to_write_t<Array<std::string, 1> >(Dataset_name, D);
40  pass_to_write_t<Array<const char*, 1> >(Dataset_name, D);
41  pass_to_write_t<Array<double, 1> >(Dataset_name, D);
42 
43  pass_to_write_t<Array<int, 2> >(Dataset_name, D);
44  pass_to_write_t<Array<std::string, 2> >(Dataset_name, D);
45  pass_to_write_t<Array<const char*, 2> >(Dataset_name, D);
46  pass_to_write_t<Array<double, 2> >(Dataset_name, D);
47 
48  pass_to_write_t<Array<int, 3> >(Dataset_name, D);
49  pass_to_write_t<Array<std::string, 3> >(Dataset_name, D);
50  pass_to_write_t<Array<const char*, 3> >(Dataset_name, D);
51  pass_to_write_t<Array<double, 3> >(Dataset_name, D);
52 }
53 
54 //-----------------------------------------------------------------------
60 //-----------------------------------------------------------------------
61 
63 {
64  try {
65  start_write();
66  typedef std::map<std::string, boost::any>::value_type vtype;
67  BOOST_FOREACH(vtype& p, func)
68  pass_to_write(p.first, &p.second);
69  end_write();
70  } catch(...) {
71  try {
72  end_because_of_error(); // Notify output to clean itself up.
73  } catch(...) {
74  }
75  throw;
76  }
77 }
78 
79 //-----------------------------------------------------------------------
84 //-----------------------------------------------------------------------
85 
87 {
88  try {
89  start_write();
90  typedef std::map<std::string, boost::any>::value_type vtype;
91  BOOST_FOREACH(vtype& p, func)
92  try {
93  pass_to_write(p.first, &p.second);
94  } catch(...) { // Ignore all errors
95  }
96  end_write();
97  } catch(...) { // Ignore all errors.
98  }
99 }
void write_best_attempt()
Write out the file, making a best attempt but ignoring all errors.
Definition: output.cc:86
Apply value function to a blitz array.
Contains classes to abstract away details in various Spurr Radiative Transfer software.
Definition: doxygen_python.h:1
void write()
Write out file.
Definition: output.cc:62

Copyright © 2017, California Institute of Technology.
ALL RIGHTS RESERVED.
U.S. Government Sponsorship acknowledged.
Generated Fri Aug 24 2018 15:44:10