Parcourir la source

Merge branch 'master' of https://gogs.univ-littoral.fr/devs-lab/artis into extended_trace

# Conflicts:
#	src/artis/kernel/AbstractCoupledModel.hpp
gbeurier il y a 7 ans
Parent
commit
7c09b99b43

+ 9 - 2
AUTHORS

@@ -6,10 +6,15 @@ Copyright
 =========
 =========
 
 
 - ULCO
 - ULCO
-  - Copyright © 2013-2016
+  - Copyright © 2013-2017
   - Université du Littoral Côte d'Opale
   - Université du Littoral Côte d'Opale
   - http://www.univ-littoral.fr
   - http://www.univ-littoral.fr
 
 
+- Cirad
+  - Copyright © 2017
+  - Cirad
+  - http://www.cirad.fr
+
 Authors
 Authors
 =======
 =======
 
 
@@ -26,4 +31,6 @@ Main programmer and founder
 
 
 
 
 Contributors
 Contributors
-------------
+------------
+
+- Grégory Beurier <beurier@cirad.fr>

+ 8 - 2
src/artis/context/Context.hpp

@@ -54,8 +54,14 @@ public:
     void end(double end)
     void end(double end)
     { _end = end; }
     { _end = end; }
 
 
-    const Context& operator=(const Context& /* context */)
-    { assert(false); }
+    const Context& operator=(const Context& context)
+    {
+        _begin = context._begin;
+        _end = context._end;
+        _valid = context._valid;
+        _state = context._state;
+        return *this;
+    }
 
 
     void saved()
     void saved()
     { _valid = true; }
     { _valid = true; }

+ 26 - 0
src/artis/context/Value.hpp

@@ -32,6 +32,8 @@
 #if WIN32
 #if WIN32
 #include <string>
 #include <string>
 #endif
 #endif
+#include <vector>
+
 namespace artis { namespace context {
 namespace artis { namespace context {
 
 
 class Value
 class Value
@@ -99,6 +101,21 @@ public:
 
 
             get_content(v);
             get_content(v);
             return v ? "true" : "false";
             return v ? "true" : "false";
+        } if (is_double_vector()) {
+            std::vector < double > v;
+
+            get_content(v);
+            return "";
+        } else if (is_int_vector()) {
+            std::vector < int > v;
+
+            get_content(v);
+            return "";
+        } else if (is_bool_vector()) {
+            std::vector < bool > v;
+
+            get_content(v);
+            return "";
         } else {
         } else {
             assert(false);
             assert(false);
         }
         }
@@ -107,12 +124,21 @@ public:
     bool is_bool() const
     bool is_bool() const
     { return _type_id == typeid(bool).hash_code(); }
     { return _type_id == typeid(bool).hash_code(); }
 
 
+    bool is_bool_vector() const
+    { return _type_id == typeid(std::vector < bool >).hash_code(); }
+
     bool is_int() const
     bool is_int() const
     { return _type_id == typeid(int).hash_code(); }
     { return _type_id == typeid(int).hash_code(); }
 
 
+    bool is_int_vector() const
+    { return _type_id == typeid(std::vector < int >).hash_code(); }
+
     bool is_double() const
     bool is_double() const
     { return _type_id == typeid(double).hash_code(); }
     { return _type_id == typeid(double).hash_code(); }
 
 
+    bool is_double_vector() const
+    { return _type_id == typeid(std::vector < double >).hash_code(); }
+
 private:
 private:
     void assign(const void* content, size_t size, size_t type_id)
     void assign(const void* content, size_t size, size_t type_id)
     {
     {

+ 2 - 3
src/artis/kernel/AbstractCoupledModel.hpp

@@ -167,11 +167,10 @@ public:
 
 
     }
     }
 
 
-    virtual void build(const W& /* parameters */)
+    virtual void build(W& /* parameters */)
     { }
     { }
 
 
-    virtual void build(const W& /* parameters */,
-                       const std::string& /* json */)
+    virtual void build(W& /* parameters */, const std::string& /* json */)
     { }
     { }
 
 
     virtual bool check(typename U::type t) const
     virtual bool check(typename U::type t) const

+ 41 - 0
src/artis/kernel/Any.hpp

@@ -26,6 +26,7 @@
 #include <artis/context/Value.hpp>
 #include <artis/context/Value.hpp>
 
 
 #include <string>
 #include <string>
+#include <vector>
 
 
 namespace artis { namespace kernel {
 namespace artis { namespace kernel {
 
 
@@ -104,6 +105,21 @@ public:
         } else if (value.is_bool()) {
         } else if (value.is_bool()) {
             bool v;
             bool v;
 
 
+            value.get_content(v);
+            put(o, v);
+        } else if (value.is_double_vector()) {
+            std::vector < double > v;
+
+            value.get_content(v);
+            put(o, v);
+        } else if (value.is_int_vector()) {
+            std::vector < int > v;
+
+            value.get_content(v);
+            put(o, v);
+        } else if (value.is_bool_vector()) {
+            std::vector < bool > v;
+
             value.get_content(v);
             value.get_content(v);
             put(o, v);
             put(o, v);
         } else {
         } else {
@@ -132,6 +148,31 @@ public:
 
 
                     if (q_bool) {
                     if (q_bool) {
                         return context::Value(o->*(q_bool->value_));
                         return context::Value(o->*(q_bool->value_));
+                    } else {
+                        data < T, std::vector < double > >* q_double_v =
+                            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 <
+                                    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 <
+                                        bool > >* >(ptr_);
+
+                                if (q_bool_v) {
+                                    return context::Value(
+                                        o->*(q_bool_v->value_));
+                                }
+                            }
+                        }
                     }
                     }
                 }
                 }
             }
             }

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

@@ -36,11 +36,11 @@ class Simulator
 {
 {
 public:
 public:
     Simulator(artis::kernel::AbstractCoupledModel < T, U, V, W >* model,
     Simulator(artis::kernel::AbstractCoupledModel < T, U, V, W >* model,
-              const W& parameters) : _model(model), _observer(model)
+              W& parameters) : _model(model), _observer(model)
     { _model->build(parameters); }
     { _model->build(parameters); }
 
 
     Simulator(artis::kernel::AbstractCoupledModel < T, U, V, W >* model,
     Simulator(artis::kernel::AbstractCoupledModel < T, U, V, W >* model,
-              const W& parameters, const std::string& json)
+              W& parameters, const std::string& json)
         : _model(model), _observer(model)
         : _model(model), _observer(model)
     { _model->build(parameters, json); }
     { _model->build(parameters, json); }
 
 

+ 2 - 2
src/artis/utils/Trace.hpp

@@ -20,8 +20,8 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
  */
 
 
-#ifndef UTILS_TRACE
-#define UTILS_TRACE
+#ifndef ARTIS_UTILS_TRACE
+#define ARTIS_UTILS_TRACE
 
 
 #include <algorithm>
 #include <algorithm>
 #include <iterator>
 #include <iterator>