Explorar el Código

Added trace dictionnary

gbeurier hace 7 años
padre
commit
476020848b
Se han modificado 2 ficheros con 33 adiciones y 21 borrados
  1. 26 21
      src/artis/utils/Trace.hpp
  2. 7 0
      src/artis/utils/trace.cpp

+ 26 - 21
src/artis/utils/Trace.hpp

@@ -165,7 +165,7 @@ public:
                 ss << "*";
             ss << KernelInfo::term(_var);
         }
-        if( not _value == -1) {
+        if( not KernelInfo::term(_value).empty()) {
             ss << "=" << KernelInfo::term(_value);
         }
         if(not KernelInfo::term(_tgt_model).empty()) {
@@ -245,6 +245,29 @@ public:
     void set_kernel_info(const KernelInfo& info)
     { _kernel_info = info; }
 
+    std::string to_string(artis::utils::DateFormat date_format =
+            artis::utils::DATE_FORMAT_EXTENDED) const
+    {
+        std::ostringstream ss;
+        ss << (from_kernel() ? "KERNEL" : "TRACE ");
+        if (get_time() != Time::null) {
+            ss << "(" << utils::DateTime::toJulianDayFmt(get_time(),
+                                                         date_format)
+               << ")";
+        }
+        ss << ": ";
+        ss << "<" + TraceTypesStr[get_type()] + ">";
+        ss << " " << get_model_name();
+        if (not get_kernel_info().empty()) {
+            ss << get_kernel_info().to_string();
+        }
+        if (not get_comment().empty()) {
+            ss << " => " << get_comment();
+        }
+        return ss.str();
+
+    }
+
 private:
     std::string         _model_name;
     typename Time::type _time;
@@ -328,22 +351,7 @@ public:
         for (typename TraceElements < Time >::const_iterator it =
              TraceElements < Time >::begin();
              it != TraceElements < Time >::end(); ++it) {
-            ss << (it->from_kernel() ? "KERNEL" : "TRACE ");
-            if (it->get_time() != Time::null) {
-                ss << "(" << utils::DateTime::toJulianDayFmt(it->get_time(),
-                                                             date_format)
-                   << ")";
-            }
-            ss << ": ";
-            ss << "<" + TraceTypesStr[it->get_type()] + ">";
-            ss << " " << it->get_model_name();
-            if (not it->get_kernel_info().empty()) {
-                ss << it->get_kernel_info().to_string();
-            }
-            if (not it->get_comment().empty()) {
-                ss << " => " << it->get_comment();
-            }
-            ss << std::endl;
+            ss << it->to_string(date_format) << std::endl;
         }
         return ss.str();
     }
@@ -359,10 +367,7 @@ public:
     static Trace& trace()
     {
         std::call_once(_flag, [] ()
-        { _instance.reset(new Trace());
-//            artis::utils::KernelInfo::elt_dictionary = std::map < std::string, int >();
-//            artis::utils::KernelInfo::elt_names = std::vector < std::string > ();
-        }
+        { _instance.reset(new Trace()); }
         );
         return *_instance;
     }

+ 7 - 0
src/artis/utils/trace.cpp

@@ -0,0 +1,7 @@
+#include "Trace.hpp"
+
+std::map < std::string, int > artis::utils::KernelInfo::elt_dictionary;
+std::vector < std::string > artis::utils::KernelInfo::elt_names;
+
+
+