Pārlūkot izejas kodu

Changed TraceType meaning and trace syntax (to confirm)

gbeurier 7 gadi atpakaļ
vecāks
revīzija
ccb7039f15

+ 15 - 5
src/artis/kernel/AbstractAtomicModel.hpp

@@ -48,16 +48,25 @@ public:
     {
 #ifdef WITH_TRACE
         utils::Trace < utils::DoubleTime >::trace()
-            << utils::TraceElement < utils::DoubleTime >("KERNEL", -1,
-                                                         utils::KERNEL)
-            << "NEW ATOMIC MODEL - "
-            << typeid(T).name();
+            << utils::TraceElement < utils::DoubleTime >(
+                   boost::core::demangle(typeid(T).name()).erase(0,6),
+                   utils::DoubleTime::null,
+                   utils::CONSTRUCT);
         utils::Trace < utils::DoubleTime >::trace().flush();
 #endif
     }
 
     virtual ~AbstractAtomicModel()
-    { }
+    {
+#ifdef WITH_TRACE
+        utils::Trace < utils::DoubleTime >::trace()
+            << utils::TraceElement < utils::DoubleTime >(
+                   boost::core::demangle(typeid(T).name()).erase(0,6),
+                   utils::DoubleTime::null,
+                   utils::DESTRUCT);
+        utils::Trace < utils::DoubleTime >::trace().flush();
+#endif
+    }
 
     virtual const Node < U >* atomic(unsigned int /* index */) const
     { return this; }
@@ -88,6 +97,7 @@ public:
                                                          utils::KERNEL)
             << "BEFORE - "
             << AbstractAtomicModel < T, U, V >::path(this);
+        utils::Trace < utils::DoubleTime >::trace().flush();
        trace_model(t);
 #else
         (void) t;

+ 15 - 15
src/artis/kernel/AbstractCoupledModel.hpp

@@ -69,10 +69,10 @@ public:
     {
 #ifdef WITH_TRACE
         utils::Trace < utils::DoubleTime >::trace()
-            << utils::TraceElement < utils::DoubleTime >("KERNEL", -1,
-                                                         utils::KERNEL)
-            << "NEW COUPLED MODEL - "
-            << typeid(T).name();
+            << utils::TraceElement < utils::DoubleTime >(
+                   boost::core::demangle(typeid(T).name()).erase(0,6),
+                   utils::DoubleTime::null,
+                   utils::CONSTRUCT);
         utils::Trace < utils::DoubleTime >::trace().flush();
 #endif
     }
@@ -81,10 +81,10 @@ public:
     {
 #ifdef WITH_TRACE
         utils::Trace < utils::DoubleTime >::trace()
-            << utils::TraceElement < utils::DoubleTime >("KERNEL", 0,
-                                                         utils::KERNEL)
-            << "DESTRUCTION - "
-            << AbstractCoupledModel < T, U, V, W >::path(this);
+            << utils::TraceElement < utils::DoubleTime >(
+                   boost::core::demangle(typeid(T).name()).erase(0,6),
+                   utils::DoubleTime::null,
+                   utils::DESTRUCT);
         utils::Trace < utils::DoubleTime >::trace().flush();
 #endif
     }
@@ -95,7 +95,7 @@ public:
 #ifdef WITH_TRACE
         utils::Trace < utils::DoubleTime >::trace()
             << utils::TraceElement < utils::DoubleTime >("KERNEL", t,
-                                                         utils::KERNEL)
+                                                         utils::AFTER_COMPUTE)
             << "AFTER - "
             << AbstractCoupledModel < T, U, V, W >::path(this);
         utils::Trace < utils::DoubleTime >::trace().flush();
@@ -124,7 +124,7 @@ public:
 #ifdef WITH_TRACE
         utils::Trace < utils::DoubleTime >::trace()
             << utils::TraceElement < utils::DoubleTime >("KERNEL", t,
-                                                         utils::KERNEL)
+                                                         utils::BEFORE_COMPUTE)
             << "BEFORE - "
             << AbstractCoupledModel < T, U, V, W >::path(this);
         utils::Trace < utils::DoubleTime >::trace().flush();
@@ -299,10 +299,10 @@ public:
                     "/[" + std::to_string(i) + "]" +
                     boost::core::demangle(typeid(*this).name());
             } else {
-                return p + "/" + boost::core::demangle(typeid(*this).name());
+                return p + "/" + boost::core::demangle(typeid(*this).name()).erase(0,6);
             }
         } else {
-            return boost::core::demangle(typeid(*this).name());
+            return boost::core::demangle(typeid(*this).name()).erase(0,6);
         }
     }
 
@@ -423,7 +423,7 @@ protected:
 #ifdef WITH_TRACE
                 utils::Trace < utils::DoubleTime >::trace()
                         << utils::TraceElement < utils::DoubleTime >("KERNEL", -1,
-                                                                     utils::KERNEL)
+                                                                     utils::INTERNAL_LINK)
                         << "LINK INTERNAL "
                         << AbstractCoupledModel < T, U, V, W >::path(this)
                         << ":"
@@ -447,7 +447,7 @@ protected:
 #ifdef WITH_TRACE
                 utils::Trace < utils::DoubleTime >::trace()
                         << utils::TraceElement < utils::DoubleTime >("KERNEL", -1,
-                                                                     utils::KERNEL)
+                                                                     utils::INTERNAL_DECL)
                         << "LINK INTERNAL "
                         << AbstractCoupledModel < T, U, V, W >::path(this)
                         << ":"
@@ -473,7 +473,7 @@ protected:
 #ifdef WITH_TRACE
         utils::Trace < utils::DoubleTime >::trace()
             << utils::TraceElement < utils::DoubleTime >("KERNEL", -1,
-                                                         utils::KERNEL)
+                                                         utils::SUBMODEL_ADD)
             << "SUBMODEL - "
             << AbstractCoupledModel < T, U, V, W >::path(it->second)
             << " to "

+ 2 - 2
src/artis/kernel/AbstractModel.hpp

@@ -96,10 +96,10 @@ public:
         if (index >= 0) {
             return p +
                 "/[" + std::to_string(index) + "]" +
-                boost::core::demangle(typeid(*child).name());
+                boost::core::demangle(typeid(*child).name()).erase(0,6);
         } else {
             return (p.empty() ? "" : p + "/") +
-                boost::core::demangle(typeid(*child).name());
+                boost::core::demangle(typeid(*child).name()).erase(0,6);
         }
     }
 

+ 1 - 2
src/artis/kernel/Simulator.hpp

@@ -53,14 +53,13 @@ public:
 
     void init(double time, const V& parameters)
     {
-        std::cout << "LAUNCH INIT" << std::endl;
         _model->init(time, parameters);
         _observer.init();
 
 #ifdef WITH_TRACE
         utils::Trace < utils::DoubleTime >::trace()
             << utils::TraceElement < utils::DoubleTime >("KERNEL", 0,
-                                                         utils::KERNEL)
+                                                         utils::INIT)
             << "GLOBAL VALUES - "
             << _model->path(_model);
         utils::Trace < utils::DoubleTime >::trace().flush();

+ 2 - 2
src/test/test-context.cpp

@@ -58,7 +58,7 @@ int main()
                        modelParameters);
         simulator.run(context);
 
-        std::cout << ::Trace::trace().elements().to_string() << std::endl;
+        std::cout << ::Trace::trace().elements().to_string(artis::utils::DATE_FORMAT_YMD) << std::endl;
 
         simulator.save(context);
 
@@ -83,7 +83,7 @@ int main()
             artis::utils::DateTime::toJulianDayNumber("2016-1-10"));
         simulator.run(new_context);
 
-        std::cout << ::Trace::trace().elements().to_string() << std::endl;
+        std::cout << ::Trace::trace().elements().filter_type(artis::utils::COMPUTE).to_string() << std::endl;
     }
 
     std::cout << "==== PAUSE ====" << std::endl;