Browse Source

New coding style

Eric Ramat 1 year ago
parent
commit
0fc53c8137
73 changed files with 6733 additions and 7163 deletions
  1. 2 3
      src/apps/main.cpp
  2. 200 201
      src/artis-star/common/Any.hpp
  3. 38 41
      src/artis-star/common/Bag.hpp
  4. 111 120
      src/artis-star/common/Coordinator.hpp
  5. 85 90
      src/artis-star/common/ExternalEvent.hpp
  6. 67 70
      src/artis-star/common/GraphManager.hpp
  7. 36 40
      src/artis-star/common/InternalEvent.hpp
  8. 109 116
      src/artis-star/common/Links.hpp
  9. 1 1
      src/artis-star/common/Macro.hpp
  10. 234 259
      src/artis-star/common/Model.hpp
  11. 29 32
      src/artis-star/common/Node.hpp
  12. 7 7
      src/artis-star/common/Parameters.hpp
  13. 73 77
      src/artis-star/common/RootCoordinator.hpp
  14. 15 15
      src/artis-star/common/Scheduler.hpp
  15. 24 25
      src/artis-star/common/Simulator.hpp
  16. 78 82
      src/artis-star/common/States.hpp
  17. 166 172
      src/artis-star/common/Value.hpp
  18. 48 51
      src/artis-star/common/context/Context.hpp
  19. 71 77
      src/artis-star/common/context/State.hpp
  20. 48 51
      src/artis-star/common/context/StateValues.hpp
  21. 59 61
      src/artis-star/common/observer/Iterator.hpp
  22. 75 82
      src/artis-star/common/observer/Observer.hpp
  23. 63 64
      src/artis-star/common/observer/Output.hpp
  24. 138 145
      src/artis-star/common/observer/View.hpp
  25. 112 120
      src/artis-star/common/scheduler/HeapScheduler.hpp
  26. 10 10
      src/artis-star/common/scheduler/SchedulerHandle.hpp
  27. 77 83
      src/artis-star/common/scheduler/VectorScheduler.hpp
  28. 4 4
      src/artis-star/common/time/DoubleTime.hpp
  29. 4 4
      src/artis-star/common/time/IntegerTime.hpp
  30. 9 9
      src/artis-star/common/time/Limits.hpp
  31. 11 9
      src/artis-star/common/time/RationalTime.hpp
  32. 16 16
      src/artis-star/common/time/Time.hpp
  33. 28 40
      src/artis-star/common/utils/FormalismType.hpp
  34. 31 47
      src/artis-star/common/utils/FunctionType.hpp
  35. 22 27
      src/artis-star/common/utils/LevelType.hpp
  36. 199 210
      src/artis-star/common/utils/Multithreading.hpp
  37. 12 13
      src/artis-star/common/utils/String.hpp
  38. 179 192
      src/artis-star/common/utils/Trace.hpp
  39. 241 252
      src/artis-star/kernel/devs/Coordinator.hpp
  40. 52 58
      src/artis-star/kernel/devs/Dynamics.hpp
  41. 96 102
      src/artis-star/kernel/devs/GraphManager.hpp
  42. 157 165
      src/artis-star/kernel/devs/Simulator.hpp
  43. 247 260
      src/artis-star/kernel/dsde/Coordinator.hpp
  44. 230 241
      src/artis-star/kernel/dsde/Executive.hpp
  45. 80 86
      src/artis-star/kernel/dsde/GraphManager.hpp
  46. 167 173
      src/artis-star/kernel/dtss/Coordinator.hpp
  47. 93 104
      src/artis-star/kernel/dtss/Dynamics.hpp
  48. 122 130
      src/artis-star/kernel/dtss/GraphManager.hpp
  49. 63 65
      src/artis-star/kernel/dtss/Policy.hpp
  50. 151 159
      src/artis-star/kernel/dtss/Simulator.hpp
  51. 26 26
      src/artis-star/kernel/fddevs/Coordinator.hpp
  52. 69 79
      src/artis-star/kernel/fddevs/Dynamics.hpp
  53. 18 18
      src/artis-star/kernel/fddevs/GraphManager.hpp
  54. 170 177
      src/artis-star/kernel/fddevs/Simulator.hpp
  55. 19 19
      src/artis-star/kernel/pdevs/Context.hpp
  56. 224 234
      src/artis-star/kernel/pdevs/Coordinator.hpp
  57. 79 89
      src/artis-star/kernel/pdevs/Dynamics.hpp
  58. 139 150
      src/artis-star/kernel/pdevs/GraphManager.hpp
  59. 159 168
      src/artis-star/kernel/pdevs/Simulator.hpp
  60. 30 31
      src/artis-star/kernel/pdevs/mpi/Coordinator.hpp
  61. 26 24
      src/artis-star/kernel/pdevs/mpi/GraphManager.hpp
  62. 72 78
      src/artis-star/kernel/pdevs/mpi/LogicalProcessor.hpp
  63. 123 133
      src/artis-star/kernel/pdevs/mpi/ModelProxy.hpp
  64. 198 202
      src/artis-star/kernel/pdevs/multithreading/Coordinator.hpp
  65. 12 12
      src/artis-star/kernel/qss/Data.hpp
  66. 158 175
      src/artis-star/kernel/qss/Derivative.hpp
  67. 242 258
      src/artis-star/kernel/qss/Integrator.hpp
  68. 317 343
      src/artis-star/kernel/qss/Quantifier.hpp
  69. 130 136
      src/artis-star/kernel/sss/Coordinator.hpp
  70. 33 35
      src/artis-star/kernel/sss/Dynamics.hpp
  71. 82 85
      src/artis-star/kernel/sss/GraphManager.hpp
  72. 86 91
      src/artis-star/kernel/sss/Model.hpp
  73. 131 139
      src/artis-star/kernel/sss/Simulator.hpp

+ 2 - 3
src/apps/main.cpp

@@ -24,7 +24,6 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-int main()
-{
-    return 0;
+int main() {
+  return 0;
 }

+ 200 - 201
src/artis-star/common/Any.hpp

@@ -1,5 +1,5 @@
 /**
- * @file Any.hpp
+ * @file common/Any.hpp
  * @author The ARTIS Development Team
  * See the AUTHORS or Authors.txt file
  */
@@ -35,230 +35,229 @@
 #include <vector>
 
 namespace artis {
-    namespace common {
+namespace common {
 
-        class Any {
-        private:
-            struct base {
-                virtual ~base() { }
+class Any {
+private:
+  struct base {
+    virtual ~base() {}
 
-                virtual base* clone() const = 0;
-            };
+    virtual base *clone() const = 0;
+  };
 
-            template<typename T, typename V>
-            struct data : base {
-                data(V T::* const& value)
-                        :value_(value) { }
+  template<typename T, typename V>
+  struct data : base {
+    data(V T::* const &value)
+        : value_(value) {}
 
-                base* clone() const { return new data<T, V>(*this); }
+    base *clone() const { return new data<T, V>(*this); }
 
-                V T::* value_;
-            };
+    V T::* value_;
+  };
 
-            base* ptr_;
+  base *ptr_;
 
-        public:
-            Any()
-                    :ptr_(nullptr) { }
+public:
+  Any()
+      : ptr_(nullptr) {}
 
-            template<typename T, typename V>
-            Any(V T::* const& value)
-                    : ptr_(new data<T, V>(value)) { }
+  template<typename T, typename V>
+  Any(V T::* const &value)
+      : ptr_(new data<T, V>(value)) {}
 
-            Any(Any const& other)
-                    :ptr_(other.ptr_ ? other.ptr_->clone() : nullptr) { }
+  Any(Any const &other)
+      : ptr_(other.ptr_ ? other.ptr_->clone() : nullptr) {}
 
-            virtual ~Any() { if (ptr_) delete ptr_; }
+  virtual ~Any() {
+    if (ptr_)
+      delete ptr_;
+  }
 
-            void operator=(Any const& other) { Any(other).swap(*this); }
+  void operator=(Any const &other) { Any(other).swap(*this); }
 
-            void swap(Any& other) { std::swap(ptr_, other.ptr_); }
+  void swap(Any &other) { std::swap(ptr_, other.ptr_); }
 
-            template<typename T, typename V>
-            V T::* get() const { return dynamic_cast < data<T, V>* >(ptr_)->value_; }
+  template<typename T, typename V>
+  V T::* get() const { return dynamic_cast < data<T, V> * >(ptr_)->value_; }
 
-            bool is_null() const { return ptr_ == nullptr; }
+  bool is_null() const { return ptr_ == nullptr; }
 
-            template<typename T, typename V>
-            void put(T* o, const V& value)
-            {
-                V T::* p = dynamic_cast <data<T, V>* >(ptr_)->value_;
-                o->*(p) = value;
-            }
+  template<typename T, typename V>
+  void put(T *o, const V &value) {
+    V T::* p = dynamic_cast <data<T, V> * >(ptr_)->value_;
+    o->*(p) = value;
+  }
 
-            template<typename T>
-            void restore(T* o, const common::Value& value)
-            {
-                if (value.is_type<double>()) {
-                    double v;
-
-                    value(v);
-                    put(o, v);
-                } else if (value.is_type<unsigned int>()) {
-                    unsigned int v;
-
-                    value(v);
-                    put(o, v);
-                } else if (value.is_type<int>()) {
-                    int v;
-
-                    value(v);
-                    put(o, v);
-                } else if (value.is_type<bool>()) {
-                    bool v;
-
-                    value(v);
-                    put(o, v);
-                } else if (value.is_type<std::vector<double> >()) {
-                    std::vector<double> v;
-
-                    value(v);
-                    put(o, v);
-                } else if (value.is_type<std::vector<unsigned int> >()) {
-                    std::vector<unsigned int> v;
-
-                    value(v);
-                    put(o, v);
-                } else if (value.is_type<std::vector<int> >()) {
-                    std::vector<int> v;
-
-                    value(v);
-                    put(o, v);
-                } else if (value.is_type<std::vector<bool> >()) {
-                    std::vector<bool> v;
-
-                    value(v);
-                    put(o, v);
-                } else {
-                    assert(false);
-                }
-            }
+  template<typename T>
+  void restore(T *o, const common::Value &value) {
+    if (value.is_type<double>()) {
+      double v;
+
+      value(v);
+      put(o, v);
+    } else if (value.is_type<unsigned int>()) {
+      unsigned int v;
+
+      value(v);
+      put(o, v);
+    } else if (value.is_type<int>()) {
+      int v;
+
+      value(v);
+      put(o, v);
+    } else if (value.is_type<bool>()) {
+      bool v;
+
+      value(v);
+      put(o, v);
+    } else if (value.is_type<std::vector<double> >()) {
+      std::vector<double> v;
+
+      value(v);
+      put(o, v);
+    } else if (value.is_type<std::vector<unsigned int> >()) {
+      std::vector<unsigned int> v;
+
+      value(v);
+      put(o, v);
+    } else if (value.is_type<std::vector<int> >()) {
+      std::vector<int> v;
 
-            template<typename T>
-            common::Value save(const T* o) const
-            {
-                if (ptr_) {
-                    data<T, double>* q_double =
-                            dynamic_cast < data<T, double>* >(ptr_);
-
-                    if (q_double) {
-                        return common::Value(o->*(q_double->value_));
-                    } else {
-                        data<T, unsigned int>* q_uint =
-                                dynamic_cast < data<T, unsigned int>* >(ptr_);
-
-                        if (q_uint) {
-                            return common::Value(o->*(q_uint->value_));
-                        } else {
-                            data<T, int>* q_int =
-                                    dynamic_cast < data<T, int>* >(ptr_);
-
-                            if (q_int) {
-                                return common::Value(o->*(q_int->value_));
-                            } else {
-                                data<T, bool>* q_bool =
-                                        dynamic_cast < data<T, bool>* >(ptr_);
-
-                                if (q_bool) {
-                                    return common::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 common::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 common::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 common::Value(
-                                                        o->*(q_bool_v->value_));
-                                            }
-                                        }
-                                    }
-                                }
-                            }
-                        }
-                    }
+      value(v);
+      put(o, v);
+    } else if (value.is_type<std::vector<bool> >()) {
+      std::vector<bool> v;
+
+      value(v);
+      put(o, v);
+    } else {
+      assert(false);
+    }
+  }
+
+  template<typename T>
+  common::Value save(const T *o) const {
+    if (ptr_) {
+      data<T, double> *q_double =
+          dynamic_cast < data<T, double> * >(ptr_);
+
+      if (q_double) {
+        return common::Value(o->*(q_double->value_));
+      } else {
+        data<T, unsigned int> *q_uint =
+            dynamic_cast < data<T, unsigned int> * >(ptr_);
+
+        if (q_uint) {
+          return common::Value(o->*(q_uint->value_));
+        } else {
+          data<T, int> *q_int =
+              dynamic_cast < data<T, int> * >(ptr_);
+
+          if (q_int) {
+            return common::Value(o->*(q_int->value_));
+          } else {
+            data<T, bool> *q_bool =
+                dynamic_cast < data<T, bool> * >(ptr_);
+
+            if (q_bool) {
+              return common::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 common::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 common::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 common::Value(
+                        o->*(q_bool_v->value_));
+                  }
                 }
-                assert(false);
-                return common::Value();
+              }
             }
-
-            template<typename T>
-            std::string to_string(const T* o) const
-            {
-                if (ptr_) {
-                    data<T, double>* q_double =
-                            dynamic_cast < data<T, double>* >(ptr_);
-
-                    if (q_double) {
-                        return std::to_string(o->*(q_double->value_));
-                    } else {
-                        data<T, unsigned int>* q_uint =
-                                dynamic_cast < data<T, unsigned int>* >(ptr_);
-
-                        if (q_uint) {
-                            return std::to_string(o->*(q_uint->value_));
-                        } else {
-                            data<T, int>* q_int =
-                                    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_);
-
-                                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<
-                                                    double> >* >(ptr_);
-
-                                    if (q_double_v) {
-                                        return "";
-                                    } else {
-                                        data<T, std::vector<int> >* q_int_v =
-                                                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<
-                                                            bool> >* >(ptr_);
-
-                                            if (q_bool_v) {
-                                                return "";
-                                            } else {
-                                                return "NA";
-                                            }
-                                        }
-                                    }
-                                }
-                            }
-                        }
-                    }
+          }
+        }
+      }
+    }
+    assert(false);
+    return common::Value();
+  }
+
+  template<typename T>
+  std::string to_string(const T *o) const {
+    if (ptr_) {
+      data<T, double> *q_double =
+          dynamic_cast < data<T, double> * >(ptr_);
+
+      if (q_double) {
+        return std::to_string(o->*(q_double->value_));
+      } else {
+        data<T, unsigned int> *q_uint =
+            dynamic_cast < data<T, unsigned int> * >(ptr_);
+
+        if (q_uint) {
+          return std::to_string(o->*(q_uint->value_));
+        } else {
+          data<T, int> *q_int =
+              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_);
+
+            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<
+                      double> > * >(ptr_);
+
+              if (q_double_v) {
+                return "";
+              } else {
+                data<T, std::vector<int> > *q_int_v =
+                    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<
+                          bool> > * >(ptr_);
+
+                  if (q_bool_v) {
+                    return "";
+                  } else {
                     return "NA";
+                  }
                 }
+              }
             }
-        };
-
+          }
+        }
+      }
+    } else {
+      return "NA";
     }
+  }
+};
+
+}
 }
 
 #endif

+ 38 - 41
src/artis-star/common/Bag.hpp

@@ -1,5 +1,5 @@
 /**
- * @file Bag.hpp
+ * @file common/Bag.hpp
  * @author The ARTIS Development Team
  * See the AUTHORS or Authors.txt file
  */
@@ -25,7 +25,7 @@
  */
 
 #ifndef COMMON_BAG
-#define COMMON_BAG 1
+#define COMMON_BAG
 
 #include <artis-star/common/ExternalEvent.hpp>
 
@@ -36,58 +36,55 @@
 #include <vector>
 
 namespace artis {
-    namespace common {
+namespace common {
 
-        template<class Time>
-        class ExternalEvent;
+template<class Time>
+class ExternalEvent;
 
-        template<class Time>
-        class Bag : public std::vector<ExternalEvent<Time> > {
-        public:
-            Bag() = default;
+template<class Time>
+class Bag : public std::vector<ExternalEvent<Time> > {
+public:
+  Bag() = default;
 
-            Bag(const ExternalEvent<Time>& event) { this->push_back(event); }
+  Bag(const ExternalEvent<Time> &event) { this->push_back(event); }
 
-            virtual ~Bag() = default;
+  virtual ~Bag() = default;
 
-            std::string to_string() const
-            {
-                std::ostringstream ss;
+  std::string to_string() const {
+    std::ostringstream ss;
 
-                ss << "{ ";
-                for (typename Bag<Time>::const_iterator it =
-                        Bag<Time>::begin();
-                     it != Bag<Time>::end(); ++it) {
-                    ss << it->to_string() << " ";
-                }
-                ss << "}";
-                return ss.str();
-            }
+    ss << "{ ";
+    for (typename Bag<Time>::const_iterator it =
+        Bag<Time>::begin();
+         it != Bag<Time>::end(); ++it) {
+      ss << it->to_string() << " ";
+    }
+    ss << "}";
+    return ss.str();
+  }
 
-        private:
-            friend class boost::serialization::access;
+private:
+  friend class boost::serialization::access;
 
-            template<class Archive>
-            void save(Archive& ar, const unsigned int version) const
-            {
-                (void) version;
+  template<class Archive>
+  void save(Archive &ar, const unsigned int version) const {
+    (void) version;
 
-                ar & *dynamic_cast < const std::vector<ExternalEvent<Time> >* >(
-                        this);
-            }
+    ar & *dynamic_cast < const std::vector<ExternalEvent<Time> > * >(
+        this);
+  }
 
-            template<class Archive>
-            void load(Archive& ar, const unsigned int version)
-            {
-                (void) version;
+  template<class Archive>
+  void load(Archive &ar, const unsigned int version) {
+    (void) version;
 
-                ar & *dynamic_cast < std::vector<ExternalEvent<Time> >* >(this);
-            }
+    ar & *dynamic_cast < std::vector<ExternalEvent<Time> > * >(this);
+  }
 
-            BOOST_SERIALIZATION_SPLIT_MEMBER()
-        };
+  BOOST_SERIALIZATION_SPLIT_MEMBER()
+};
 
-    }
+}
 } // namespace artis common
 
 #endif

+ 111 - 120
src/artis-star/common/Coordinator.hpp

@@ -1,5 +1,5 @@
 /**
- * @file Coordinator.hpp
+ * @file common/Coordinator.hpp
  * @author The ARTIS Development Team
  * See the AUTHORS or Authors.txt file
  */
@@ -36,134 +36,125 @@
 #include <sstream>
 
 namespace artis {
-    namespace common {
-
-        template<class Time>
-        class Model;
-
-        template<class Time>
-        class GraphManager;
-
-        template<class Time>
-        class Coordinator : public virtual Model<Time> {
-        public :
-            Coordinator(const std::string& name)
-                    :Model<Time>(name) { }
-
-            virtual ~Coordinator() { }
-
-            virtual GraphManager<Time>& get_graph_manager() = 0;
-
-            virtual const GraphManager<Time>& get_graph_manager() const = 0;
-
-            virtual const Model<Time>* get_submodel(unsigned int index) const
-            {
-                const GraphManager<Time>& graph_manager = get_graph_manager();
-                typename common::ModelMap<Time>::const_iterator it = graph_manager.child_map().find(
-                        index);
-
-                if (it != graph_manager.child_map().end()) {
-                    return it->second;
-                } else {
-                    return nullptr;
-                }
-            }
-
-            virtual const Model<Time>* get_submodel(unsigned int index, unsigned int rank) const
-            {
-                const GraphManager<Time>& graph_manager = get_graph_manager();
-                typename common::ModelsMap<Time>::const_iterator it = graph_manager.children_map().find(
-                        index);
-
-                if (it != graph_manager.children_map().end() and it->second.size() > rank) {
-                    return it->second.at(rank);
-                } else {
-                    return nullptr;
-                }
-            }
-
-            virtual unsigned int get_submodel_number(unsigned int index) const
-            {
-                const GraphManager<Time>& graph_manager = get_graph_manager();
-                typename common::ModelsMap<Time>::const_iterator it = graph_manager.children_map().find(
-                        index);
-
-                if (it != graph_manager.children_map().end()) {
-                    return it->second.size();
-                } else {
-                    return 0;
-                }
-            }
-
-            void input_port(common::Port p) { Coordinator<Time>::add_in_port(p); }
-
-            void input_ports(std::initializer_list<common::Port> list)
-            {
-                for (typename std::initializer_list<common::Port>::iterator it = list.begin();
-                     it != list.end();
-                     ++it) {
-                    Coordinator<Time>::add_in_port(*it);
-                }
-            }
-
-            virtual bool is_atomic() const { return false; }
-
-            void output_port(common::Port p) { Coordinator<Time>::add_out_port(p); }
-
-            void output_ports(std::initializer_list<common::Port> list)
-            {
-                for (typename std::initializer_list<common::Port>::iterator it = list.begin();
-                     it != list.end();
-                     ++it) {
-                    Coordinator<Time>::add_out_port(*it);
-                }
-            }
-
-            virtual void remove_model(const typename Time::type& t, common::Model<Time>* model)
-            {
-                model->finish(t);
-            }
-
-            void restore(const common::context::State<Time>& state)
-            {
-                Model<Time>::restore(state);
-                get_graph_manager().restore(state);
-            }
-
-            void save(common::context::State<Time>& state) const
-            {
-                Model<Time>::save(state);
-                get_graph_manager().save(state);
-            }
-
-            virtual std::string to_string(int /* level */) const
-            {
-                std::ostringstream ss;
-
-                ss << "Coordinator " << Coordinator<Time>::get_name();
-                return ss.str();
-            }
+namespace common {
 
-// DEVS methods
-            virtual void finish(const typename Time::type& t) = 0;
+template<class Time>
+class Model;
+
+template<class Time>
+class GraphManager;
+
+template<class Time>
+class Coordinator : public virtual Model<Time> {
+public :
+  Coordinator(const std::string &name)
+      : Model<Time>(name) {}
+
+  virtual ~Coordinator() {}
+
+  virtual GraphManager<Time> &get_graph_manager() = 0;
+
+  virtual const GraphManager<Time> &get_graph_manager() const = 0;
+
+  virtual const Model<Time> *get_submodel(unsigned int index) const {
+    const GraphManager<Time> &graph_manager = get_graph_manager();
+    typename common::ModelMap<Time>::const_iterator it = graph_manager.child_map().find(
+        index);
 
-            virtual common::Value
-            observe(const typename Time::type& t, unsigned int index) const = 0;
+    if (it != graph_manager.child_map().end()) {
+      return it->second;
+    } else {
+      return nullptr;
+    }
+  }
+
+  virtual const Model<Time> *get_submodel(unsigned int index, unsigned int rank) const {
+    const GraphManager<Time> &graph_manager = get_graph_manager();
+    typename common::ModelsMap<Time>::const_iterator it = graph_manager.children_map().find(
+        index);
 
-            virtual void output(const typename Time::type& t) = 0;
+    if (it != graph_manager.children_map().end() and it->second.size() > rank) {
+      return it->second.at(rank);
+    } else {
+      return nullptr;
+    }
+  }
 
-            virtual void
-            post_event(const typename Time::type& t, const common::ExternalEvent<Time>& event) = 0;
+  virtual unsigned int get_submodel_number(unsigned int index) const {
+    const GraphManager<Time> &graph_manager = get_graph_manager();
+    typename common::ModelsMap<Time>::const_iterator it = graph_manager.children_map().find(
+        index);
 
-            virtual typename Time::type dispatch_events(const common::Bag<Time>& bag,
-                    const typename Time::type& t) = 0;
+    if (it != graph_manager.children_map().end()) {
+      return it->second.size();
+    } else {
+      return 0;
+    }
+  }
+
+  void input_port(common::Port p) { Coordinator<Time>::add_in_port(p); }
+
+  void input_ports(std::initializer_list<common::Port> list) {
+    for (typename std::initializer_list<common::Port>::iterator it = list.begin();
+         it != list.end();
+         ++it) {
+      Coordinator<Time>::add_in_port(*it);
+    }
+  }
 
-            virtual typename Time::type start(const typename Time::type& t) = 0;
+  virtual bool is_atomic() const { return false; }
 
-            virtual typename Time::type transition(const typename Time::type& t) = 0;
-        };
+  void output_port(common::Port p) { Coordinator<Time>::add_out_port(p); }
 
+  void output_ports(std::initializer_list<common::Port> list) {
+    for (typename std::initializer_list<common::Port>::iterator it = list.begin();
+         it != list.end();
+         ++it) {
+      Coordinator<Time>::add_out_port(*it);
     }
+  }
+
+  virtual void remove_model(const typename Time::type &t, common::Model<Time> *model) {
+    model->finish(t);
+  }
+
+  void restore(const common::context::State<Time> &state) {
+    Model<Time>::restore(state);
+    get_graph_manager().restore(state);
+  }
+
+  void save(common::context::State<Time> &state) const {
+    Model<Time>::save(state);
+    get_graph_manager().save(state);
+  }
+
+  virtual std::string to_string(int /* level */) const {
+    std::ostringstream ss;
+
+    ss << "Coordinator " << Coordinator<Time>::get_name();
+    return ss.str();
+  }
+
+// DEVS methods
+  virtual void finish(const typename Time::type &t) = 0;
+
+  virtual common::Value
+  observe(const typename Time::type &t, unsigned int index) const = 0;
+
+  virtual void output(const typename Time::type &t) = 0;
+
+  virtual void
+  post_event(const typename Time::type &t, const common::ExternalEvent<Time> &event) = 0;
+
+  virtual typename Time::type dispatch_events(const common::Bag<Time> &bag,
+                                              const typename Time::type &t) = 0;
+
+  virtual typename Time::type start(const typename Time::type &t) = 0;
+
+  virtual typename Time::type transition(const typename Time::type &t) = 0;
+};
+
+}
 } // namespace artis common
 
 #endif

+ 85 - 90
src/artis-star/common/ExternalEvent.hpp

@@ -1,5 +1,5 @@
 /**
- * @file ExternalEvent.hpp
+ * @file common/ExternalEvent.hpp
  * @author The ARTIS Development Team
  * See the AUTHORS or Authors.txt file
  */
@@ -25,7 +25,7 @@
  */
 
 #ifndef COMMON_EXTERNAL_EVENT
-#define COMMON_EXTERNAL_EVENT 1
+#define COMMON_EXTERNAL_EVENT
 
 #include <artis-star/common/Model.hpp>
 #include <artis-star/common/Node.hpp>
@@ -39,124 +39,119 @@
 #include <vector>
 
 namespace artis {
-    namespace common {
+namespace common {
 
-        template<class Time>
-        class Node;
+template<class Time>
+class Node;
 
-        template<class Time>
-        class Model;
+template<class Time>
+class Model;
 
-        template<class Time>
-        class ExternalEvent {
-        public:
-            ExternalEvent(const Value& data)
-                    :
-                    _port_index(-1), _model(nullptr), _data(data) { }
+template<class Time>
+class ExternalEvent {
+public:
+  ExternalEvent(const Value &data)
+      :
+      _port_index(-1), _model(nullptr), _data(data) {}
 
-            ExternalEvent(int port_index)
-                    :
-                    _port_index(port_index), _model(nullptr), _data(Value()) { }
+  ExternalEvent(int port_index)
+      :
+      _port_index(port_index), _model(nullptr), _data(Value()) {}
 
-            ExternalEvent(int port_index, const Value& data)
-                    :
-                    _port_index(port_index), _model(nullptr), _data(data) { }
+  ExternalEvent(int port_index, const Value &data)
+      :
+      _port_index(port_index), _model(nullptr), _data(data) {}
 
-            ExternalEvent(const Node<Time>& node, const Value& data)
-                    :
-                    _port_index(node.get_port_index()),
-                    _model(node.get_model()),
-                    _data(data) { }
+  ExternalEvent(const Node<Time> &node, const Value &data)
+      :
+      _port_index(node.get_port_index()),
+      _model(node.get_model()),
+      _data(data) {}
 
-            ExternalEvent(const ExternalEvent& event)
-                    :
-                    _port_index(event._port_index), _model(event._model),
-                    _data(event._data) { }
+  ExternalEvent(const ExternalEvent &event)
+      :
+      _port_index(event._port_index), _model(event._model),
+      _data(event._data) {}
 
-            ExternalEvent()
-                    :_port_index(-2), _model(nullptr) { }
+  ExternalEvent()
+      : _port_index(-2), _model(nullptr) {}
 
-            virtual ~ExternalEvent() = default;
+  virtual ~ExternalEvent() = default;
 
-            const Value& data() const { return _data; }
+  const Value &data() const { return _data; }
 
-            void data(const Value& data) { _data = data; }
+  void data(const Value &data) { _data = data; }
 
-            Model<Time>* get_model() const { return _model; }
+  Model<Time> *get_model() const { return _model; }
 
-            bool is_void() const { return _port_index == -2; }
+  bool is_void() const { return _port_index == -2; }
 
-            bool on_port(int port_index) const
-            {
+  bool on_port(int port_index) const {
 
-                assert(_port_index != -1);
+    assert(_port_index != -1);
 
-                return _port_index == port_index;
-            }
+    return _port_index == port_index;
+  }
 
-            ExternalEvent& operator=(const ExternalEvent& e)
-            {
-                _port_index = e._port_index;
-                _model = e._model;
-                _data = e._data;
-                return *this;
-            }
+  ExternalEvent &operator=(const ExternalEvent &e) {
+    _port_index = e._port_index;
+    _model = e._model;
+    _data = e._data;
+    return *this;
+  }
 
-            int port_index() const
-            {
+  int port_index() const {
 
-                assert(_port_index != -1);
+    assert(_port_index != -1);
 
-                return _port_index;
-            }
+    return _port_index;
+  }
 
-            void set_model(Model<Time>* model) { _model = model; }
+  void set_model(Model<Time> *model) { _model = model; }
 
-            std::string to_string() const
-            {
-                std::ostringstream ss;
+  std::string to_string() const {
+    std::ostringstream ss;
 
-                ss << "( ";
-                if (_port_index != -1) {
-                    ss << _port_index << " , ";
-                }
-                ss << (_model ? _model->get_name() : "<>")
-                   << " , ";
-                if (not _data.empty()) {
-                    ss << _data.to_string();
-                } else {
-                    ss << "null";
-                }
-                ss << " )";
-                return ss.str();
-            }
+    ss << "( ";
+    if (_port_index != -1) {
+      ss << _port_index << " , ";
+    }
+    ss << (_model ? _model->get_name() : "<>")
+       << " , ";
+    if (not _data.empty()) {
+      ss << _data.to_string();
+    } else {
+      ss << "null";
+    }
+    ss << " )";
+    return ss.str();
+  }
 
-            static ExternalEvent Void;
+  static ExternalEvent Void;
 
-        private:
-            friend class boost::serialization::access;
+private:
+  friend class boost::serialization::access;
 
-            template<class Archive>
-            void serialize(Archive& ar, const unsigned int version)
-            {
-                (void) version;
+  template<class Archive>
+  void serialize(Archive &ar, const unsigned int version) {
+    (void) version;
 
-                ar & _port_index;
-                _model = 0;
-                // ar & _model;
-                ar & _data;
-                // ar & _model->get_name();
-            }
+    ar & _port_index;
+    _model = 0;
+    // ar & _model;
+    ar & _data;
+    // ar & _model->get_name();
+  }
 
-            int _port_index;
-            Model<Time>* _model;
-            Value _data;
-        };
+  int _port_index;
+  Model<Time> *_model;
+  Value _data;
+};
 
-        template<class Time>
-        ExternalEvent<Time> ExternalEvent<Time>::Void;
+template<class Time>
+ExternalEvent<Time> ExternalEvent<Time>::Void;
 
-    }
+}
 } // namespace artis common
 
 #endif

+ 67 - 70
src/artis-star/common/GraphManager.hpp

@@ -36,78 +36,75 @@
 #include <sstream>
 
 namespace artis {
-    namespace common {
-
-        template<class Time>
-        class GraphManager {
-        public:
-            GraphManager(common::Coordinator<Time>* coordinator)
-                    :
-                    _coordinator(coordinator) { }
-
-            virtual ~GraphManager() { }
-
-            virtual void add_child(unsigned int index, common::Model<Time>* child)
-            {
-                _children.push_back(child);
-                _child_map[index] = child;
-                child->set_parent(_coordinator);
-            }
-
-            virtual void add_children(unsigned int index, common::Model<Time>* child)
-            {
-                _children.push_back(child);
-                if (_children_map.find(index) == _children_map.end()) {
-                    _children_map[index] = Models<Time>();
-                }
-                _children_map[index].push_back(child);
-                child->set_parent(_coordinator);
-            }
-
-            const common::Models<Time>& children() const { return _children; }
-
-            const common::ModelMap<Time>& child_map() const { return _child_map; }
-
-            common::Model<Time>* child_map(size_t index) const { return _child_map.at(index); }
-
-            const common::ModelsMap<Time>& children_map() const { return _children_map; }
-
-            common::Coordinator<Time>* coordinator() const { return _coordinator; }
-
-            virtual void remove_child(unsigned int index)
-            {
-                common::Model<Time>* child = _child_map[index];
-
-                _children.erase(std::find(_children.begin(), _children.end(), child));
-                _child_map[index] = nullptr;
-                _child_map.erase(index);
-            }
-
-            void restore(const common::context::State<Time>& state)
-            {
-                for(typename common::ModelMap<Time>::iterator it = _child_map.begin(); it != _child_map.end(); ++it) {
-                    it->second->restore(state.get_substate(it->first));
-                }
-            }
-
-            void save(common::context::State<Time>& state) const
-            {
-                for(typename common::ModelMap<Time>::const_iterator it = _child_map.begin(); it != _child_map.end(); ++it) {
-                    context::State<Time> substate;
-
-                    it->second->save(substate);
-                    state.add_substate(it->first, substate);
-                }
-            }
-
-        protected:
-            common::Models<Time> _children;
-            common::ModelMap<Time> _child_map;
-            common::ModelsMap<Time> _children_map;
-            common::Coordinator<Time>* _coordinator;
-        };
+namespace common {
+
+template<class Time>
+class GraphManager {
+public:
+  GraphManager(common::Coordinator<Time> *coordinator)
+      :
+      _coordinator(coordinator) {}
+
+  virtual ~GraphManager() {}
+
+  virtual void add_child(unsigned int index, common::Model<Time> *child) {
+    _children.push_back(child);
+    _child_map[index] = child;
+    child->set_parent(_coordinator);
+  }
+
+  virtual void add_children(unsigned int index, common::Model<Time> *child) {
+    _children.push_back(child);
+    if (_children_map.find(index) == _children_map.end()) {
+      _children_map[index] = Models<Time>();
+    }
+    _children_map[index].push_back(child);
+    child->set_parent(_coordinator);
+  }
+
+  const common::Models<Time> &children() const { return _children; }
+
+  const common::ModelMap<Time> &child_map() const { return _child_map; }
+
+  common::Model<Time> *child_map(size_t index) const { return _child_map.at(index); }
+
+  const common::ModelsMap<Time> &children_map() const { return _children_map; }
+
+  common::Coordinator<Time> *coordinator() const { return _coordinator; }
+
+  virtual void remove_child(unsigned int index) {
+    common::Model<Time> *child = _child_map[index];
 
+    _children.erase(std::find(_children.begin(), _children.end(), child));
+    _child_map[index] = nullptr;
+    _child_map.erase(index);
+  }
+
+  void restore(const common::context::State<Time> &state) {
+    for (typename common::ModelMap<Time>::iterator it = _child_map.begin(); it != _child_map.end();
+         ++it) {
+      it->second->restore(state.get_substate(it->first));
+    }
+  }
+
+  void save(common::context::State<Time> &state) const {
+    for (typename common::ModelMap<Time>::const_iterator it = _child_map.begin();
+         it != _child_map.end(); ++it) {
+      context::State<Time> substate;
+
+      it->second->save(substate);
+      state.add_substate(it->first, substate);
     }
+  }
+
+protected:
+  common::Models<Time> _children;
+  common::ModelMap<Time> _child_map;
+  common::ModelsMap<Time> _children_map;
+  common::Coordinator<Time> *_coordinator;
+};
+
+}
 } // namespace artis common
 
 #endif

+ 36 - 40
src/artis-star/common/InternalEvent.hpp

@@ -1,5 +1,5 @@
 /**
- * @file InternalEvent.hpp
+ * @file common/InternalEvent.hpp
  * @author The ARTIS Development Team
  * See the AUTHORS or Authors.txt file
  */
@@ -25,64 +25,60 @@
  */
 
 #ifndef COMMON_INTERNAL_EVENT
-#define COMMON_INTERNAL_EVENT 1
+#define COMMON_INTERNAL_EVENT
 
 #include <artis-star/common/Model.hpp>
 
 #include <functional>
 
 namespace artis {
-    namespace common {
+namespace common {
 
-        template<class Time>
-        class Model;
+template<class Time>
+class Model;
 
-        template<class Time>
-        class InternalEvent {
-        public:
-            InternalEvent(const typename Time::type& time, Model<Time>* model)
-                    :_time(time), _model(model) { }
+template<class Time>
+class InternalEvent {
+public:
+  InternalEvent(const typename Time::type &time, Model<Time> *model)
+      : _time(time), _model(model) {}
 
-            virtual ~InternalEvent() { }
+  virtual ~InternalEvent() {}
 
-            Model<Time>* get_model() const { return _model; }
+  Model<Time> *get_model() const { return _model; }
 
-            typename Time::type get_time() const { return _time; }
+  typename Time::type get_time() const { return _time; }
 
-            bool operator<(InternalEvent const& e) const
-            {
-                return _time < e._time;
-            }
+  bool operator<(InternalEvent const &e) const {
+    return _time < e._time;
+  }
 
-            bool operator>(InternalEvent const& e) const
-            {
-                return _time > e._time;
-            }
+  bool operator>(InternalEvent const &e) const {
+    return _time > e._time;
+  }
 
-            bool operator>=(InternalEvent const& e) const
-            {
-                return _time >= e._time;
-            }
+  bool operator>=(InternalEvent const &e) const {
+    return _time >= e._time;
+  }
 
-            bool operator==(InternalEvent const& e) const
-            {
-                return _time == e._time;
-            }
+  bool operator==(InternalEvent const &e) const {
+    return _time == e._time;
+  }
 
-            void set_time(typename Time::type time) { _time = time; }
+  void set_time(typename Time::type time) { _time = time; }
 
-        private:
-            typename Time::type _time;
-            Model<Time>* _model;
-        };
+private:
+  typename Time::type _time;
+  Model<Time> *_model;
+};
 
-        template<typename Event>
-        struct EventCompare
-                : std::binary_function<Event, Event, bool> {
-            bool operator()(const Event& left, const Event& right) const { return left >= right; }
-        };
+template<typename Event>
+struct EventCompare
+    : std::binary_function<Event, Event, bool> {
+  bool operator()(const Event &left, const Event &right) const { return left >= right; }
+};
 
-    }
+}
 } // namespace artis common
 
 #endif

+ 109 - 116
src/artis-star/common/Links.hpp

@@ -1,5 +1,5 @@
 /**
- * @file Links.hpp
+ * @file common/Links.hpp
  * @author The ARTIS Development Team
  * See the AUTHORS or Authors.txt file
  */
@@ -25,7 +25,7 @@
  */
 
 #ifndef COMMON_LINKS
-#define COMMON_LINKS 1
+#define COMMON_LINKS
 
 #include <artis-star/common/Node.hpp>
 #include <artis-star/common/utils/String.hpp>
@@ -34,121 +34,114 @@
 #include <sstream>
 
 namespace artis {
-    namespace common {
-
-        template<class Time>
-        class Node;
-
-        template<class Time>
-        class Links : public std::multimap<Node<Time>, Node<Time> > {
-            typedef std::multimap<Node<Time>, Node<Time> > type;
-
-        public:
-            typedef std::pair<
-                    typename Links<Time>::const_iterator,
-                    typename Links<Time>::const_iterator
-            > Result;
-
-            Links() { }
-
-            virtual ~Links() { }
-
-            void add(Model<Time>* out_model, unsigned int out_port_index,
-                    Model<Time>* in_model, unsigned int in_port_index)
-            {
-                type::insert(std::pair<Node<Time>, Node<Time> >(
-                        Node<Time>(out_model, out_port_index),
-                        Node<Time>(in_model, in_port_index)));
-            }
-
-            bool exist(Model<Time>* out_model,
-                    unsigned int out_port_index,
-                    Model<Time>* in_model,
-                    unsigned int in_port_index) const
-            {
-                std::pair<typename Links<Time>::const_iterator,
-                        typename Links<Time>::const_iterator> it =
-                        type::equal_range(Node<Time>(out_model, out_port_index));
-                typename Links<Time>::const_iterator it2 = it.first;
-                bool found = false;
-
-                while (not found and it2 != it.second) {
-                    found = it2->second == Node<Time>(
-                            in_model, in_port_index);
-                    ++it2;
-                }
-                return found;
-            }
-
-            typename Links<Time>::const_iterator
-            find(Model<Time>* out_model, unsigned int out_port_index,
-                    Model<Time>* in_model, unsigned int in_port_index) const
-            {
-                std::pair<typename Links<Time>::const_iterator,
-                        typename Links<Time>::const_iterator> it =
-                        type::equal_range(Node<Time>(out_model, out_port_index));
-                typename Links<Time>::const_iterator it2 = it.first;
-                bool found = false;
-
-                while (not found and it2 != it.second) {
-                    found = it2->second == Node<Time>(
-                            in_model, in_port_index);
-                    if (not found) {
-                        ++it2;
-                    }
-                }
-                return it2;
-            }
-
-            Links::Result find(Model<Time>* out_model, unsigned int out_port_index) const
-            {
-                return type::equal_range(common::Node<Time>(out_model, out_port_index));
-            }
-
-            void remove(common::Model<Time>* src_model, unsigned int src_port_index,
-                    common::Model<Time>* dst_model, unsigned int dst_port_index)
-            {
-                typename Links<Time>::const_iterator result = find(src_model, src_port_index,
-                        dst_model, dst_port_index);
-
-                this->erase(result);
-            }
-
-            void remove_links(common::Model<Time>* model)
-            {
-                typename Links<Time>::iterator it = this->begin();
-
-                while (it != this->end()) {
-                    if (it->first.get_model() == model or it->second.get_model() == model) {
-                        this->erase(it);
-                        it = this->begin();
-                    } else {
-                        ++it;
-                    }
-                }
-            }
-
-            std::string to_string(int level = 0) const
-            {
-                std::stringstream ss;
-
-                ss << common::String::make_spaces(level * 2) << "Links:" << std::endl;
-                for (typename Links<Time>::const_iterator it = Links<Time>::begin();
-                     it != Links<Time>::end(); ++it) {
-                    ss << common::String::make_spaces((level + 1) * 2)
-                       << it->first.get_model()->get_name() << "::"
-                       << it->first.get_model()->get_out_port_name(
-                               it->first.get_port_index())
-                       << " -> "
-                       << it->second.get_model()->get_name() << "::"
-                       << it->second.get_model()->get_out_port_name(
-                               it->second.get_port_index()) << std::endl;
-                }
-                return ss.str();
-            }
-        };
-
+namespace common {
+
+template<class Time>
+class Node;
+
+template<class Time>
+class Links : public std::multimap<Node<Time>, Node<Time> > {
+  typedef std::multimap<Node<Time>, Node<Time> > type;
+
+public:
+  typedef std::pair<
+      typename Links<Time>::const_iterator,
+      typename Links<Time>::const_iterator
+  > Result;
+
+  Links() {}
+
+  virtual ~Links() {}
+
+  void add(Model<Time> *out_model, unsigned int out_port_index,
+           Model<Time> *in_model, unsigned int in_port_index) {
+    type::insert(std::pair<Node<Time>, Node<Time> >(
+        Node<Time>(out_model, out_port_index),
+        Node<Time>(in_model, in_port_index)));
+  }
+
+  bool exist(Model<Time> *out_model,
+             unsigned int out_port_index,
+             Model<Time> *in_model,
+             unsigned int in_port_index) const {
+    std::pair<typename Links<Time>::const_iterator,
+              typename Links<Time>::const_iterator> it =
+        type::equal_range(Node<Time>(out_model, out_port_index));
+    typename Links<Time>::const_iterator it2 = it.first;
+    bool found = false;
+
+    while (not found and it2 != it.second) {
+      found = it2->second == Node<Time>(
+          in_model, in_port_index);
+      ++it2;
+    }
+    return found;
+  }
+
+  typename Links<Time>::const_iterator
+  find(Model<Time> *out_model, unsigned int out_port_index,
+       Model<Time> *in_model, unsigned int in_port_index) const {
+    std::pair<typename Links<Time>::const_iterator,
+              typename Links<Time>::const_iterator> it =
+        type::equal_range(Node<Time>(out_model, out_port_index));
+    typename Links<Time>::const_iterator it2 = it.first;
+    bool found = false;
+
+    while (not found and it2 != it.second) {
+      found = it2->second == Node<Time>(
+          in_model, in_port_index);
+      if (not found) {
+        ++it2;
+      }
+    }
+    return it2;
+  }
+
+  Links::Result find(Model<Time> *out_model, unsigned int out_port_index) const {
+    return type::equal_range(common::Node<Time>(out_model, out_port_index));
+  }
+
+  void remove(common::Model<Time> *src_model, unsigned int src_port_index,
+              common::Model<Time> *dst_model, unsigned int dst_port_index) {
+    typename Links<Time>::const_iterator result = find(src_model, src_port_index,
+                                                       dst_model, dst_port_index);
+
+    this->erase(result);
+  }
+
+  void remove_links(common::Model<Time> *model) {
+    typename Links<Time>::iterator it = this->begin();
+
+    while (it != this->end()) {
+      if (it->first.get_model() == model or it->second.get_model() == model) {
+        this->erase(it);
+        it = this->begin();
+      } else {
+        ++it;
+      }
     }
+  }
+
+  std::string to_string(int level = 0) const {
+    std::stringstream ss;
+
+    ss << common::String::make_spaces(level * 2) << "Links:" << std::endl;
+    for (typename Links<Time>::const_iterator it = Links<Time>::begin();
+         it != Links<Time>::end(); ++it) {
+      ss << common::String::make_spaces((level + 1) * 2)
+         << it->first.get_model()->get_name() << "::"
+         << it->first.get_model()->get_out_port_name(
+             it->first.get_port_index())
+         << " -> "
+         << it->second.get_model()->get_name() << "::"
+         << it->second.get_model()->get_out_port_name(
+             it->second.get_port_index()) << std::endl;
+    }
+    return ss.str();
+  }
+};
+
+}
 } // namespace artis common
 
 #endif

+ 1 - 1
src/artis-star/common/Macro.hpp

@@ -1,5 +1,5 @@
 /**
- * @file Macro.hpp
+ * @file common/Macro.hpp
  * @author The ARTIS Development Team
  * See the AUTHORS or Authors.txt file
  */

+ 234 - 259
src/artis-star/common/Model.hpp

@@ -1,5 +1,5 @@
 /**
- * @file Model.hpp
+ * @file common/Model.hpp
  * @author The ARTIS Development Team
  * See the AUTHORS or Authors.txt file
  */
@@ -40,318 +40,293 @@
 #include <sstream>
 
 namespace artis {
-    namespace common {
+namespace common {
 
-        template<class Time>
-        class ExternalEvent;
+template<class Time>
+class ExternalEvent;
 
-        template<class Time>
-        class InternalEvent;
+template<class Time>
+class InternalEvent;
 
-        template<class Time>
-        class Bag;
+template<class Time>
+class Bag;
 
-        struct Port {
-            unsigned int index;
-            std::string name;
-        };
+struct Port {
+  unsigned int index;
+  std::string name;
+};
 
-        typedef std::vector<unsigned int> Ports;
-        typedef std::map<unsigned int, std::string> PortMap;
+typedef std::vector<unsigned int> Ports;
+typedef std::map<unsigned int, std::string> PortMap;
 
-        template<class Time>
-        class Model {
-        public:
-            Model(const std::string& name)
-                    :
-                    _tl(0), _tn(0), _parent(0), _name(name), _inputs(0) { }
+template<class Time>
+class Model {
+public:
+  Model(const std::string &name)
+      :
+      _tl(0), _tn(0), _parent(0), _name(name), _inputs(0) {}
 
-            virtual ~Model()
-            {
-                if (_inputs) {
-                    delete _inputs;
-                }
-            }
+  virtual ~Model() {
+    if (_inputs) {
+      delete _inputs;
+    }
+  }
+
+  // structure
+  void add_in_port(const Port &port) {
+    assert(not exist_in_port(port.index));
+
+    _in_ports.push_back(port.index);
+    _in_port_map[port.index] = port.name;
+  }
+
+  void add_out_port(const Port &port) {
+    assert(not exist_out_port(port.index));
+
+    _out_ports.push_back(port.index);
+    _out_port_map[port.index] = port.name;
+  }
+
+  void delete_in_port(const Port &port) {
+    assert(not exist_in_port(port.index));
+
+    _in_ports.erase(std::find(_in_ports.begin(), _in_ports.end(),
+                              port.index));
+    _in_port_map.erase(port.index);
+  }
+
+  void delete_out_port(const Port &port) {
+    assert(not exist_out_port(port.index));
+
+    _out_ports.erase(std::find(_out_ports.begin(), _out_ports.end(),
+                               port.index));
+    _out_port_map.erase(port.index);
+  }
+
+  bool exist_in_port(unsigned int port_index) const {
+    return _in_port_map.find(port_index) != _in_port_map.end();
+  }
+
+  bool exist_out_port(unsigned int port_index) const {
+    return _out_port_map.find(port_index) != _out_port_map.end();
+  }
 
-            // structure
-            void add_in_port(const Port& port)
-            {
-                assert(not exist_in_port(port.index));
+  std::string get_in_port_name(unsigned int port_index) const {
+    assert(exist_in_port(port_index));
 
-                _in_ports.push_back(port.index);
-                _in_port_map[port.index] = port.name;
-            }
+    return _in_port_map.find(port_index)->second;
+  }
 
-            void add_out_port(const Port& port)
-            {
-                assert(not exist_out_port(port.index));
+  size_t get_in_port_number() const { return _in_port_map.size(); }
 
-                _out_ports.push_back(port.index);
-                _out_port_map[port.index] = port.name;
-            }
+  std::string get_out_port_name(unsigned int port_index) const {
+    assert(exist_out_port(port_index));
 
-            void delete_in_port(const Port& port)
-            {
-                assert(not exist_in_port(port.index));
+    return _out_port_map.find(port_index)->second;
+  }
 
-                _in_ports.erase(std::find(_in_ports.begin(), _in_ports.end(),
-                        port.index));
-                _in_port_map.erase(port.index);
-            }
+  size_t get_out_port_number() const { return _out_port_map.size(); }
 
-            void delete_out_port(const Port& port)
-            {
-                assert(not exist_out_port(port.index));
+  const std::string &get_name() const { return _name; }
 
-                _out_ports.erase(std::find(_out_ports.begin(), _out_ports.end(),
-                        port.index));
-                _out_port_map.erase(port.index);
-            }
+  Model<Time> *get_parent() const { return _parent; }
 
-            bool exist_in_port(unsigned int port_index) const
-            {
-                return _in_port_map.find(port_index) != _in_port_map.end();
-            }
+  // TODO: to remove
+  virtual int get_receiver_number(typename Time::type t) {
+    (void) t;
 
-            bool exist_out_port(unsigned int port_index) const
-            {
-                return _out_port_map.find(port_index) != _out_port_map.end();
-            }
+    return 0;
+  }
 
-            std::string get_in_port_name(unsigned int port_index) const
-            {
-                assert(exist_in_port(port_index));
+  virtual const Model<Time> *get_submodel(unsigned int index) const {
+    (void) index;
 
-                return _in_port_map.find(port_index)->second;
-            }
+    assert(false);
 
-            size_t get_in_port_number() const { return _in_port_map.size(); }
+    return nullptr;
+  }
 
-            std::string get_out_port_name(unsigned int port_index) const
-            {
-                assert(exist_out_port(port_index));
+  virtual const Model<Time> *get_submodel(unsigned int index,
+                                          unsigned int rank) const {
+    (void) index;
+    (void) rank;
 
-                return _out_port_map.find(port_index)->second;
-            }
+    assert(false);
 
-            size_t get_out_port_number() const { return _out_port_map.size(); }
+    return nullptr;
+  }
 
-            const std::string& get_name() const { return _name; }
+  virtual unsigned int get_submodel_number(unsigned int index) const {
+    (void) index;
 
-            Model<Time>* get_parent() const { return _parent; }
+    assert(false);
 
-            // TODO: to remove
-            virtual int get_receiver_number(typename Time::type t)
-            {
-                (void) t;
+    return 0;
+  }
 
-                return 0;
-            }
+  virtual bool is_atomic() const = 0;
 
-            virtual const Model<Time>* get_submodel(unsigned int index) const
-            {
-                (void) index;
+  virtual bool is_remote() const { return false; }
 
-                assert(false);
+  virtual std::string observable_name(unsigned int observable_index) const {
+    (void) observable_index;
 
-                return nullptr;
-            }
+    assert(false);
 
-            virtual const Model<Time>* get_submodel(unsigned int index,
-                    unsigned int rank) const
-            {
-                (void) index;
-                (void) rank;
+    return std::string();
+  }
 
-                assert(false);
+  std::string path() const {
+    return (_parent != nullptr ? _parent->path() : "") + ":" + get_name();
+  }
 
-                return nullptr;
-            }
+  virtual void restore(const common::context::State<Time> &state) {
+    _tl = state.last_time();
+    _tn = state.next_time();
+  }
 
-            virtual unsigned int get_submodel_number(unsigned int index) const
-            {
-                (void) index;
+  virtual void save(common::context::State<Time> &state) const {
+    state.last_time(_tl);
+    state.next_time(_tn);
+  }
 
-                assert(false);
+  void set_parent(Model<Time> *parent) { _parent = parent; }
 
-                return 0;
-            }
+  virtual std::string to_string(int /* level */) const = 0;
 
-            virtual bool is_atomic() const = 0;
+  // event
+  void add_event(const common::ExternalEvent<Time> &message) {
+    if (_inputs == 0) {
+      _inputs = new Bag<Time>;
+    }
+    _inputs->push_back(message);
+  }
+
+  void clear_bag() {
+    if (_inputs) {
+      delete _inputs;
+      _inputs = 0;
+    }
+  }
+
+  unsigned int event_number() const {
+    return _inputs ? _inputs->size() : 0;
+  }
+
+  const common::Bag<Time> &get_bag() {
+    if (_inputs == 0) {
+      _inputs = new Bag<Time>;
+    }
+    return *_inputs;
+  }
 
-            virtual bool is_remote() const { return false; }
+  // time
+  typename Time::type get_tl() const { return _tl; }
 
-            virtual std::string observable_name(unsigned int observable_index) const
-            {
-                (void) observable_index;
+  typename Time::type get_tn() const { return _tn; }
 
-                assert(false);
+  // devs methods
+  virtual void finish(const typename Time::type &t) = 0;
 
-                return std::string();
-            }
+  virtual common::Value observe(const typename Time::type &t,
+                                unsigned int index) const = 0;
 
-            std::string path() const
-            {
-                return (_parent != nullptr ? _parent->path() : "") + ":" + get_name();
-            }
+  virtual void output(const typename Time::type &t) = 0;
 
-            virtual void restore(const common::context::State<Time>& state)
-            {
-                _tl = state.last_time();
-                _tn = state.next_time();
-            }
+  virtual void post_event(const typename Time::type &t,
+                          const common::ExternalEvent<Time> &event) = 0;
 
-            virtual void save(common::context::State<Time>& state) const
-            {
-                state.last_time(_tl);
-                state.next_time(_tn);
-            }
+  virtual typename Time::type start(const typename Time::type &t) = 0;
 
-            void set_parent(Model<Time>* parent) { _parent = parent; }
+  virtual typename Time::type transition(const typename Time::type &t) = 0;
 
-            virtual std::string to_string(int /* level */) const = 0;
+  virtual typename Time::type lookahead(const typename Time::type &t) const { return t; }
 
-            // event
-            void add_event(const common::ExternalEvent<Time>& message)
-            {
-                if (_inputs == 0) {
-                    _inputs = new Bag<Time>;
-                }
-                _inputs->push_back(message);
-            }
+  // scheduler
+  void handle(SchedulerHandle handle) { _handle.handle(handle); }
 
-            void clear_bag()
-            {
-                if (_inputs) {
-                    delete _inputs;
-                    _inputs = 0;
-                }
-            }
+  const SchedulerHandle &handle() const { return _handle.handle(); }
 
-            unsigned int event_number() const
-            {
-                return _inputs ? _inputs->size() : 0;
-            }
+protected:
+  typename Time::type _tl;
+  typename Time::type _tn;
 
-            const common::Bag<Time>& get_bag()
-            {
-                if (_inputs == 0) {
-                    _inputs = new Bag<Time>;
-                }
-                return *_inputs;
-            }
+private :
+  Model<Time> *_parent;
+  std::string _name;
+  Ports _in_ports;
+  PortMap _in_port_map;
+  Ports _out_ports;
+  PortMap _out_port_map;
 
-            // time
-            typename Time::type get_tl() const { return _tl; }
+  Bag<Time> *_inputs;
+  SchedulerHandle _handle;
+};
 
-            typename Time::type get_tn() const { return _tn; }
-
-            // devs methods
-            virtual void finish(const typename Time::type& t) = 0;
-
-            virtual common::Value observe(const typename Time::type& t,
-                    unsigned int index) const = 0;
-
-            virtual void output(const typename Time::type& t) = 0;
-
-            virtual void post_event(const typename Time::type& t,
-                    const common::ExternalEvent<Time>& event) = 0;
-
-            virtual typename Time::type start(const typename Time::type& t) = 0;
-
-            virtual typename Time::type transition(const typename Time::type& t) = 0;
-
-            virtual typename Time::type lookahead(const typename Time::type& t) const
-            { return t; }
-
-            // scheduler
-            void handle(SchedulerHandle handle) { _handle.handle(handle); }
-
-            const SchedulerHandle& handle() const { return _handle.handle(); }
-
-        protected:
-            typename Time::type _tl;
-            typename Time::type _tn;
-
-        private :
-            Model<Time>* _parent;
-            std::string _name;
-            Ports _in_ports;
-            PortMap _in_port_map;
-            Ports _out_ports;
-            PortMap _out_port_map;
-
-            Bag<Time>* _inputs;
-            SchedulerHandle _handle;
-        };
-
-        template<class Time>
-        class ModelMap : public std::map<unsigned int, Model<Time>*> {
-        public:
-            ModelMap() { }
-
-            virtual ~ModelMap() { }
-
-            std::string to_string() const
-            {
-                std::ostringstream ss;
-
-                ss << "{ ";
-                for (typename ModelMap<Time>::const_iterator it =
-                        ModelMap<Time>::begin();
-                     it != ModelMap<Time>::end(); ++it) {
-                    ss << it->second->get_name() << " ";
-                }
-                ss << "}";
-                return ss.str();
-            }
-        };
-
-        template<class Time>
-        class Models : public std::vector<Model<Time>*> {
-        public:
-            Models() { }
-
-            virtual ~Models() { }
-
-            std::string to_string() const
-            {
-                std::ostringstream ss;
-
-                ss << "{ ";
-                for (typename Models<Time>::const_iterator it =
-                        Models<Time>::begin();
-                     it != Models<Time>::end(); ++it) {
-                    ss << (*it)->get_name() << " ";
-                }
-                ss << "}";
-                return ss.str();
-            }
-        };
-
-        template<class Time>
-        class ModelsMap : public std::map<unsigned int, Models<Time> > {
-        public:
-            ModelsMap() { }
-
-            virtual ~ModelsMap() { }
-
-            std::string to_string() const
-            {
-                std::ostringstream ss;
-
-                ss << "{ ";
-                for (typename ModelsMap<Time>::const_iterator it =
-                        ModelsMap<Time>::begin();
-                     it != ModelsMap<Time>::end(); ++it) {
-                    ss << it->second.to_string() << " ";
-                }
-                ss << "}";
-                return ss.str();
-            }
-        };
+template<class Time>
+class ModelMap : public std::map<unsigned int, Model<Time> *> {
+public:
+  ModelMap() {}
 
+  virtual ~ModelMap() {}
+
+  std::string to_string() const {
+    std::ostringstream ss;
+
+    ss << "{ ";
+    for (typename ModelMap<Time>::const_iterator it =
+        ModelMap<Time>::begin();
+         it != ModelMap<Time>::end(); ++it) {
+      ss << it->second->get_name() << " ";
+    }
+    ss << "}";
+    return ss.str();
+  }
+};
+
+template<class Time>
+class Models : public std::vector<Model<Time> *> {
+public:
+  Models() {}
+
+  virtual ~Models() {}
+
+  std::string to_string() const {
+    std::ostringstream ss;
+
+    ss << "{ ";
+    for (typename Models<Time>::const_iterator it =
+        Models<Time>::begin();
+         it != Models<Time>::end(); ++it) {
+      ss << (*it)->get_name() << " ";
     }
+    ss << "}";
+    return ss.str();
+  }
+};
+
+template<class Time>
+class ModelsMap : public std::map<unsigned int, Models<Time> > {
+public:
+  ModelsMap() {}
+
+  virtual ~ModelsMap() {}
+
+  std::string to_string() const {
+    std::ostringstream ss;
+
+    ss << "{ ";
+    for (typename ModelsMap<Time>::const_iterator it =
+        ModelsMap<Time>::begin();
+         it != ModelsMap<Time>::end(); ++it) {
+      ss << it->second.to_string() << " ";
+    }
+    ss << "}";
+    return ss.str();
+  }
+};
+
+}
 } // namespace artis common
 
 #endif

+ 29 - 32
src/artis-star/common/Node.hpp

@@ -1,5 +1,5 @@
 /**
- * @file Node.hpp
+ * @file common/Node.hpp
  * @author The ARTIS Development Team
  * See the AUTHORS or Authors.txt file
  */
@@ -32,47 +32,44 @@
 #include <string>
 
 namespace artis {
-    namespace common {
+namespace common {
 
-        template<class Time>
-        class Model;
+template<class Time>
+class Model;
 
-        template<class Time>
-        class Node {
-        public :
-            Node(Model<Time>* model, unsigned int port_index)
-                    :_model(model), _port_index(port_index)
-            {
-                _id = std::hash<std::string>()(model->get_name() +
-                        std::to_string(port_index));
-            }
+template<class Time>
+class Node {
+public :
+  Node(Model<Time> *model, unsigned int port_index)
+      : _model(model), _port_index(port_index) {
+    _id = std::hash<std::string>()(model->get_name() +
+        std::to_string(port_index));
+  }
 
-            Node(const Node<Time>& other)
-                    :_model(other._model), _port_index(other._port_index), _id(other._id) { }
+  Node(const Node<Time> &other)
+      : _model(other._model), _port_index(other._port_index), _id(other._id) {}
 
-            virtual ~Node() { }
+  virtual ~Node() {}
 
-            bool operator<(const Node<Time>& o) const
-            {
-                return _id < o._id;
-            }
+  bool operator<(const Node<Time> &o) const {
+    return _id < o._id;
+  }
 
-            bool operator==(const Node<Time>& o) const
-            {
-                return _id == o._id;
-            }
+  bool operator==(const Node<Time> &o) const {
+    return _id == o._id;
+  }
 
-            unsigned int get_port_index() const { return _port_index; }
+  unsigned int get_port_index() const { return _port_index; }
 
-            Model<Time>* get_model() const { return _model; }
+  Model<Time> *get_model() const { return _model; }
 
-        private :
-            Model<Time>* _model;
-            unsigned int _port_index;
-            int _id;
-        };
+private :
+  Model<Time> *_model;
+  unsigned int _port_index;
+  int _id;
+};
 
-    }
+}
 } // namespace artis common
 
 #endif

+ 7 - 7
src/artis-star/common/Parameters.hpp

@@ -25,17 +25,17 @@
  */
 
 #ifndef COMMON_PARAMETERS
-#define COMMON_PARAMETERS 1
+#define COMMON_PARAMETERS
 
 namespace artis {
-    namespace common {
+namespace common {
 
-        class NoParameters {
-        public:
-            NoParameters() { }
-        };
+class NoParameters {
+public:
+  NoParameters() {}
+};
 
-    }
+}
 } // namespace artis common
 
 #endif

+ 73 - 77
src/artis-star/common/RootCoordinator.hpp

@@ -1,5 +1,5 @@
 /**
- * @file RootCoordinator.hpp
+ * @file common/RootCoordinator.hpp
  * @author The ARTIS Development Team
  * See the AUTHORS or Authors.txt file
  */
@@ -36,43 +36,41 @@
 #include <string>
 
 namespace artis {
-    namespace common {
-
-        template<class Time, class Coordinator>
-        class RootCoordinator {
-        public :
-            RootCoordinator(const common::context::Context<Time>& context,
-                    const std::string& root_name,
-                    const typename Coordinator::parameters_type& parameters,
-                    const typename Coordinator::graph_parameters_type& graph_parameters)
-                    :
-                    _root(root_name, parameters, graph_parameters), _observer(&_root),
-                    _t_max(context.end()), _tn(context.begin()) { }
-
-            RootCoordinator(const common::context::Context<Time>& context,
-                    const std::string& root_name,
-                    const typename Coordinator::parameters_type& parameters)
-                    :
-                    _root(root_name, parameters, NoParameters()), _observer(&_root),
-                    _t_max(context.end()), _tn(context.begin()) { }
-
-            RootCoordinator(const common::context::Context<Time>& context,
-                    const std::string& root_name)
-                    :
-                    _root(root_name, NoParameters(), NoParameters()), _observer(&_root),
-                    _t_max(context.end()), _tn(context.begin()) { }
-
-            virtual ~RootCoordinator() { }
-
-            void attachView(const std::string& name, observer::View<Time>* view)
-            {
-                _observer.attachView(name, view);
-            }
-
-            const observer::Observer<Time>& observer() const { return _observer; }
-
-            void run(const common::context::Context<Time>& context)
-            {
+namespace common {
+
+template<class Time, class Coordinator>
+class RootCoordinator {
+public :
+  RootCoordinator(const common::context::Context<Time> &context,
+                  const std::string &root_name,
+                  const typename Coordinator::parameters_type &parameters,
+                  const typename Coordinator::graph_parameters_type &graph_parameters)
+      :
+      _root(root_name, parameters, graph_parameters), _observer(&_root),
+      _t_max(context.end()), _tn(context.begin()) {}
+
+  RootCoordinator(const common::context::Context<Time> &context,
+                  const std::string &root_name,
+                  const typename Coordinator::parameters_type &parameters)
+      :
+      _root(root_name, parameters, NoParameters()), _observer(&_root),
+      _t_max(context.end()), _tn(context.begin()) {}
+
+  RootCoordinator(const common::context::Context<Time> &context,
+                  const std::string &root_name)
+      :
+      _root(root_name, NoParameters(), NoParameters()), _observer(&_root),
+      _t_max(context.end()), _tn(context.begin()) {}
+
+  virtual ~RootCoordinator() {}
+
+  void attachView(const std::string &name, observer::View<Time> *view) {
+    _observer.attachView(name, view);
+  }
+
+  const observer::Observer<Time> &observer() const { return _observer; }
+
+  void run(const common::context::Context<Time> &context) {
 //             DSDE synchroniser
 //               When receive (START,t)
 //                  send (START,0) to child
@@ -84,47 +82,45 @@ namespace artis {
 //                  endWhile
 //               end
 
-                _observer.init();
-                if (context.valid()) {
-                    _root.restore(context.state());
-                    _tn = _root.get_tn();
-                } else {
-                    _tn = _root.start(_tn);
-                }
-                while (_tn <= _t_max) {
-                    typename Time::type next_tn;
-
-                    _root.output(_tn);
-                    next_tn = _root.transition(_tn);
-                    _observer.observe(_tn, _t_max < next_tn ? _t_max : next_tn);
-                    _tn = next_tn;
-                }
-            }
-
-            void save(common::context::Context<Time>& context) const
-            {
-                _root.save(context.state());
-                context.saved();
-            }
-
-            void switch_to_timed_observer(double step) { _observer.switch_to_timed_observer(step); }
-
-            std::string to_string() const
-            {
-                std::ostringstream ss;
-
-                ss << _root.to_string(0);
-                return ss.str();
-            }
-
-        private :
-            Coordinator _root;
-            observer::Observer<Time> _observer;
-            typename Time::type _t_max;
-            typename Time::type _tn;
-        };
+    _observer.init();
+    if (context.valid()) {
+      _root.restore(context.state());
+      _tn = _root.get_tn();
+    } else {
+      _tn = _root.start(_tn);
+    }
+    while (_tn <= _t_max) {
+      typename Time::type next_tn;
 
+      _root.output(_tn);
+      next_tn = _root.transition(_tn);
+      _observer.observe(_tn, _t_max < next_tn ? _t_max : next_tn);
+      _tn = next_tn;
     }
+  }
+
+  void save(common::context::Context<Time> &context) const {
+    _root.save(context.state());
+    context.saved();
+  }
+
+  void switch_to_timed_observer(double step) { _observer.switch_to_timed_observer(step); }
+
+  std::string to_string() const {
+    std::ostringstream ss;
+
+    ss << _root.to_string(0);
+    return ss.str();
+  }
+
+private :
+  Coordinator _root;
+  observer::Observer<Time> _observer;
+  typename Time::type _t_max;
+  typename Time::type _tn;
+};
+
+}
 } // namespace artis common
 
 #endif

+ 15 - 15
src/artis-star/common/Scheduler.hpp

@@ -1,5 +1,5 @@
 /**
- * @file Scheduler.hpp
+ * @file common/Scheduler.hpp
  * @author The ARTIS Development Team
  * See the AUTHORS or Authors.txt file
  */
@@ -25,33 +25,33 @@
  */
 
 #ifndef COMMON_SCHEDULER
-#define COMMON_SCHEDULER 1
+#define COMMON_SCHEDULER
 
 #include <artis-star/common/scheduler/HeapScheduler.hpp>
 #include <artis-star/common/time/DoubleTime.hpp>
 
 namespace artis {
-    namespace common {
+namespace common {
 
-        struct SchedulerHandle;
+struct SchedulerHandle;
 
-        typedef typename artis::common::scheduler::HeapScheduler<
-                common::DoubleTime, SchedulerHandle>::type SchedulerType;
+typedef typename artis::common::scheduler::HeapScheduler<
+    common::DoubleTime, SchedulerHandle>::type SchedulerType;
 
-        struct SchedulerHandle {
-            SchedulerHandle() { }
+struct SchedulerHandle {
+  SchedulerHandle() {}
 
-            SchedulerHandle(const SchedulerType::handle_type& handle)
-                    :_handle(handle) { }
+  SchedulerHandle(const SchedulerType::handle_type &handle)
+      : _handle(handle) {}
 
-            const SchedulerHandle& handle() const { return *this; }
+  const SchedulerHandle &handle() const { return *this; }
 
-            void handle(const SchedulerHandle& handle) { _handle = handle._handle; }
+  void handle(const SchedulerHandle &handle) { _handle = handle._handle; }
 
-            SchedulerType::handle_type _handle;
-        };
+  SchedulerType::handle_type _handle;
+};
 
-    }
+}
 } // namespace artis common
 
 #endif

+ 24 - 25
src/artis-star/common/Simulator.hpp

@@ -1,5 +1,5 @@
 /**
- * @file Simulator.hpp
+ * @file common/Simulator.hpp
  * @author The ARTIS Development Team
  * See the AUTHORS or Authors.txt file
  */
@@ -32,43 +32,42 @@
 #include <sstream>
 
 namespace artis {
-    namespace common {
+namespace common {
 
-        template<class Time>
-        class Simulator : public virtual Model<Time> {
-        public :
-            Simulator(const std::string& name)
-                    :Model<Time>(name) { }
+template<class Time>
+class Simulator : public virtual Model<Time> {
+public :
+  Simulator(const std::string &name)
+      : Model<Time>(name) {}
 
-            virtual ~Simulator() { }
+  virtual ~Simulator() {}
 
-            virtual bool is_atomic() const { return true; }
+  virtual bool is_atomic() const { return true; }
 
-            virtual std::string to_string(int /* level */) const
-            {
-                std::ostringstream ss;
+  virtual std::string to_string(int /* level */) const {
+    std::ostringstream ss;
 
-                ss << "Simulator " << Simulator<Time>::get_name();
-                return ss.str();
-            }
+    ss << "Simulator " << Simulator<Time>::get_name();
+    return ss.str();
+  }
 
 // DEVS methods
-            virtual void finish(const typename Time::type& t) = 0;
+  virtual void finish(const typename Time::type &t) = 0;
 
-            virtual common::Value observe(const typename Time::type& t,
-                    unsigned int index) const = 0;
+  virtual common::Value observe(const typename Time::type &t,
+                                unsigned int index) const = 0;
 
-            virtual void output(const typename Time::type& t) = 0;
+  virtual void output(const typename Time::type &t) = 0;
 
-            virtual void post_event(const typename Time::type& t,
-                    const common::ExternalEvent<Time>& event) = 0;
+  virtual void post_event(const typename Time::type &t,
+                          const common::ExternalEvent<Time> &event) = 0;
 
-            virtual typename Time::type start(const typename Time::type& t) = 0;
+  virtual typename Time::type start(const typename Time::type &t) = 0;
 
-            virtual typename Time::type transition(const typename Time::type& t) = 0;
-        };
+  virtual typename Time::type transition(const typename Time::type &t) = 0;
+};
 
-    }
+}
 } // namespace artis common
 
 #endif

+ 78 - 82
src/artis-star/common/States.hpp

@@ -1,5 +1,5 @@
 /**
- * @file States.hpp
+ * @file common/States.hpp
  * @author The ARTIS Development Team
  * See the AUTHORS or Authors.txt file
  */
@@ -34,89 +34,85 @@
 #include <vector>
 
 namespace artis {
-    namespace common {
-
-        template<typename Time, typename Dyn>
-        class States {
-        public:
-            template<class W>
-            struct element {
-                unsigned int index;
-                const std::string name;
-                W Dyn::* var;
-
-                element(unsigned int index, const std::string& name, W Dyn::* var)
-                        :
-                        index(index), name(name), var(var) { }
-            };
-
-            States() { }
-
-            virtual ~States() { }
-
-            common::Any& get(unsigned int index) { return states.at(index); }
-
-            const common::Any& get(unsigned int index) const { return states.at(index); }
-
-            unsigned int state_number() const { return states.size(); }
-
-            template<class W>
-            void S_(std::initializer_list<element<W> > list)
-            {
-                for (typename std::initializer_list<element<W> >::iterator it =
-                        list.begin(); it != list.end(); ++it) {
-                    if (states.size() <= it->index) {
-                        states.resize(it->index + 1, common::Any());
-                        state_names.resize(it->index + 1, std::string());
-                    }
-                    states[it->index] = it->var;
-                    state_names[it->index] = it->name;
-                }
-            }
-
-            virtual void restore(Dyn* model, const common::context::State<Time>& state)
-            {
-                unsigned int index = 0;
-
-                for (typename std::vector<common::Any>::iterator it = states.begin();
-                     it != states.end(); ++it) {
-                    if (not it->is_null()) {
-                        it->restore<Dyn>(model, state.get_state(index));
-                    }
-                    ++index;
-                }
-            }
-
-            virtual void save(const Dyn* model, common::context::State<Time>& state) const
-            {
-                unsigned int index = 0;
-
-                for (typename std::vector<common::Any>::const_iterator it =
-                        states.begin(); it != states.end(); ++it) {
-                    if (not it->is_null()) {
-                        state.add_state(index, it->save<Dyn>(model));
-                    }
-                    ++index;
-                }
-            }
-
-            template<class W>
-            void state_(unsigned int index, const std::string& name, W Dyn::* var)
-            {
-                if (states.size() <= index) {
-                    states.resize(index + 1, common::Any());
-                    state_names.resize(index + 1, std::string());
-                }
-                states[index] = common::Any(var);
-                state_names[index] = name;
-            }
-
-        private:
-            std::vector<common::Any> states;
-            std::vector<std::string> state_names;
-        };
+namespace common {
+
+template<typename Time, typename Dyn>
+class States {
+public:
+  template<class W>
+  struct element {
+    unsigned int index;
+    const std::string name;
+    W Dyn::* var;
+
+    element(unsigned int index, const std::string &name, W Dyn::* var)
+        :
+        index(index), name(name), var(var) {}
+  };
+
+  States() {}
+
+  virtual ~States() {}
+
+  common::Any &get(unsigned int index) { return states.at(index); }
+
+  const common::Any &get(unsigned int index) const { return states.at(index); }
+
+  unsigned int state_number() const { return states.size(); }
+
+  template<class W>
+  void S_(std::initializer_list<element<W> > list) {
+    for (typename std::initializer_list<element<W> >::iterator it =
+        list.begin(); it != list.end(); ++it) {
+      if (states.size() <= it->index) {
+        states.resize(it->index + 1, common::Any());
+        state_names.resize(it->index + 1, std::string());
+      }
+      states[it->index] = it->var;
+      state_names[it->index] = it->name;
+    }
+  }
+
+  virtual void restore(Dyn *model, const common::context::State<Time> &state) {
+    unsigned int index = 0;
+
+    for (typename std::vector<common::Any>::iterator it = states.begin();
+         it != states.end(); ++it) {
+      if (not it->is_null()) {
+        it->restore<Dyn>(model, state.get_state(index));
+      }
+      ++index;
+    }
+  }
+
+  virtual void save(const Dyn *model, common::context::State<Time> &state) const {
+    unsigned int index = 0;
 
+    for (typename std::vector<common::Any>::const_iterator it =
+        states.begin(); it != states.end(); ++it) {
+      if (not it->is_null()) {
+        state.add_state(index, it->save<Dyn>(model));
+      }
+      ++index;
     }
+  }
+
+  template<class W>
+  void state_(unsigned int index, const std::string &name, W Dyn::* var) {
+    if (states.size() <= index) {
+      states.resize(index + 1, common::Any());
+      state_names.resize(index + 1, std::string());
+    }
+    states[index] = common::Any(var);
+    state_names[index] = name;
+  }
+
+private:
+  std::vector<common::Any> states;
+  std::vector<std::string> state_names;
+};
+
+}
 }
 
 #define DECLARE_STATE(W, index, var)                                    \

+ 166 - 172
src/artis-star/common/Value.hpp

@@ -1,5 +1,5 @@
 /**
- * @file Value.hpp
+ * @file common/Value.hpp
  * @author The ARTIS Development Team
  * See the AUTHORS or Authors.txt file
  */
@@ -25,7 +25,7 @@
  */
 
 #ifndef COMMON_VALUE
-#define COMMON_VALUE 1
+#define COMMON_VALUE
 
 #include <boost/serialization/serialization.hpp>
 #include <boost/serialization/array.hpp>
@@ -37,178 +37,172 @@
 #include <vector>
 
 namespace artis {
-    namespace common {
-
-        class Value {
-        public:
-            Value()
-                    :_content(nullptr), _size(0) { }
-
-            template<typename T>
-            Value(T value) { assign(&value, sizeof(T), typeid(T).hash_code()); }
-
-            template<typename T>
-            Value(T* value, size_t size)
-            {
-                assign(value, sizeof(T) * size, typeid(T*).hash_code());
-            }
-
-            Value(void* content, size_t size) { assign(content, size, typeid(void*).hash_code()); }
-
-            Value(const char* value, unsigned int size)
-            {
-                assign(value, size * sizeof(char), typeid(char*).hash_code());
-            }
-
-            Value(const Value& value)
-            {
-                if (value._content) {
-                    assign(value._content, value._size, value._type_id);
-                } else {
-                    _content = nullptr;
-                    _size = 0;
-                    _type_id = 0;
-                }
-            }
-
-            virtual ~Value() { if (_content != nullptr) delete[] _content; }
-
-            bool empty() const { return _content == nullptr; }
-
-            template<typename T>
-            void operator()(T& value) const
-            {
-                assert(_type_id == typeid(T).hash_code());
-
-                value = *(T*) (_content);
-            }
-
-            template<typename T>
-            void operator()(T*& value) const
-            {
-                assert(_type_id == typeid(T*).hash_code());
-
-                value = (T*) (_content);
-            }
-
-            template<typename Z>
-            bool is_type() const { return _type_id == typeid(Z).hash_code(); }
-
-            Value& operator=(const Value& value)
-            {
-                if (_content != nullptr) {
-                    delete _content;