2
0

4 Commits 52ad001a34 ... b3c7b9a191

Autor SHA1 Nachricht Datum
  gbeurier b3c7b9a191 Add function for single subModel vor 6 Jahren
  gbeurier 441f3fd073 Added forced cast enum to int vor 6 Jahren
  Eric Ramat 654ca84c5b Remove warning at compilation. vor 6 Jahren
  Eric Ramat 70a9b815e0 Fix: missing c++ file in CMakeLists.txt and rename file vor 6 Jahren

+ 3 - 0
src/artis/context/StateValues.hpp

@@ -59,6 +59,7 @@ public:
             return it->second;
         } else {
             assert(false);
+            return it->second;
         }
     }
 
@@ -71,6 +72,7 @@ public:
             return it->second;
         } else {
             assert(false);
+            return it->second;
         }
     }
 
@@ -83,6 +85,7 @@ public:
             return it->second;
         } else {
             assert(false);
+            return it->second;
         }
     }
 

+ 17 - 13
src/artis/kernel/AbstractCoupledModel.hpp

@@ -491,22 +491,26 @@ protected:
         for (typename std::initializer_list < std::pair <  unsigned int,
                  type* > >::iterator it =
                  models.begin(); it != models.end(); ++it) {
-            submodels[it->first] = it->second;
-            it->second->set_parent(this);
+            subModel(it->first, it->second);
+        }
+    }
+
+    void subModel(unsigned int index, type* model)
+    {
+        submodels[index] = model;
+        model->set_parent(this);
 
 #ifdef WITH_TRACE
-            utils::Trace < utils::DoubleTime >::trace()
-                << utils::TraceElement < utils::DoubleTime >(
-                    true,
-                    AbstractCoupledModel < T, U, V, W >::path(this),
-                    utils::DoubleTime::null,
-                    utils::SUBMODEL_ADD)
-                << utils::KernelInfo(
-                    AbstractCoupledModel < T, U, V, W >::path(it->second));
-            utils::Trace < utils::DoubleTime >::trace().flush();
+        utils::Trace < utils::DoubleTime >::trace()
+            << utils::TraceElement < utils::DoubleTime >(
+                true,
+                AbstractCoupledModel < T, U, V, W >::path(this),
+                utils::DoubleTime::null,
+                utils::SUBMODEL_ADD)
+            << utils::KernelInfo(
+                AbstractCoupledModel < T, U, V, W >::path(model));
+        utils::Trace < utils::DoubleTime >::trace().flush();
 #endif
-
-        }
     }
 
     void setsubmodel(unsigned int index, type* model)

+ 26 - 16
src/artis/kernel/Any.hpp

@@ -30,8 +30,6 @@
 #include <utility>
 #include <vector>
 
-#include <iostream>
-
 namespace artis { namespace kernel {
 
 enum ValueTypeID { DOUBLE, INT, BOOL, DOUBLE_VECTOR, INT_VECTOR, BOOL_VECTOR,
@@ -132,7 +130,7 @@ public:
     void put(T* o, const V& value )
     {
         V T::* p = dynamic_cast <
-            data < T, V >* >(ptr_)->value_;
+                data < T, V >* >(ptr_)->value_;
         o->*(p) = value;
     }
 
@@ -179,44 +177,44 @@ public:
     {
         if (ptr_) {
             data < T, double >* q_double =
-                dynamic_cast < data < T, double >* >(ptr_);
+                    dynamic_cast < data < T, double >* >(ptr_);
 
             if (q_double) {
                 return context::Value(o->*(q_double->value_));
             } else {
                 data < T, int >* q_int =
-                    dynamic_cast < data < T, int >* >(ptr_);
+                        dynamic_cast < data < T, int >* >(ptr_);
 
                 if (q_int) {
                     return context::Value(o->*(q_int->value_));
                 } else {
                     data < T, bool >* q_bool =
-                        dynamic_cast < data < T, bool >* >(ptr_);
+                            dynamic_cast < data < T, bool >* >(ptr_);
 
                     if (q_bool) {
                         return context::Value(o->*(q_bool->value_));
                     } else {
                         data < T, std::vector < double > >* q_double_v =
-                            dynamic_cast < data < T, std::vector <
+                                dynamic_cast < data < T, std::vector <
                                 double > >* >(ptr_);
 
                         if (q_double_v) {
                             return context::Value(o->*(q_double_v->value_));
                         } else {
                             data < T, std::vector < int > >* q_int_v =
-                                dynamic_cast < data < T, std::vector <
+                                    dynamic_cast < data < T, std::vector <
                                     int > >* >(ptr_);
 
                             if (q_int_v) {
                                 return context::Value(o->*(q_int_v->value_));
                             } else {
                                 data < T, std::vector < bool > >* q_bool_v =
-                                    dynamic_cast < data < T, std::vector <
+                                        dynamic_cast < data < T, std::vector <
                                         bool > >* >(ptr_);
 
                                 if (q_bool_v) {
                                     return context::Value(
-                                        o->*(q_bool_v->value_));
+                                                o->*(q_bool_v->value_));
                                 }
                             }
                         }
@@ -225,6 +223,7 @@ public:
             }
         }
         assert(false);
+        return context::Value();
     }
 
     template < typename T >
@@ -232,45 +231,56 @@ public:
     {
         if (ptr_) {
             data < T, double >* q_double =
-                dynamic_cast < data < T, double >* >(ptr_);
+                    dynamic_cast < data < T, double >* >(ptr_);
 
             if (q_double) {
                 return std::to_string(o->*(q_double->value_));
             } else {
                 data < T, int >* q_int =
-                    dynamic_cast < data < T, int >* >(ptr_);
+                        dynamic_cast < data < T, int >* >(ptr_);
 
                 if (q_int) {
                     return std::to_string(o->*(q_int->value_));
                 } else {
                     data < T, bool >* q_bool =
-                        dynamic_cast < data < T, bool >* >(ptr_);
+                            dynamic_cast < data < T, bool >* >(ptr_);
 
                     if (q_bool) {
                         return o->*(q_bool->value_) ? "true": "false";
                     } else {
                         data < T, std::vector < double > >* q_double_v =
-                            dynamic_cast < data < T, std::vector <
+                                dynamic_cast < data < T, std::vector <
                                 double > >* >(ptr_);
 
                         if (q_double_v) {
                             return "";
                         } else {
                             data < T, std::vector < int > >* q_int_v =
-                                dynamic_cast < data < T, std::vector <
+                                    dynamic_cast < data < T, std::vector <
                                     int > >* >(ptr_);
 
                             if (q_int_v) {
                                 return "";
                             } else {
                                 data < T, std::vector < bool > >* q_bool_v =
-                                    dynamic_cast < data < T, std::vector <
+                                        dynamic_cast < data < T, std::vector <
                                         bool > >* >(ptr_);
 
                                 if (q_bool_v) {
                                     return "";
                                 } else {
+#ifdef FORCE_TRACE_ENUM
+                                    data < T, int >* q_enum =
+                                            static_cast < data < T, int >* >(ptr_);
+
+                                    if (q_enum) {
+                                        return std::to_string(o->*(q_enum->value_));
+                                    } else {
+                                        return "NA";
+                                    }
+#else
                                     return "NA";
+#endif
                                 }
                             }
                         }

+ 1 - 1
src/artis/utils/CMakeLists.txt

@@ -5,7 +5,7 @@ INCLUDE_DIRECTORIES(
 LINK_DIRECTORIES(
   ${Boost_LIBRARY_DIRS})
 
-SET(ARTIS_UTILS_CPP DateTime.cpp ParametersReader.cpp)
+SET(ARTIS_UTILS_CPP DateTime.cpp ParametersReader.cpp Trace.cpp)
 
 SET(ARTIS_UTILS_HPP DateTime.hpp DoubleTime.hpp Exception.hpp
   ParametersReader.hpp Time.hpp Trace.hpp)

+ 30 - 0
src/artis/utils/Trace.cpp

@@ -0,0 +1,30 @@
+/**
+ * @file utils/Trace.cpp
+ * @author See the AUTHORS file
+ */
+
+/*
+ * Copyright (C) 2012-2017 ULCO http://www.univ-littoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <artis/utils/Trace.hpp>
+
+namespace artis { namespace utils {
+
+std::map < std::string, int > artis::utils::KernelInfo::elt_dictionary;
+std::vector < std::string > artis::utils::KernelInfo::elt_names;
+
+} }

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

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