00001
00008 #ifndef _DIVINE_DISTR_REPORTER_HH_
00009 #define _DIVINE_DISTR_REPORTER_HH_
00010
00011 #ifndef DOXYGEN_PROCESSING
00012 #include <iostream>
00013
00014 #include "distributed/distributed.hh"
00015 #include "common/reporter.hh"
00016
00017 namespace divine {
00018 #endif //DOXYGEN_PROCESSING
00019
00021 const size_t REPORTER_OUTPUT_SHORT = 1;
00023 const size_t REPORTER_OUTPUT_NORMAL = 2;
00025 const size_t REPORTER_OUTPUT_LONG = 3;
00026
00028 const size_t REPORTER_MASTER = 0;
00029 const size_t REPORTER_MIN = 1;
00030 const size_t REPORTER_AVG = 2;
00031 const size_t REPORTER_SUM = 3;
00032 const size_t REPORTER_MAX = 4;
00033
00036
00037 class distr_reporter_t : public reporter_t {
00038 protected:
00039 static const size_int_t BASIC_ITEMS;
00040
00041 typedef struct {
00042 double num_val;
00043 std::string str_val;
00044 bool val_is_num;
00045 } global_info_value_t;
00046
00047
00049 distributed_t* distributed;
00051 std::map<std::string, std::size_t> specific_info_flag;
00052 std::map<std::string, global_info_value_t> global_info;
00053 std::map<std::string, std::string> global_long_name;
00054 std::vector<std::vector<double> > results;
00055
00056 void print_specific_value(std::ostream & out, const std::string label,
00057 const divine::size_int_t i);
00058 void _set_pr(std::ostream& out, double a);
00059
00060 public:
00062 distr_reporter_t(distributed_t* d) { distributed = d; }
00063
00065
00068 void collect_and_print(std::size_t type_of_output, std::ostream& out);
00069
00070 void print(std::size_t type_of_output, std::ostream& out);
00071
00072 void collect();
00073
00075 void collect_and_print(std::size_t type_of_output = REPORTER_OUTPUT_NORMAL);
00076
00078
00082 void set_info(std::string s, double a, size_t flag = REPORTER_MASTER)
00083 { specific_info[s] = a; specific_info_flag[s] = flag; if (s=="InitTime") init_time=a; }
00084 void set_info(std::string s, double a, const std::string& long_name, size_t flag = REPORTER_MASTER)
00085 { distr_reporter_t::set_info(s,a,flag); specific_long_name[s]=long_name; }
00086
00088 void set_global_info(std::string s, double a)
00089 {
00090 global_info_value_t gv;
00091 gv.num_val=a;
00092 gv.str_val="";
00093 gv.val_is_num=true;
00094 if (distributed->is_manager())
00095 {
00096 global_info[s] = gv;
00097 }
00098 else
00099 {
00100 gerr << "Cannot set global info to report on non-master nodes."<<thr();
00101 }
00102 }
00103
00104 void set_global_info(std::string s, double a, const std::string & long_name)
00105 { set_global_info(s,a); global_long_name[s] = long_name; }
00106
00108 void set_global_info(std::string s, std::string a)
00109 {
00110 global_info_value_t gv;
00111 gv.num_val=0;
00112 gv.str_val=a;
00113 gv.val_is_num=false;
00114 if (distributed->is_manager())
00115 {
00116 global_info[s] = gv;
00117 }
00118 else
00119 {
00120 gerr << "Cannot set global info to report on non-master nodes."<<thr();
00121 }
00122 }
00123
00124 void set_global_info(std::string s, std::string a, const std::string & long_name)
00125 { set_global_info(s,a); global_long_name[s] = long_name; }
00126
00127 }
00128 ;
00129
00130 #ifndef DOXYGEN_PROCESSING
00131 }
00132 #endif //DOXYGEN_PROCESSING
00133
00134 #endif
00135
00136
00137
00138
00139