00001 00003 #ifndef _DIVINE_LOGGER_HH_ 00004 #define _DIVINE_LOGGER_HH_ 00005 00006 #ifndef DOXYGEN_PROCESSING 00007 #include <iostream> 00008 #include <fstream> 00009 #include <sys/types.h> 00010 #include <unistd.h> 00011 #include <sys/times.h> 00012 00013 #include "common/sysinfo.hh" 00014 #include "distributed/distributed.hh" 00015 #include "storage/explicit_storage.hh" 00016 00017 void on_SIGALRM_signal(int); 00018 00019 namespace divine { 00020 #endif//DOXYGEN_PROCESSING 00021 00031 class logger_t 00032 { 00033 private: 00034 bool initialized; 00035 vminfo_t vm; 00036 int format; 00037 clock_t firsttick; 00038 tms tmsstruct; 00039 distributed_t *divine_ptr; 00040 size_int_t net_id; 00041 std::string host; 00042 explicit_storage_t *storage_ptr; 00043 std::ofstream logger_file; 00044 std::string logger_file_name; 00045 unsigned long int log_counter; 00046 00047 typedef unsigned (*unsignedfunc_t)(); 00048 unsignedfunc_t ufunc[10]; 00049 std::string ufunc_name[10]; 00050 int ufunc_count; 00051 00052 typedef int (*intfunc_t)(); 00053 intfunc_t ifunc[10]; 00054 std::string ifunc_name[10]; 00055 int ifunc_count; 00056 00057 typedef double (*doublefunc_t)(); 00058 doublefunc_t dfunc[10]; 00059 std::string dfunc_name[10]; 00060 int dfunc_count; 00061 00062 public: 00063 class log_ulong_int_t { 00064 public: 00065 virtual ulong_int_t log() const = 0; 00066 virtual ~log_ulong_int_t() {} 00067 }; 00068 private: 00069 const log_ulong_int_t * ufunctor[10]; 00070 std::string ufunctor_name[10]; 00071 int ufunctor_count; 00072 00073 public: 00074 class log_slong_int_t { 00075 public: 00076 virtual slong_int_t log() const = 0; 00077 virtual ~log_slong_int_t() {} 00078 }; 00079 private: 00080 const log_slong_int_t * sfunctor[10]; 00081 std::string sfunctor_name[10]; 00082 int sfunctor_count; 00083 00084 public: 00085 class log_double_t { 00086 public: 00087 virtual double log() const = 0; 00088 virtual ~log_double_t() {} 00089 }; 00090 private: 00091 const log_double_t * dfunctor[10]; 00092 std::string dfunctor_name[10]; 00093 int dfunctor_count; 00094 00095 public: 00096 unsigned int signal_period; 00097 00100 logger_t(); 00101 00103 ~logger_t(); 00104 00119 void init(distributed_t * divine_ptr_in, std::string basename, 00120 int format = 0); 00121 00126 void init(string tmpstr_in, int format_in = 0); 00127 00133 void set_storage(explicit_storage_t *storage_ptr); 00134 00140 void log_now(); 00141 00147 void use_SIGALRM(unsigned int period=1); 00148 00151 void stop_SIGALRM(); 00152 00161 void register_unsigned(unsignedfunc_t func_ptr, 00162 std::string description = ""); 00163 00169 void register_int(intfunc_t func_ptr, std::string description = ""); 00170 00176 void register_double(doublefunc_t func_ptr, std::string description = ""); 00177 00186 void register_ulong_int(const log_ulong_int_t & functor, 00187 std::string description = ""); 00188 00197 void register_slong_int(const log_slong_int_t & functor, 00198 std::string description = ""); 00199 00208 void register_double(const log_double_t & functor, 00209 std::string description = ""); 00210 00211 }; 00212 00213 #ifndef DOXYGEN_PROCESSING 00214 } 00215 #endif 00216 00217 #endif