Parcourir la source

Add a template for Time

Eric Ramat il y a 11 ans
Parent
commit
04c768fb93

+ 0 - 14
src/common/Bag.cpp

@@ -26,20 +26,6 @@
 
 
 #include <common/Bag.hpp>
 #include <common/Bag.hpp>
 
 
-#include <sstream>
-
 namespace paradevs { namespace common {
 namespace paradevs { namespace common {
 
 
-std::string Bag::to_string() const
-{
-    std::ostringstream ss;
-
-    ss << "{ ";
-    for (const_iterator it = begin(); it != end(); ++it) {
-        ss << it->to_string() << " ";
-    }
-    ss << "}";
-    return ss.str();
-}
-
 } } // namespace paradevs common
 } } // namespace paradevs common

+ 16 - 2
src/common/Bag.hpp

@@ -29,14 +29,17 @@
 
 
 #include <common/ExternalEvent.hpp>
 #include <common/ExternalEvent.hpp>
 
 
+#include <sstream>
 #include <string>
 #include <string>
 #include <vector>
 #include <vector>
 
 
 namespace paradevs { namespace common {
 namespace paradevs { namespace common {
 
 
+template < class Time >
 class ExternalEvent;
 class ExternalEvent;
 
 
-class Bag : public std::vector < ExternalEvent >
+template < class Time >
+class Bag : public std::vector < ExternalEvent < Time > >
 {
 {
 public:
 public:
     Bag()
     Bag()
@@ -44,7 +47,18 @@ public:
     virtual ~Bag()
     virtual ~Bag()
     { }
     { }
 
 
-    std::string to_string() const;
+    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();
+    }
 };
 };
 
 
 } } // namespace paradevs common
 } } // namespace paradevs common

+ 13 - 9
src/common/Coordinator.hpp

@@ -37,10 +37,14 @@
 
 
 namespace paradevs { namespace common {
 namespace paradevs { namespace common {
 
 
-class Coordinator : public Model
+template < class Time >
+class Model;
+
+template < class Time >
+class Coordinator : public Model < Time >
 {
 {
 public :
 public :
-    Coordinator(const std::string& name) : Model(name)
+    Coordinator(const std::string& name) : Model < Time >(name)
     { }
     { }
 
 
     virtual ~Coordinator()
     virtual ~Coordinator()
@@ -48,13 +52,13 @@ public :
 
 
 // DEVS methods
 // DEVS methods
     virtual void observation(std::ostream& file) const =0;
     virtual void observation(std::ostream& file) const =0;
-    virtual void output(common::Time t) =0;
-    virtual void post_event(common::Time t,
-                            const common::ExternalEvent& event) =0;
-    virtual common::Time dispatch_events(common::Bag bag,
-                                         common::Time t) =0;
-    virtual common::Time start(common::Time t) =0;
-    virtual common::Time transition(common::Time t) =0;
+    virtual void output(typename Time::type t) =0;
+    virtual void post_event(typename Time::type t,
+                            const common::ExternalEvent < Time >& event) =0;
+    virtual typename Time::type dispatch_events(common::Bag < Time > bag,
+                                                typename Time::type t) =0;
+    virtual typename Time::type start(typename Time::type t) =0;
+    virtual typename Time::type transition(typename Time::type t) =0;
 };
 };
 
 
 } } // namespace paradevs common
 } } // namespace paradevs common

+ 0 - 62
src/common/EventTable.cpp

@@ -26,68 +26,6 @@
 
 
 #include <common/EventTable.hpp>
 #include <common/EventTable.hpp>
 
 
-#include <algorithm>
-#include <sstream>
-
 namespace paradevs { namespace common {
 namespace paradevs { namespace common {
 
 
-Model* EventTable::get_current_model()
-{
-    return back().get_model();
-}
-
-Models EventTable::get_current_models(Time time) const
-{
-    common::Models models;
-    bool found = true;
-
-    for (const_reverse_iterator it = rbegin(); found and it != rend(); ++it) {
-        if (it->get_time() == time) {
-            models.push_back(it->get_model());
-        } else {
-            found = false;
-        }
-    }
-    return models;
-}
-
-void EventTable::init(common::Time time, Model* model)
-{
-    push_back(InternalEvent(time, model));
-    std::sort(begin(), end());
-}
-
-void EventTable::put(common::Time time, Model* model)
-{
-    remove(model);
-    push_back(InternalEvent(time, model));
-    std::sort(begin(), end());
-}
-
-void EventTable::remove(Model* model)
-{
-    iterator jt = begin();
-
-    while (jt != end()) {
-        if (jt->get_model() == model) {
-            jt = erase(jt);
-        } else {
-            ++jt;
-        }
-    }
-}
-
-std::string EventTable::to_string() const
-{
-    std::stringstream ss;
-
-    ss << "EventTable = { ";
-    for (const_iterator it = begin(); it != end(); ++it) {
-        ss << "(" << it->get_time() << " -> " << it->get_model()->get_name()
-           << ") ";
-    }
-    ss << "}";
-    return ss.str();
-}
-
 } } // namespace paradevs common
 } } // namespace paradevs common

+ 65 - 9
src/common/EventTable.hpp

@@ -29,9 +29,13 @@
 
 
 #include <common/InternalEvent.hpp>
 #include <common/InternalEvent.hpp>
 
 
+#include <algorithm>
+#include <sstream>
+
 namespace paradevs { namespace common {
 namespace paradevs { namespace common {
 
 
-class EventTable : protected std::vector < InternalEvent >
+template < class Time >
+class EventTable : protected std::vector < InternalEvent < Time > >
 {
 {
 public:
 public:
     EventTable()
     EventTable()
@@ -39,21 +43,73 @@ public:
     virtual ~EventTable()
     virtual ~EventTable()
     { }
     { }
 
 
-    Model* get_current_model();
+    Model < Time >* get_current_model()
+    {
+        return EventTable < Time >::back().get_model();
+    }
+
+    Models < Time > get_current_models(typename Time::type time) const
+    {
+        Models < Time > models;
+        bool found = true;
+
+        for (typename EventTable < Time >::const_reverse_iterator it =
+                 EventTable < Time >::rbegin();
+             found and it != EventTable < Time >::rend(); ++it) {
+            if (it->get_time() == time) {
+                models.push_back(it->get_model());
+            } else {
+                found = false;
+            }
+        }
+        return models;
+    }
+
+    typename Time::type get_current_time() const
+    { return EventTable < Time >::back().get_time(); }
 
 
-    Models get_current_models(Time time) const;
+    void init(typename Time::type time, Model < Time >* model)
+    {
+        EventTable < Time >::push_back(InternalEvent < Time >(time, model));
+        std::sort(EventTable < Time >::begin(), EventTable < Time >::end());
+    }
 
 
-    Time get_current_time() const
-    { return back().get_time(); }
+    void put(typename Time::type time, Model < Time >* model)
+    {
+        remove(model);
+        EventTable < Time >::push_back(InternalEvent < Time >(time, model));
+        std::sort(EventTable < Time >::begin(), EventTable < Time >::end());
+    }
 
 
-    void init(Time time, Model* model);
-    void put(Time time, Model* model);
+    std::string to_string() const
+    {
+        std::stringstream ss;
 
 
-    std::string to_string() const;
+        ss << "EventTable = { ";
+        for (typename EventTable < Time >::const_iterator it =
+                 EventTable < Time >::begin();
+             it != EventTable < Time >::end(); ++it) {
+            ss << "(" << it->get_time() << " -> " << it->get_model()->get_name()
+               << ") ";
+        }
+        ss << "}";
+        return ss.str();
+    }
 
 
 private:
 private:
-    void remove(Model* model);
+    void remove(Model < Time >* model)
+    {
+        typename EventTable < Time >::iterator jt =
+            EventTable < Time >::begin();
 
 
+        while (jt != EventTable < Time >::end()) {
+            if (jt->get_model() == model) {
+                jt = EventTable < Time >::erase(jt);
+            } else {
+                ++jt;
+            }
+        }
+    }
 };
 };
 
 
 } } // namespace paradevs common
 } } // namespace paradevs common

+ 0 - 41
src/common/ExternalEvent.cpp

@@ -26,47 +26,6 @@
 
 
 #include <common/ExternalEvent.hpp>
 #include <common/ExternalEvent.hpp>
 
 
-#include <sstream>
-
 namespace paradevs { namespace common {
 namespace paradevs { namespace common {
 
 
-ExternalEvent::ExternalEvent(const std::string& port_name, double content) :
-    _port_name(port_name), _model(0), _content(content)
-{ }
-
-ExternalEvent::ExternalEvent(const Node& node, double content) :
-    _port_name(node.get_port_name()), _model(node.get_model()),
-    _content(content)
-{ }
-
-ExternalEvent::ExternalEvent()
-{ }
-
-ExternalEvent::~ExternalEvent()
-{ }
-
-const std::string& ExternalEvent::get_port_name() const
-{ return _port_name; }
-
-double ExternalEvent::get_content() const
-{ return _content; }
-
-void ExternalEvent::set_content(double content)
-{ _content = content; }
-
-Model* ExternalEvent::get_model() const
-{ return _model; }
-
-void ExternalEvent::set_model(Model* model)
-{ _model = model; }
-
-std::string ExternalEvent::to_string() const
-{
-    std::ostringstream ss;
-
-    ss << "( " << _port_name << " , " << (_model?_model->get_name():"<>")
-       << " , " << _content << ")";
-    return ss.str();
-}
-
 } } // namespace paradevs common
 } } // namespace paradevs common

+ 43 - 14
src/common/ExternalEvent.hpp

@@ -30,35 +30,64 @@
 #include <common/Model.hpp>
 #include <common/Model.hpp>
 #include <common/Node.hpp>
 #include <common/Node.hpp>
 
 
+#include <sstream>
 #include <string>
 #include <string>
 #include <vector>
 #include <vector>
 
 
 namespace paradevs { namespace common {
 namespace paradevs { namespace common {
 
 
-class Model;
+template < class Time >
 class Node;
 class Node;
+template < class Time >
+class Model;
 
 
+template < class Time >
 class ExternalEvent
 class ExternalEvent
 {
 {
 public:
 public:
-    ExternalEvent(const std::string& port_name, double content);
-    ExternalEvent(const Node& node, double content);
-    ExternalEvent();
-    virtual ~ExternalEvent();
+    ExternalEvent(const std::string& port_name, double content) :
+        _port_name(port_name), _model(0), _content(content)
+    { }
+
+    ExternalEvent(const Node < Time >& node, double content) :
+        _port_name(node.get_port_name()), _model(node.get_model()),
+        _content(content)
+    { }
+
+    ExternalEvent()
+    { }
+
+    virtual ~ExternalEvent()
+    { }
+
+    double get_content() const
+    { return _content; }
+
+    const std::string& get_port_name() const
+    { return _port_name; }
+
+    void set_content(double content)
+    { _content = content; }
+
+    Model < Time >* get_model() const
+    { return _model; }
 
 
-    double get_content() const;
-    Model* get_model() const;
-    const std::string& get_port_name() const;
+    void set_model(Model < Time >* model)
+    { _model = model; }
 
 
-    void set_content(double content);
-    void set_model(Model* model);
+    std::string to_string() const
+    {
+        std::ostringstream ss;
 
 
-    std::string to_string() const;
+        ss << "( " << _port_name << " , " << (_model?_model->get_name():"<>")
+           << " , " << _content << ")";
+        return ss.str();
+    }
 
 
 private :
 private :
-    std::string _port_name;
-    Model*      _model;
-    double      _content;
+    std::string     _port_name;
+    Model < Time >* _model;
+    double          _content;
 };
 };
 
 
 } } // namespace paradevs common
 } } // namespace paradevs common

+ 0 - 12
src/common/InternalEvent.cpp

@@ -28,16 +28,4 @@
 
 
 namespace paradevs { namespace common {
 namespace paradevs { namespace common {
 
 
-InternalEvent::InternalEvent(const common::Time& time, common::Model* model)
- : _time(time), _model(model)
-{ }
-
-InternalEvent::~InternalEvent()
-{ }
-
-bool InternalEvent::operator<(InternalEvent const &e) const
-{
-    return e._time < _time;
-}
-
 } } // namespace paradevs common
 } } // namespace paradevs common

+ 15 - 8
src/common/InternalEvent.hpp

@@ -28,27 +28,34 @@
 #define COMMON_INTERNAL_EVENT 1
 #define COMMON_INTERNAL_EVENT 1
 
 
 #include <common/Model.hpp>
 #include <common/Model.hpp>
-#include <common/Time.hpp>
 
 
 namespace paradevs { namespace common {
 namespace paradevs { namespace common {
 
 
+template < class Time >
 class InternalEvent
 class InternalEvent
 {
 {
 public:
 public:
-    InternalEvent(const common::Time& time, common::Model* model);
-    virtual ~InternalEvent();
+    InternalEvent(const typename Time::type& time, Model < Time >* model)
+        : _time(time), _model(model)
+    { }
 
 
-    common::Model* get_model() const
+    virtual ~InternalEvent()
+    { }
+
+    Model < Time >* get_model() const
     { return _model; }
     { return _model; }
 
 
-    common::Time get_time() const
+    typename Time::type get_time() const
     { return _time; }
     { return _time; }
 
 
-    bool operator<(InternalEvent const& e) const;
+    bool operator<(InternalEvent const &e) const
+    {
+        return e._time < _time;
+    }
 
 
 private:
 private:
-    common::Time   _time;
-    common::Model* _model;
+    typename Time::type _time;
+    Model < Time >*     _model;
 };
 };
 
 
 } } // namespace paradevs common
 } } // namespace paradevs common

+ 0 - 31
src/common/Links.cpp

@@ -26,37 +26,6 @@
 
 
 #include <common/Links.hpp>
 #include <common/Links.hpp>
 
 
-#include <sstream>
-
 namespace paradevs { namespace common {
 namespace paradevs { namespace common {
 
 
-void Links::add(Model* out_model, const std::string& out_port_name,
-                Model* in_model, const std::string& in_port_name)
-{
-    insert(std::pair < Node, Node >(Node(out_model, out_port_name),
-                                    Node(in_model, in_port_name)));
-}
-
-Links::Result Links::find(Model* out_model, const std::string& out_port_name) const
-{
-    return equal_range(common::Node(out_model, out_port_name));
-}
-
-std::string Links::to_string() const
-{
-    std::stringstream ss;
-
-    ss << "Graph = { ";
-    for (const_iterator it = begin(); it != end(); ++it) {
-        ss << "(" << it->first.get_model()->get_name() << ":"
-           << it->first.get_port_name()
-           << " -> "
-           << it->second.get_model()->get_name() << ":"
-           << it->second.get_port_name()
-           << ") ";
-    }
-    ss << "}";
-    return ss.str();
-}
-
 } } // namespace paradevs common
 } } // namespace paradevs common

+ 37 - 7
src/common/Links.hpp

@@ -30,29 +30,59 @@
 #include <common/Node.hpp>
 #include <common/Node.hpp>
 
 
 #include <map>
 #include <map>
+#include <sstream>
 
 
 namespace paradevs { namespace common {
 namespace paradevs { namespace common {
 
 
+template < class Time >
 class Node;
 class Node;
 
 
-class Links : public std::multimap < Node, Node >
+template < class Time >
+class Links : public std::multimap < Node < Time >, Node < Time > >
 {
 {
 public:
 public:
 
 
-    typedef std::pair < common::Links::const_iterator,
-                        common::Links::const_iterator > Result;
+    typedef std::pair < typename Links < Time >::const_iterator,
+                        typename Links < Time >::const_iterator > Result;
 
 
     Links()
     Links()
     { }
     { }
     virtual ~Links()
     virtual ~Links()
     { }
     { }
 
 
-    void add(Model* out_model, const std::string& out_port_name,
-             Model* in_model, const std::string& in_port_name);
+    void add(Model < Time >* out_model, const std::string& out_port_name,
+             Model < Time >* in_model, const std::string& in_port_name)
+    {
+        std::multimap < Node < Time >, Node < Time > >::insert(
+            std::pair < Node < Time >, Node <Time > >(
+                Node < Time >(out_model, out_port_name),
+                Node < Time >(in_model, in_port_name)));
+    }
 
 
-    Result find(Model* out_model, const std::string& out_port_name) const;
+    Links::Result find(Model < Time >* out_model,
+                       const std::string& out_port_name) const
+    {
+        return std::multimap < Node < Time >, Node < Time > >::equal_range(
+            common::Node < Time >(out_model, out_port_name));
+    }
 
 
-    std::string to_string() const;
+    std::string to_string() const
+    {
+        std::stringstream ss;
+
+        ss << "Graph = { ";
+        for (typename Node < Time >::const_iterator it = Node < Time >::begin();
+             it != Node < Time >::end(); ++it) {
+            ss << "(" << it->first.get_model()->get_name() << ":"
+               << it->first.get_port_name()
+               << " -> "
+               << it->second.get_model()->get_name() << ":"
+               << it->second.get_port_name()
+               << ") ";
+        }
+        ss << "}";
+        return ss.str();
+    }
 };
 };
 
 
 } } // namespace paradevs common
 } } // namespace paradevs common

+ 0 - 58
src/common/Model.cpp

@@ -26,64 +26,6 @@
 
 
 #include <common/Model.hpp>
 #include <common/Model.hpp>
 
 
-#include <sstream>
-
 namespace paradevs { namespace common {
 namespace paradevs { namespace common {
 
 
-Model::Model(const std::string& name) :
-    _tl(0), _tn(0), _parent(0), _name(name), _inputs(0)
-{ }
-
-Model::~Model()
-{
-    if (_inputs) {
-        delete _inputs;
-    }
-}
-
-void Model::add_event(const common::ExternalEvent& message)
-{
-    if (_inputs == 0) {
-        _inputs = new Bag;
-    }
-    _inputs->push_back(message);
-}
-
-const common::Bag& Model::get_bag()
-{
-    if (_inputs == 0) {
-        _inputs = new Bag;
-    }
-    return *_inputs;
-}
-
-void Model::clear_bag()
-{
-    if (_inputs) {
-        delete _inputs;
-        _inputs = 0;
-    }
-}
-
-unsigned int Model::event_number() const
-{
-    if (_inputs) {
-        return _inputs->size();
-    } else {
-        return 0;
-    }
-}
-
-std::string Models::to_string() const
-{
-    std::ostringstream ss;
-
-    ss << "{ ";
-    for (const_iterator it = begin(); it != end(); ++it) {
-        ss << (*it)->get_name() << " ";
-    }
-    ss << "}";
-    return ss.str();
-}
-
 } } // namespace paradevs common
 } } // namespace paradevs common

+ 75 - 23
src/common/Model.hpp

@@ -29,54 +29,95 @@
 
 
 #include <common/Bag.hpp>
 #include <common/Bag.hpp>
 #include <common/ExternalEvent.hpp>
 #include <common/ExternalEvent.hpp>
-#include <common/Time.hpp>
 
 
 #include <iostream>
 #include <iostream>
+#include <sstream>
 #include <vector>
 #include <vector>
 
 
 namespace paradevs { namespace common {
 namespace paradevs { namespace common {
 
 
-class Bag;
+template < class Time >
 class ExternalEvent;
 class ExternalEvent;
 
 
+template < class Time >
+class Bag;
+
+template < class Time >
 class Model
 class Model
 {
 {
 public:
 public:
-    Model(const std::string& name);
-    virtual ~Model();
+    Model(const std::string& name) :
+        _tl(0), _tn(0), _parent(0), _name(name), _inputs(0)
+    { }
+
+    virtual ~Model()
+    {
+        if (_inputs) {
+            delete _inputs;
+        }
+    }
+
+    void add_event(const common::ExternalEvent < Time >& message)
+    {
+        if (_inputs == 0) {
+            _inputs = new Bag < Time >;
+        }
+        _inputs->push_back(message);
+    }
+
+    const common::Bag < Time >& get_bag()
+    {
+        if (_inputs == 0) {
+            _inputs = new Bag < Time>;
+        }
+        return *_inputs;
+    }
+
+    void clear_bag()
+    {
+        if (_inputs) {
+            delete _inputs;
+            _inputs = 0;
+        }
+    }
+
+    unsigned int event_number() const
+    {
+        if (_inputs) {
+            return _inputs->size();
+        } else {
+            return 0;
+        }
+    }
 
 
     virtual void observation(std::ostream& file) const =0;
     virtual void observation(std::ostream& file) const =0;
-    virtual void output(common::Time t) =0;
-    virtual void post_event(common::Time t,
-                            const common::ExternalEvent& event) = 0;
-    virtual common::Time start(common::Time t) =0;
-    virtual common::Time transition(common::Time t) =0;
+    virtual void output(typename Time::type t) =0;
+    virtual void post_event(typename Time::type t,
+                            const common::ExternalEvent < Time >& event) = 0;
+    virtual typename Time::type start(typename Time::type t) =0;
+    virtual typename Time::type transition(typename Time::type t) =0;
 
 
     virtual const std::string& get_name() const
     virtual const std::string& get_name() const
     { return _name; }
     { return _name; }
 
 
-    Model* get_parent() const
+    Model < Time >* get_parent() const
     { return _parent; }
     { return _parent; }
 
 
-    void set_parent(Model* parent)
+    void set_parent(Model < Time >* parent)
     { _parent = parent; }
     { _parent = parent; }
 
 
-    void add_event(const common::ExternalEvent& event);
-    void clear_bag();
-    const common::Bag& get_bag();
-    unsigned int event_number() const;
-
 protected:
 protected:
-    Time        _tl;
-    Time        _tn;
+    typename Time::type _tl;
+    typename Time::type _tn;
 
 
 private :
 private :
-    Model*      _parent;
-    std::string _name;
-    Bag*        _inputs;
+    Model < Time >*     _parent;
+    std::string         _name;
+    Bag < Time >*       _inputs;
 };
 };
 
 
-class Models : public std::vector < Model* >
+template < class Time >
+class Models : public std::vector < Model < Time >* >
 {
 {
 public:
 public:
     Models()
     Models()
@@ -84,7 +125,18 @@ public:
     virtual ~Models()
     virtual ~Models()
     { }
     { }
 
 
-    std::string to_string() const;
+    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();
+    }
 };
 };
 
 
 } } // namespace paradevs common
 } } // namespace paradevs common

+ 0 - 31
src/common/Node.cpp

@@ -28,35 +28,4 @@
 
 
 namespace paradevs { namespace common {
 namespace paradevs { namespace common {
 
 
-Node::Node(Model* model, const std::string& port_name)
-    : _model(model), _port_name(port_name)
-{ }
-
-Node::Node(const Node& other)
-    : _model(other._model), _port_name(other._port_name)
-{ }
-
-Node::~Node()
-{ }
-
-bool Node::operator<(const Node& o) const
-{
-    if (o._model == _model) {
-        return o._port_name < _port_name;
-    } else {
-        return o._model < _model;
-    }
-}
-
-bool Node::operator==(const Node& o) const
-{
-    return (o._port_name == _port_name and o._model == _model);
-}
-
-const std::string& Node::get_port_name() const
-{ return _port_name; }
-
-Model* Node::get_model() const
-{ return _model; }
-
 } } // namespace paradevs common
 } } // namespace paradevs common

+ 32 - 9
src/common/Node.hpp

@@ -33,24 +33,47 @@
 
 
 namespace paradevs { namespace common {
 namespace paradevs { namespace common {
 
 
+template < class Time >
 class Model;
 class Model;
 
 
+template < class Time >
 class Node
 class Node
 {
 {
 public :
 public :
-    Node(Model* model, const std::string& port_name);
-    Node(const Node& other);
-    virtual ~Node();
+    Node(Model < Time >* model, const std::string& port_name)
+        : _model(model), _port_name(port_name)
+    { }
 
 
-    Model* get_model() const;
-    const std::string& get_port_name() const;
+    Node(const Node < Time >& other)
+    : _model(other._model), _port_name(other._port_name)
+    { }
 
 
-    virtual bool operator<(const Node& e) const;
-    virtual bool operator==(const Node& other) const;
+    virtual ~Node()
+    { }
+
+    bool operator<(const Node < Time >& o) const
+    {
+        if (o._model == _model) {
+            return o._port_name < _port_name;
+        } else {
+            return o._model < _model;
+        }
+    }
+
+    bool operator==(const Node < Time >& o) const
+    {
+        return (o._port_name == _port_name and o._model == _model);
+    }
+
+    const std::string& get_port_name() const
+    { return _port_name; }
+
+    Model < Time >* get_model() const
+    { return _model; }
 
 
 private :
 private :
-    Model*      _model;
-    std::string _port_name;
+    Model < Time >* _model;
+    std::string     _port_name;
 };
 };
 
 
 } } // namespace paradevs common
 } } // namespace paradevs common

+ 6 - 7
src/common/RootCoordinator.hpp

@@ -27,17 +27,16 @@
 #ifndef COMMON_ROOT_COORDINATOR
 #ifndef COMMON_ROOT_COORDINATOR
 #define COMMON_ROOT_COORDINATOR 1
 #define COMMON_ROOT_COORDINATOR 1
 
 
-#include <common/Time.hpp>
-
 #include <string>
 #include <string>
 
 
 namespace paradevs { namespace common {
 namespace paradevs { namespace common {
 
 
-template < class Coordinator >
+template < class Time, class Coordinator >
 class RootCoordinator
 class RootCoordinator
 {
 {
 public :
 public :
-    RootCoordinator(const common::Time& t_start, const common::Time& t_max,
+    RootCoordinator(const typename Time::type& t_start,
+                    const typename Time::type& t_max,
                     const std::string& root_name,
                     const std::string& root_name,
                     const typename Coordinator::parameters_type& parameters) :
                     const typename Coordinator::parameters_type& parameters) :
         _root(root_name, parameters), _t_max(t_max), _tn(t_start)
         _root(root_name, parameters), _t_max(t_max), _tn(t_start)
@@ -56,10 +55,10 @@ public :
     }
     }
 
 
 private :
 private :
-    Coordinator  _root;
-    common::Time _t_max;
+    Coordinator         _root;
+    typename Time::type _t_max;
 
 
-    common::Time _tn;
+    typename Time::type _tn;
 };
 };
 
 
 } } // namespace paradevs common
 } } // namespace paradevs common

+ 9 - 9
src/common/Simulator.hpp

@@ -27,25 +27,25 @@
 #ifndef COMMON_SIMULATOR
 #ifndef COMMON_SIMULATOR
 #define COMMON_SIMULATOR 1
 #define COMMON_SIMULATOR 1
 
 
-#include <common/Links.hpp>
-#include <common/Node.hpp>
+#include <common/Model.hpp>
 
 
 namespace paradevs { namespace common {
 namespace paradevs { namespace common {
 
 
-class Simulator : public Model
+template < class Time >
+class Simulator : public Model < Time >
 {
 {
 public :
 public :
-    Simulator(const std::string& name) : Model(name)
+    Simulator(const std::string& name) : Model < Time >(name)
     { }
     { }
     virtual ~Simulator()
     virtual ~Simulator()
     { }
     { }
 
 
     virtual void observation(std::ostream& file) const =0;
     virtual void observation(std::ostream& file) const =0;
-    virtual void output(common::Time t) =0;
-    virtual void post_event(common::Time t,
-                            const common::ExternalEvent& event) = 0;
-    virtual common::Time start(common::Time t) =0;
-    virtual common::Time transition(common::Time t) =0;
+    virtual void output(typename Time::type t) =0;
+    virtual void post_event(typename Time::type t,
+                            const common::ExternalEvent < Time >& event) = 0;
+    virtual typename Time::type start(typename Time::type t) =0;
+    virtual typename Time::type transition(typename Time::type t) =0;
 };
 };
 
 
 } } // namespace paradevs common
 } } // namespace paradevs common

+ 8 - 1
src/common/Time.hpp

@@ -29,7 +29,14 @@
 
 
 namespace paradevs { namespace common {
 namespace paradevs { namespace common {
 
 
-typedef double Time;
+template < typename Type, typename Limits >
+struct Time
+{
+    static constexpr Type negative_infinity = Limits::negative_infinity;
+    static constexpr Type infinity = Limits::positive_infinity;
+    static constexpr Type null = Limits::null;
+    typedef Type type;
+};
 
 
 } } // namespace paradevs common
 } } // namespace paradevs common
 
 

+ 0 - 79
src/common/Trace.cpp

@@ -28,84 +28,5 @@
 
 
 namespace paradevs { namespace common {
 namespace paradevs { namespace common {
 
 
-Trace* Trace::_instance = 0;
-
-std::string TraceElements::to_string() const
-{
-    std::ostringstream ss;
-
-    for (const_iterator it = begin(); it != end(); ++it) {
-        ss << "TRACE: " << it->get_model_name() << " at "
-           << it->get_time() << " <";
-        switch (it->get_type())
-        {
-        case NONE: ss << "none"; break;
-        case I_MESSAGE: ss << "i_message"; break;
-        case POST_EVENT:  ss << "post_event"; break;
-        case S_MESSAGE: ss << "s_message"; break;
-        case Y_MESSAGE: ss << "y_message"; break;
-        case DELTA_INT: ss << "delta_int"; break;
-        case DELTA_EXT: ss << "delta_ext"; break;
-        case DELTA_CONF:  ss << "delta_conf"; break;
-        case TA: ss << "ta"; break;
-        case LAMBDA: ss << "lambda"; break;
-        case START: ss << "start"; break;
-        case OUTPUT: ss << "output"; break;
-        };
-        ss << ">";
-        if (not it->get_comment().empty()) {
-            ss << " => " << it->get_comment();
-        }
-        ss << std::endl;
-    }
-    return ss.str();
-}
-
-void Trace::flush()
-{
-    if (_sstream) {
-        _element.set_comment(_sstream->str());
-        delete _sstream;
-        _sstream = 0;
-    }
-    _trace.push_back(_element);
-}
-
-std::ostringstream& Trace::sstream()
-{
-    if (_sstream == 0) {
-        _sstream = new std::ostringstream();
-    }
-    return *_sstream;
-}
-
-Trace& Trace::trace()
-{
-    if (_instance == 0) {
-        _instance = new Trace();
-    }
-    return *_instance;
-}
-
 } } // namespace paradevs common
 } } // namespace paradevs common
 
 
-paradevs::common::Trace& operator<<(paradevs::common::Trace& trace,
-                                    const paradevs::common::TraceElement& e)
-{
-    trace.set_element(e);
-    return trace;
-}
-
-paradevs::common::Trace& operator<<(paradevs::common::Trace& trace,
-                                    const std::string& str)
-{
-    trace.sstream() << str;
-    return trace;
-}
-
-paradevs::common::Trace& operator<<(paradevs::common::Trace& trace,
-                                    paradevs::common::Time t)
-{
-    trace.sstream() << t;
-    return trace;
-}

+ 116 - 34
src/common/Trace.hpp

@@ -27,8 +27,6 @@
 #ifndef COMMON_TRACE
 #ifndef COMMON_TRACE
 #define COMMON_TRACE 1
 #define COMMON_TRACE 1
 
 
-#include <common/Time.hpp>
-
 #include <algorithm>
 #include <algorithm>
 #include <iterator>
 #include <iterator>
 #include <sstream>
 #include <sstream>
@@ -40,14 +38,18 @@ namespace paradevs { namespace common {
 enum TraceType { NONE = 0, I_MESSAGE, POST_EVENT, S_MESSAGE, Y_MESSAGE,
 enum TraceType { NONE = 0, I_MESSAGE, POST_EVENT, S_MESSAGE, Y_MESSAGE,
                  DELTA_INT, DELTA_EXT, DELTA_CONF, TA, LAMBDA, START, OUTPUT };
                  DELTA_INT, DELTA_EXT, DELTA_CONF, TA, LAMBDA, START, OUTPUT };
 
 
+template < class Time >
 class TraceElement
 class TraceElement
 {
 {
 public:
 public:
-    TraceElement() : _time(0), _type(NONE)
+    TraceElement() : _time(Time::null), _type(NONE)
     { }
     { }
-    TraceElement(const std::string& model_name, Time time, TraceType type) :
+
+    TraceElement(const std::string& model_name, typename Time::type time,
+                 TraceType type) :
         _model_name(model_name), _time(time), _type(type)
         _model_name(model_name), _time(time), _type(type)
     { }
     { }
+
     virtual ~TraceElement()
     virtual ~TraceElement()
     { }
     { }
 
 
@@ -57,7 +59,7 @@ public:
     const std::string& get_model_name() const
     const std::string& get_model_name() const
     { return _model_name; }
     { return _model_name; }
 
 
-    Time get_time() const
+    typename Time::type get_time() const
     { return _time; }
     { return _time; }
 
 
     TraceType get_type() const
     TraceType get_type() const
@@ -67,13 +69,14 @@ public:
     { _comment = comment; }
     { _comment = comment; }
 
 
 private:
 private:
-    std::string _model_name;
-    Time        _time;
-    TraceType   _type;
-    std::string _comment;
+    std::string         _model_name;
+    typename Time::type _time;
+    TraceType           _type;
+    std::string         _comment;
 };
 };
 
 
-class TraceElements : public std::vector < TraceElement >
+template < class Time >
+class TraceElements : public std::vector < TraceElement < Time > >
 {
 {
 public:
 public:
     TraceElements()
     TraceElements()
@@ -84,20 +87,22 @@ public:
     TraceElements filter_model_name(
     TraceElements filter_model_name(
         const std::string& model_name) const
         const std::string& model_name) const
     {
     {
-        TraceElements result;
+        TraceElements < Time > result;
 
 
-        std::copy_if(begin(), end(), std::back_inserter(result),
-                     [model_name](TraceElement const & x)
+        std::copy_if(TraceElements < Time >::begin(),
+                     TraceElements < Time >::end(), std::back_inserter(result),
+                     [model_name](TraceElement < Time > const & x)
                      { return x.get_model_name() == model_name; });
                      { return x.get_model_name() == model_name; });
         return result;
         return result;
     }
     }
 
 
-    TraceElements filter_time(Time time) const
+    TraceElements filter_time(typename Time::type time) const
     {
     {
         TraceElements result;
         TraceElements result;
 
 
-        std::copy_if(begin(), end(), std::back_inserter(result),
-                     [time](TraceElement const & x)
+        std::copy_if(TraceElements < Time >::begin(),
+                     TraceElements < Time >::end(), std::back_inserter(result),
+                     [time](TraceElement < Time > const & x)
                      { return x.get_time() == time; });
                      { return x.get_time() == time; });
         return result;
         return result;
     }
     }
@@ -106,32 +111,85 @@ public:
     {
     {
         TraceElements result;
         TraceElements result;
 
 
-        std::copy_if(begin(), end(), std::back_inserter(result),
-                     [type](TraceElement const & x)
+        std::copy_if(TraceElements < Time >::begin(),
+                     TraceElements < Time >::end(), std::back_inserter(result),
+                     [type](TraceElement < Time > const & x)
                      { return x.get_type() == type; });
                      { return x.get_type() == type; });
         return result;
         return result;
     }
     }
 
 
-    std::string to_string() const;
+    std::string to_string() const
+    {
+        std::ostringstream ss;
+
+        for (typename TraceElements < Time >::const_iterator it =
+                 TraceElements < Time >::begin();
+             it != TraceElements < Time >::end(); ++it) {
+            ss << "TRACE: " << it->get_model_name() << " at "
+               << it->get_time() << " <";
+            switch (it->get_type())
+            {
+            case NONE: ss << "none"; break;
+            case I_MESSAGE: ss << "i_message"; break;
+            case POST_EVENT:  ss << "post_event"; break;
+            case S_MESSAGE: ss << "s_message"; break;
+            case Y_MESSAGE: ss << "y_message"; break;
+            case DELTA_INT: ss << "delta_int"; break;
+            case DELTA_EXT: ss << "delta_ext"; break;
+            case DELTA_CONF:  ss << "delta_conf"; break;
+            case TA: ss << "ta"; break;
+            case LAMBDA: ss << "lambda"; break;
+            case START: ss << "start"; break;
+            case OUTPUT: ss << "output"; break;
+            };
+            ss << ">";
+            if (not it->get_comment().empty()) {
+                ss << " => " << it->get_comment();
+            }
+            ss << std::endl;
+        }
+        return ss.str();
+    }
 };
 };
 
 
+template < class Time >
 class Trace
 class Trace
 {
 {
 public:
 public:
-    static Trace& trace();
+    static Trace& trace()
+    {
+        if (_instance == 0) {
+            _instance = new Trace();
+        }
+        return *_instance;
+    }
 
 
     void clear()
     void clear()
     { _trace.clear(); }
     { _trace.clear(); }
 
 
-    const TraceElements& elements() const
+    const TraceElements < Time >& elements() const
     { return _trace; }
     { return _trace; }
 
 
-    void flush();
+    void flush()
+    {
+        if (_sstream) {
+            _element.set_comment(_sstream->str());
+            delete _sstream;
+            _sstream = 0;
+        }
+        _trace.push_back(_element);
+    }
 
 
-    void set_element(const TraceElement& element)
+    void set_element(const TraceElement < Time >& element)
     { _element = element; }
     { _element = element; }
 
 
-    std::ostringstream& sstream();
+    std::ostringstream& sstream()
+    {
+        if (_sstream == 0) {
+            _sstream = new std::ostringstream();
+        }
+        return *_sstream;
+    }
 
 
 private:
 private:
     Trace()
     Trace()
@@ -144,20 +202,44 @@ private:
         }
         }
     }
     }
 
 
-    static Trace* _instance;
+    static Trace < Time >* _instance;
 
 
-    TraceElements       _trace;
-    TraceElement        _element;
-    std::ostringstream* _sstream;
+    TraceElements < Time > _trace;
+    TraceElement < Time >  _element;
+    std::ostringstream*    _sstream;
 };
 };
 
 
 } } // namespace paradevs common
 } } // namespace paradevs common
 
 
-paradevs::common::Trace& operator<<(paradevs::common::Trace& trace,
-                                    const paradevs::common::TraceElement& e);
-paradevs::common::Trace& operator<<(paradevs::common::Trace& trace,
-                                    const std::string& str);
-paradevs::common::Trace& operator<<(paradevs::common::Trace& trace,
-                                    paradevs::common::Time t);
+template < class Time >
+paradevs::common::Trace < Time >& operator<<(
+    paradevs::common::Trace < Time >& trace,
+    const paradevs::common::TraceElement < Time >& e)
+{
+    trace.set_element(e);
+    return trace;
+}
+
+template < class Time >
+paradevs::common::Trace < Time >& operator<<(
+    paradevs::common::Trace < Time >& trace,
+    const std::string& str)
+{
+    trace.sstream() << str;
+    return trace;
+}
+
+template < class Time >
+paradevs::common::Trace < Time >& operator<<(
+    paradevs::common::Trace < Time >& trace,
+    typename Time::type t)
+{
+    trace.sstream() << t;
+    return trace;
+}
+
+template < class Time >
+paradevs::common::Trace < Time >*
+paradevs::common::Trace < Time >::_instance = 0;
 
 
 #endif
 #endif

+ 33 - 29
src/dtss/Coordinator.hpp

@@ -34,45 +34,48 @@
 
 
 namespace paradevs { namespace dtss {
 namespace paradevs { namespace dtss {
 
 
+template < class Time >
 class Parameters
 class Parameters
 {
 {
 public:
 public:
-    Parameters(paradevs::common::Time time_step) : _time_step(time_step)
+    Parameters(typename Time::type time_step) : _time_step(time_step)
     { }
     { }
 
 
-    paradevs::common::Time _time_step;
+    typename Time::type _time_step;
 };
 };
 
 
-template < class Policy, class GraphManager >
-class Coordinator : public common::Coordinator
+template < class Time, class Policy, class GraphManager >
+class Coordinator : public common::Coordinator < Time >
 {
 {
 public:
 public:
-    typedef Parameters parameters_type;
+    typedef Parameters < Time > parameters_type;
 
 
-    Coordinator(const std::string& name, const Parameters& parameters) :
-        common::Coordinator(name), _graph_manager(this),
+    Coordinator(const std::string& name,
+                const Parameters < Time >& parameters) :
+        common::Coordinator < Time >(name), _graph_manager(this),
         _time_step(parameters._time_step)
         _time_step(parameters._time_step)
     { }
     { }
 
 
     virtual ~Coordinator()
     virtual ~Coordinator()
     { }
     { }
 
 
-    common::Time start(common::Time t)
+    typename Time::type start(typename Time::type t)
     {
     {
         assert(_graph_manager.children().size() > 0);
         assert(_graph_manager.children().size() > 0);
 
 
         for (auto & child : _graph_manager.children()) {
         for (auto & child : _graph_manager.children()) {
-            child->start(_tn);
+            child->start(Coordinator < Time, Policy, GraphManager >::_tn);
         }
         }
-        _tl = t;
-        _tn = t;
-        return _tn;
+        Coordinator < Time, Policy, GraphManager >::_tl = t;
+        Coordinator < Time, Policy, GraphManager >::_tn = t;
+        return Coordinator < Time, Policy, GraphManager >::_tn;
     }
     }
 
 
-    common::Time dispatch_events(common::Bag bag, common::Time t)
+    typename Time::type dispatch_events(common::Bag < Time > bag,
+                                        typename Time::type t)
     {
     {
         _graph_manager.dispatch_events(bag, t);
         _graph_manager.dispatch_events(bag, t);
-        return _tn;
+        return Coordinator < Time, Policy, GraphManager >::_tn;
     }
     }
 
 
     void observation(std::ostream& file) const
     void observation(std::ostream& file) const
@@ -82,45 +85,46 @@ public:
         }
         }
     }
     }
 
 
-    void output(common::Time t)
+    void output(typename Time::type t)
     {
     {
-        if (t == _tn) {
+        if (t == Coordinator < Time, Policy, GraphManager >::_tn) {
             for (auto & model : _graph_manager.children()) {
             for (auto & model : _graph_manager.children()) {
                 model->output(t);
                 model->output(t);
             }
             }
         }
         }
     }
     }
 
 
-    void post_event(common::Time t,
-                    const common::ExternalEvent& event)
+    void post_event(typename Time::type t,
+                    const common::ExternalEvent < Time >& event)
     {
     {
-        if (t == _tn) {
+        if (t == Coordinator < Time, Policy, GraphManager >::_tn) {
             _graph_manager.post_event(t, event);
             _graph_manager.post_event(t, event);
         } else {
         } else {
-            _policy(t, event, _tl, _tn);
+            _policy(t, event, Coordinator < Time, Policy, GraphManager >::_tl,
+                    Coordinator < Time, Policy, GraphManager >::_tn);
         }
         }
     }
     }
 
 
-    common::Time transition(common::Time t)
+    typename Time::type transition(typename Time::type t)
     {
     {
-        if (t == _tn) {
+        if (t == Coordinator < Time, Policy, GraphManager >::_tn) {
             for (auto & event : _policy.bag()) {
             for (auto & event : _policy.bag()) {
                 post_event(t, event);
                 post_event(t, event);
             }
             }
             for (auto & model : _graph_manager.children()) {
             for (auto & model : _graph_manager.children()) {
                 model->transition(t);
                 model->transition(t);
             }
             }
-            _tl = t;
-            _tn = t + _time_step;
+            Coordinator < Time, Policy, GraphManager >::_tl = t;
+            Coordinator < Time, Policy, GraphManager >::_tn = t + _time_step;
         }
         }
-        clear_bag();
-        return _tn;
+        Coordinator < Time, Policy, GraphManager >::clear_bag();
+        return Coordinator < Time, Policy, GraphManager >::_tn;
     }
     }
 
 
 private:
 private:
-    GraphManager   _graph_manager;
-    common::Time   _time_step;
-    Policy         _policy;
+    GraphManager        _graph_manager;
+    typename Time::type _time_step;
+    Policy              _policy;
 };
 };
 
 
 } } // namespace paradevs dtss
 } } // namespace paradevs dtss

+ 0 - 9
src/dtss/Dynamics.cpp

@@ -28,13 +28,4 @@
 
 
 namespace paradevs { namespace dtss {
 namespace paradevs { namespace dtss {
 
 
-Dynamics::Dynamics(const std::string& name) : _name(name)
-{ }
-
-Dynamics::~Dynamics()
-{ }
-
-common::Bag Dynamics::lambda(common::Time /* time */) const
-{ return common::Bag(); }
-
 } } // namespace paradevs dtss
 } } // namespace paradevs dtss

+ 15 - 7
src/dtss/Dynamics.hpp

@@ -29,7 +29,6 @@
 
 
 #include <common/Bag.hpp>
 #include <common/Bag.hpp>
 #include <common/ExternalEvent.hpp>
 #include <common/ExternalEvent.hpp>
-#include <common/Time.hpp>
 
 
 #include <limits>
 #include <limits>
 #include <string>
 #include <string>
@@ -37,17 +36,26 @@
 
 
 namespace paradevs { namespace dtss {
 namespace paradevs { namespace dtss {
 
 
+template < class Time >
 class Dynamics
 class Dynamics
 {
 {
 public:
 public:
-    Dynamics(const std::string& name);
-    virtual ~Dynamics();
+    Dynamics(const std::string& name) : _name(name)
+    { }
+
+    virtual ~Dynamics()
+    { }
 
 
-    virtual void transition(const common::Bag& /* x */, common::Time /* t */)
+    virtual void transition(const common::Bag < Time >& /* x */,
+                            typename Time::type /* t */)
     { }
     { }
-    virtual common::Time start(common::Time /* time */)
-    { return std::numeric_limits < double >::max(); }
-    virtual common::Bag lambda(common::Time /* time */) const;
+
+    virtual typename Time::type start(typename Time::type/* time */)
+    { return Time::infinity; }
+
+    common::Bag < Time > lambda(typename Time::type /* time */) const
+    { return common::Bag < Time >(); }
+
     virtual void observation(std::ostream& /* file */) const
     virtual void observation(std::ostream& /* file */) const
     { }
     { }
 
 

+ 0 - 65
src/dtss/GraphManager.cpp

@@ -28,69 +28,4 @@
 
 
 namespace paradevs { namespace dtss {
 namespace paradevs { namespace dtss {
 
 
-GraphManager::GraphManager(common::Coordinator* coordinator) :
-    _coordinator(coordinator)
-{ }
-
-GraphManager::~GraphManager()
-{
-    for (auto & child : _child_list) {
-        delete child;
-    }
-}
-
-void GraphManager::add_child(common::Model* child)
-{
-    _child_list.push_back(child);
-    child->set_parent(_coordinator);
-}
-
-void GraphManager::add_link(common::Model* out_model,
-                            const std::string& out_port_name,
-                            common::Model* in_model,
-                            const std::string& in_port_name)
-{
-    _link_list.add(out_model, out_port_name, in_model, in_port_name);
-}
-
-void GraphManager::dispatch_events(common::Bag bag, common::Time t)
-{
-    for (auto & ymsg : bag) {
-        common::Links::Result result_model =
-            _link_list.find(ymsg.get_model(),
-                            ymsg.get_port_name());
-
-        for (common::Links::const_iterator it = result_model.first;
-             it != result_model.second; ++it) {
-            // event on output port of coupled model
-            if (it->second.get_model() == _coordinator) {
-                common::Bag ymessages;
-
-                ymessages.push_back(
-                    common::ExternalEvent(it->second, ymsg.get_content()));
-                dynamic_cast < common::Coordinator* >(
-                    _coordinator->get_parent())->dispatch_events(ymessages, t);
-            } else { // event on input port of internal model
-                it->second.get_model()->post_event(
-                    t, common::ExternalEvent(it->second,
-                                             ymsg.get_content()));
-            }
-        }
-    }
-}
-
-void GraphManager::post_event(common::Time t,
-                              const common::ExternalEvent& event)
-{
-    common::Links::Result result =
-        _link_list.find(_coordinator, event.get_port_name());
-
-    for (common::Links::const_iterator it_r = result.first;
-         it_r != result.second; ++it_r) {
-        it_r->second.get_model()->post_event(
-            t, common::ExternalEvent(it_r->second,
-                                     event.get_content()));
-    }
-}
-
 } } // namespace paradevs dtss
 } } // namespace paradevs dtss

+ 67 - 13
src/dtss/GraphManager.hpp

@@ -33,30 +33,84 @@
 
 
 namespace paradevs { namespace dtss {
 namespace paradevs { namespace dtss {
 
 
+template < class Time >
 class GraphManager
 class GraphManager
 {
 {
 public:
 public:
-    GraphManager(common::Coordinator* coordinator);
-    virtual ~GraphManager();
+    GraphManager(common::Coordinator < Time >* coordinator) :
+        _coordinator(coordinator)
+    { }
 
 
-    virtual void add_child(common::Model* child);
+    virtual ~GraphManager()
+    {
+        for (auto & child : _child_list) {
+            delete child;
+        }
+    }
 
 
-    virtual void add_link(common::Model* out_model,
-                          const std::string& out_port_name,
-                          common::Model* in_model,
-                          const std::string& in_port_name);
+    void add_child(common::Model < Time >* child)
+    {
+        _child_list.push_back(child);
+        child->set_parent(_coordinator);
+    }
 
 
-    const common::Models& children() const
+    void add_link(common::Model < Time >* out_model,
+                  const std::string& out_port_name,
+                  common::Model < Time >* in_model,
+                  const std::string& in_port_name)
+    {
+        _link_list.add(out_model, out_port_name, in_model, in_port_name);
+    }
+
+    const common::Models < Time >& children() const
     { return _child_list; }
     { return _child_list; }
 
 
-    void dispatch_events(common::Bag bag, common::Time t);
+    void dispatch_events(common::Bag < Time > bag, typename Time::type t)
+    {
+        for (auto & ymsg : bag) {
+            typename common::Links < Time >::Result result_model =
+                _link_list.find(ymsg.get_model(),
+                                ymsg.get_port_name());
+
+            for (typename common::Links < Time >::const_iterator it =
+                     result_model.first; it != result_model.second; ++it) {
+                // event on output port of coupled model
+                if (it->second.get_model() == _coordinator) {
+                    common::Bag < Time > ymessages;
+
+                    ymessages.push_back(
+                        common::ExternalEvent < Time >(it->second,
+                                                       ymsg.get_content()));
+                    dynamic_cast < common::Coordinator < Time >* >(
+                        _coordinator->get_parent())->dispatch_events(ymessages,
+                                                                     t);
+                } else { // event on input port of internal model
+                    it->second.get_model()->post_event(
+                        t, common::ExternalEvent < Time >(it->second,
+                                                 ymsg.get_content()));
+                }
+            }
+        }
+    }
+
+    void post_event(typename Time::type t,
+                    const common::ExternalEvent < Time >& event)
+    {
+        typename common::Links < Time >::Result result =
+            _link_list.find(_coordinator, event.get_port_name());
 
 
-    void post_event(common::Time t, const common::ExternalEvent& event);
+        for (typename common::Links < Time >::const_iterator it_r =
+                 result.first; it_r != result.second; ++it_r) {
+            it_r->second.get_model()->post_event(
+                t, common::ExternalEvent < Time >(it_r->second,
+                                         event.get_content()));
+        }
+    }
 
 
 private:
 private:
-    common::Links        _link_list;
-    common::Models       _child_list;
-    common::Coordinator* _coordinator;
+    common::Links < Time >        _link_list;
+    common::Models < Time >       _child_list;
+    common::Coordinator < Time >* _coordinator;
 };
 };
 
 
 } } // namespace paradevs dtss
 } } // namespace paradevs dtss

+ 89 - 67
src/dtss/Simulator.hpp

@@ -35,36 +35,43 @@
 
 
 namespace paradevs { namespace dtss {
 namespace paradevs { namespace dtss {
 
 
-template < class Dynamics >
-class Simulator : public common::Simulator
+template < class Time, class Dynamics >
+class Simulator : public common::Simulator < Time >
 {
 {
-public :
-    Simulator(const std::string& name, common::Time time_step) :
-        common::Simulator(name), _dynamics(name), _time_step(time_step)
+public:
+    Simulator(const std::string& name, typename Time::type time_step) :
+        common::Simulator < Time >(name), _dynamics(name),
+        _time_step(time_step)
     { }
     { }
 
 
     ~Simulator()
     ~Simulator()
     {  }
     {  }
 
 
-    common::Time start(common::Time t)
+    typename Time::type start(typename Time::type t)
     {
     {
-        common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                       common::I_MESSAGE)
-                               << ": BEFORE => "
-                               << "tl = " << _tl << " ; tn = " << _tn;
-        common::Trace::trace().flush();
+        common::Trace < Time >::trace()
+            << common::TraceElement < Time >(
+                Simulator < Time, Dynamics >::get_name(), t,
+                common::I_MESSAGE)
+            << ": BEFORE => "
+            << "tl = " << Simulator < Time, Dynamics >::_tl
+            << " ; tn = " << Simulator < Time, Dynamics >::_tn;
+        common::Trace < Time >::trace().flush();
 
 
         _dynamics.start(t);
         _dynamics.start(t);
-        _tl = t;
-        _tn = t;
-
-        common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                       common::I_MESSAGE)
-                               << ": AFTER => "
-                               << "tl = " << _tl << " ; tn = " << _tn;
-        common::Trace::trace().flush();
-
-        return _tn;
+        Simulator < Time, Dynamics >::_tl = t;
+        Simulator < Time, Dynamics >::_tn = t;
+
+        common::Trace < Time >::trace()
+            << common::TraceElement < Time >(
+                Simulator < Time, Dynamics >::get_name(), t,
+                common::I_MESSAGE)
+            << ": AFTER => "
+            << "tl = " << Simulator < Time, Dynamics >::_tl
+            << " ; tn = " << Simulator < Time, Dynamics >::_tn;
+        common::Trace < Time >::trace().flush();
+
+        return Simulator < Time, Dynamics >::_tn;
     }
     }
 
 
     void observation(std::ostream &file) const
     void observation(std::ostream &file) const
@@ -72,78 +79,93 @@ public :
         _dynamics.observation(file);
         _dynamics.observation(file);
     }
     }
 
 
-    void output(common::Time t)
+    void output(typename Time::type t)
     {
     {
-        common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                       common::OUTPUT)
-                               << ": BEFORE";
-        common::Trace::trace().flush();
+        common::Trace < Time >::trace()
+            << common::TraceElement < Time >(
+                Simulator < Time, Dynamics >::get_name(), t,
+                common::OUTPUT)
+            << ": BEFORE";
+        common::Trace < Time >::trace().flush();
 
 
-        if(t == _tn) {
-            common::Bag bag = _dynamics.lambda(t);
+        if (t == Simulator < Time, Dynamics >::_tn) {
+            common::Bag < Time > bag = _dynamics.lambda(t);
 
 
             if (not bag.empty()) {
             if (not bag.empty()) {
                 for (auto & event : bag) {
                 for (auto & event : bag) {
                     event.set_model(this);
                     event.set_model(this);
                 }
                 }
-                dynamic_cast < common::Coordinator* >(get_parent())
+                dynamic_cast < common::Coordinator < Time >* >(
+                    Simulator < Time, Dynamics >::get_parent())
                     ->dispatch_events(bag, t);
                     ->dispatch_events(bag, t);
             }
             }
         }
         }
 
 
-        common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                       common::OUTPUT)
-                               << ": AFTER";
-        common::Trace::trace().flush();
+        common::Trace < Time >::trace()
+            << common::TraceElement < Time >(
+                Simulator < Time, Dynamics >::get_name(), t,
+                common::OUTPUT)
+            << ": AFTER";
+        common::Trace < Time >::trace().flush();
 
 
     }
     }
 
 
-    void post_event(common::Time t,
-                    const common::ExternalEvent& event)
+    void post_event(typename Time::type t,
+                    const common::ExternalEvent < Time >& event)
     {
     {
 
 
-        common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                       common::POST_EVENT)
-                               << ": BEFORE => " << event.to_string();
-        common::Trace::trace().flush();
+        common::Trace < Time >::trace()
+            << common::TraceElement < Time >(
+                Simulator < Time, Dynamics >::get_name(), t,
+                common::POST_EVENT)
+            << ": BEFORE => " << event.to_string();
+        common::Trace < Time >::trace().flush();
 
 
-        add_event(event);
+        Simulator < Time, Dynamics >::add_event(event);
 
 
-        common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                       common::POST_EVENT)
-                               << ": AFTER => " << event.to_string();
-        common::Trace::trace().flush();
+        common::Trace < Time >::trace()
+            << common::TraceElement < Time >(
+                Simulator < Time, Dynamics >::get_name(), t,
+                common::POST_EVENT)
+            << ": AFTER => " << event.to_string();
+        common::Trace < Time >::trace().flush();
 
 
     }
     }
 
 
-    common::Time transition(common::Time t)
+    typename Time::type transition(typename Time::type t)
     {
     {
 
 
-        common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                       common::S_MESSAGE)
-                               << ": BEFORE => "
-                               << "tl = " << _tl << " ; tn = " << _tn;
-        common::Trace::trace().flush();
-
-        assert(t == _tn);
-
-        _dynamics.transition(get_bag(), t);
-        _tl = t;
-        _tn = t + _time_step;
-        clear_bag();
-
-        common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                       common::S_MESSAGE)
-                               << ": AFTER => "
-                               << "tl = " << _tl << " ; tn = " << _tn;
-        common::Trace::trace().flush();
-
-        return _tn;
+        common::Trace < Time >::trace()
+            << common::TraceElement < Time >(
+                Simulator < Time, Dynamics >::get_name(), t,
+                common::S_MESSAGE)
+            << ": BEFORE => "
+            << "tl = " << Simulator < Time, Dynamics >::_tl
+            << " ; tn = " << Simulator < Time, Dynamics >::_tn;
+        common::Trace < Time >::trace().flush();
+
+        // assert(t == Simulator < Time, Dynamics >::_tn);
+
+        _dynamics.transition(Simulator < Time, Dynamics >::get_bag(), t);
+        Simulator < Time, Dynamics >::_tl = t;
+        Simulator < Time, Dynamics >::_tn = t + _time_step;
+        Simulator < Time, Dynamics >::clear_bag();
+
+        common::Trace < Time >::trace()
+            << common::TraceElement < Time >(
+                Simulator < Time, Dynamics >::get_name(), t,
+                common::S_MESSAGE)
+            << ": AFTER => "
+            << "tl = " << Simulator < Time, Dynamics >::_tl
+            << " ; tn = " << Simulator < Time, Dynamics >::_tn;
+        common::Trace < Time >::trace().flush();
+
+        return Simulator < Time, Dynamics >::_tn;
     }
     }
 
 
 private :
 private :
-    Dynamics     _dynamics;
-    common::Time _time_step;
+    Dynamics            _dynamics;
+    typename Time::type _time_step;
 };
 };
 
 
 } } // namespace paradevs dtss
 } } // namespace paradevs dtss

+ 112 - 84
src/pdevs/Coordinator.hpp

@@ -29,6 +29,7 @@
 
 
 #include <common/Coordinator.hpp>
 #include <common/Coordinator.hpp>
 #include <common/EventTable.hpp>
 #include <common/EventTable.hpp>
+#include <common/Trace.hpp>
 
 
 #include <cassert>
 #include <cassert>
 #include <iostream>
 #include <iostream>
@@ -42,43 +43,52 @@ public:
     { }
     { }
 };
 };
 
 
-template < class GraphManager >
-class Coordinator : public common::Coordinator
+template < class Time, class GraphManager >
+class Coordinator : public common::Coordinator < Time >
 {
 {
 public:
 public:
     typedef Parameters parameters_type;
     typedef Parameters parameters_type;
 
 
     Coordinator(const std::string& name, const Parameters& /* parameters */) :
     Coordinator(const std::string& name, const Parameters& /* parameters */) :
-        common::Coordinator(name), _graph_manager(this)
+        common::Coordinator < Time >(name), _graph_manager(this)
     { }
     { }
 
 
     virtual ~Coordinator()
     virtual ~Coordinator()
     { }
     { }
 
 
-    common::Time start(common::Time t)
+    typename Time::type start(typename Time::type t)
     {
     {
 
 
-        common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                       common::I_MESSAGE)
-                               << ": BEFORE => "
-                               << "tl = " << _tl << " ; tn = " << _tn;
-        common::Trace::trace().flush();
+        common::Trace < Time >::trace()
+            << common::TraceElement < Time >(
+                Coordinator < Time, GraphManager >::get_name(), t,
+                common::I_MESSAGE)
+            << ": BEFORE => "
+            << "tl = " << Coordinator < Time, GraphManager >::_tl
+            << " ; tn = " << Coordinator < Time, GraphManager >::_tn;
+        common::Trace < Time >::trace().flush();
 
 
         assert(_graph_manager.children().size() > 0);
         assert(_graph_manager.children().size() > 0);
 
 
         for (auto & child : _graph_manager.children()) {
         for (auto & child : _graph_manager.children()) {
-            _event_table.init(child->start(_tn), child);
+            _event_table.init(child->start(
+                                  Coordinator < Time, GraphManager >::_tn),
+                              child);
         }
         }
-        _tl = t;
-        _tn = _event_table.get_current_time();
-
-        common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                       common::I_MESSAGE)
-                               << ": AFTER => "
-                               << "tl = " << _tl << " ; tn = " << _tn;
-        common::Trace::trace().flush();
-
-        return _tn;
+        Coordinator < Time, GraphManager >::_tl = t;
+        Coordinator < Time, GraphManager >::_tn =
+            _event_table.get_current_time();
+
+        common::Trace < Time >::trace()
+            << common::TraceElement < Time >(
+                Coordinator < Time, GraphManager >::get_name(), t,
+                common::I_MESSAGE)
+            << ": AFTER => "
+            << "tl = " << Coordinator < Time, GraphManager >::_tl
+            << " ; tn = " << Coordinator < Time, GraphManager >::_tn;
+        common::Trace < Time >::trace().flush();
+
+        return Coordinator < Time, GraphManager >::_tn;
     }
     }
 
 
 /**************************************************
 /**************************************************
@@ -90,35 +100,43 @@ public:
  *   ...
  *   ...
  *  send done to parent
  *  send done to parent
  **************************************************/
  **************************************************/
-    void output(common::Time t)
+    void output(typename Time::type t)
     {
     {
 
 
-        common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                       common::OUTPUT)
-                               << ": BEFORE => "
-                               << "tl = " << _tl << " ; tn = " << _tn
-                               << " ; scheduler = " << _event_table.to_string();
-        common::Trace::trace().flush();
+        common::Trace < Time >::trace()
+            << common::TraceElement < Time >(
+                Coordinator < Time, GraphManager >::get_name(), t,
+                common::OUTPUT)
+            << ": BEFORE => "
+            << "tl = " << Coordinator < Time, GraphManager >::_tl
+            << " ; tn = " << Coordinator < Time, GraphManager >::_tn
+            << " ; scheduler = " << _event_table.to_string();
+        common::Trace < Time >::trace().flush();
 
 
-        assert(t == _tn);
+        // assert(t == Coordinator < Time, GraphManager >::_tn);
 
 
-        common::Models IMM = _event_table.get_current_models(t);
+        common::Models < Time > IMM = _event_table.get_current_models(t);
 
 
-        common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                       common::OUTPUT)
-                               << ": IMM = " << IMM.to_string();
-        common::Trace::trace().flush();
+        common::Trace < Time >::trace()
+            << common::TraceElement < Time >(
+                Coordinator < Time, GraphManager >::get_name(), t,
+                common::OUTPUT)
+            << ": IMM = " << IMM.to_string();
+        common::Trace < Time >::trace().flush();
 
 
         for (auto & model : IMM) {
         for (auto & model : IMM) {
             model->output(t);
             model->output(t);
         }
         }
 
 
-        common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                       common::OUTPUT)
-                               << ": AFTER => "
-                               << "tl = " << _tl << " ; tn = " << _tn
-                               << " ; scheduler = " << _event_table.to_string();
-        common::Trace::trace().flush();
+        common::Trace < Time >::trace()
+            << common::TraceElement < Time >(
+                Coordinator < Time, GraphManager >::get_name(), t,
+                common::OUTPUT)
+            << ": AFTER => "
+            << "tl = " << Coordinator < Time, GraphManager >::_tl
+            << " ; tn = " << Coordinator < Time, GraphManager >::_tn
+            << " ; scheduler = " << _event_table.to_string();
+        common::Trace < Time >::trace().flush();
 
 
     }
     }
 
 
@@ -133,88 +151,97 @@ public:
  *   tl = t
  *   tl = t
  *   tn = min(tn_d | d in D)
  *   tn = min(tn_d | d in D)
  *******************************************************************/
  *******************************************************************/
-    common::Time transition(common::Time t)
+    typename Time::type transition(typename Time::type t)
     {
     {
 
 
-        common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                       common::S_MESSAGE)
-                               << ": BEFORE => "
-                               << "tl = " << _tl << " ; tn = " << _tn
-                               << " ; scheduler = " << _event_table.to_string();
-        common::Trace::trace().flush();
+        common::Trace < Time >::trace()
+            << common::TraceElement < Time >(
+                Coordinator < Time, GraphManager >::get_name(), t,
+                common::S_MESSAGE)
+            << ": BEFORE => "
+            << "tl = " << Coordinator < Time, GraphManager >::_tl
+            << " ; tn = " << Coordinator < Time, GraphManager >::_tn
+            << " ; scheduler = " << _event_table.to_string();
+        common::Trace < Time >::trace().flush();
 
 
-        assert(t >= _tl and t <= _tn);
+        // assert(t >= Coordinator < Time, GraphManager >::_tl and t <= Coordinator < Time, GraphManager >::_tn);
 
 
-        common::Models receivers = _event_table.get_current_models(t);
+        common::Models < Time > receivers = _event_table.get_current_models(t);
 
 
         add_models_with_inputs(receivers);
         add_models_with_inputs(receivers);
 
 
-        common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                       common::S_MESSAGE)
-                               << ": receivers = " << receivers.to_string();
-        common::Trace::trace().flush();
+        common::Trace < Time >::trace()
+            << common::TraceElement < Time >(
+                Coordinator < Time, GraphManager >::get_name(), t,
+                common::S_MESSAGE)
+            << ": receivers = " << receivers.to_string();
+        common::Trace < Time >::trace().flush();
 
 
         for (auto & model : receivers) {
         for (auto & model : receivers) {
             _event_table.put(model->transition(t), model);
             _event_table.put(model->transition(t), model);
         }
         }
         update_event_table(t);
         update_event_table(t);
-        _tl = t;
-        _tn = _event_table.get_current_time();
-        clear_bag();
-
-        common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                       common::S_MESSAGE)
-                               << ": AFTER => "
-                               << "tl = " << _tl << " ; tn = " << _tn
-                               << " ; scheduler = " << _event_table.to_string();
-        common::Trace::trace().flush();
-
-        return _tn;
+        Coordinator < Time, GraphManager >::_tl = t;
+        Coordinator < Time, GraphManager >::_tn =
+            _event_table.get_current_time();
+        Coordinator < Time, GraphManager >::clear_bag();
+
+        common::Trace < Time >::trace()
+            << common::TraceElement < Time >(
+                Coordinator < Time, GraphManager >::get_name(), t,
+                common::S_MESSAGE)
+            << ": AFTER => "
+            << "tl = " << Coordinator < Time, GraphManager >::_tl
+            << " ; tn = " << Coordinator < Time, GraphManager >::_tn
+            << " ; scheduler = " << _event_table.to_string();
+        common::Trace < Time >::trace().flush();
+
+        return Coordinator < Time, GraphManager >::_tn;
     }
     }
 
 
-    void post_event(common::Time t,
-                    const common::ExternalEvent& event)
+    void post_event(typename Time::type t,
+                    const common::ExternalEvent < Time >& event)
     {
     {
 
 
-        common::Trace::trace() << common::TraceElement(get_name(), t,
+        common::Trace < Time >::trace() << common::TraceElement < Time >(Coordinator < Time, GraphManager >::get_name(), t,
                                                        common::POST_EVENT)
                                                        common::POST_EVENT)
                                << ": BEFORE => " << event.to_string();
                                << ": BEFORE => " << event.to_string();
-        common::Trace::trace().flush();
+        common::Trace < Time >::trace().flush();
 
 
-        add_event(event);
+        Coordinator < Time, GraphManager >::add_event(event);
         _graph_manager.post_event(t, event);
         _graph_manager.post_event(t, event);
         update_event_table(t);
         update_event_table(t);
-        _tn = _event_table.get_current_time();
+        Coordinator < Time, GraphManager >::_tn = _event_table.get_current_time();
 
 
-        common::Trace::trace() << common::TraceElement(get_name(), t,
+        common::Trace < Time >::trace() << common::TraceElement < Time >(Coordinator < Time, GraphManager >::get_name(), t,
                                                        common::POST_EVENT)
                                                        common::POST_EVENT)
                                << ": AFTER => " << event.to_string();
                                << ": AFTER => " << event.to_string();
-        common::Trace::trace().flush();
+        common::Trace < Time >::trace().flush();
 
 
     }
     }
 
 
 /*******************************************************************
 /*******************************************************************
  * when y-message(y_d, t) with output y_d from d
  * when y-message(y_d, t) with output y_d from d
  *******************************************************************/
  *******************************************************************/
-    common::Time dispatch_events(common::Bag bag, common::Time t)
+    typename Time::type dispatch_events(common::Bag < Time > bag, typename Time::type t)
     {
     {
 
 
-        common::Trace::trace() << common::TraceElement(get_name(), t,
+        common::Trace < Time >::trace() << common::TraceElement < Time >(Coordinator < Time, GraphManager >::get_name(), t,
                                                        common::Y_MESSAGE)
                                                        common::Y_MESSAGE)
                                << ": BEFORE => "
                                << ": BEFORE => "
-                               << "tl = " << _tl << " ; tn = " << _tn
+                               << "tl = " << Coordinator < Time, GraphManager >::_tl << " ; tn = " << Coordinator < Time, GraphManager >::_tn
                                << " ; bag = " << bag.to_string();
                                << " ; bag = " << bag.to_string();
-        common::Trace::trace().flush();
+        common::Trace < Time >::trace().flush();
 
 
         _graph_manager.dispatch_events(bag, t);
         _graph_manager.dispatch_events(bag, t);
 
 
-        common::Trace::trace() << common::TraceElement(get_name(), t,
+        common::Trace < Time >::trace() << common::TraceElement < Time >(Coordinator < Time, GraphManager >::get_name(), t,
                                                        common::Y_MESSAGE)
                                                        common::Y_MESSAGE)
                                << ": BEFORE => "
                                << ": BEFORE => "
-                               << "tl = " << _tl << " ; tn = " << _tn;
-        common::Trace::trace().flush();
+                               << "tl = " << Coordinator < Time, GraphManager >::_tl << " ; tn = " << Coordinator < Time, GraphManager >::_tn;
+        common::Trace < Time >::trace().flush();
 
 
-        return _tn;
+        return Coordinator < Time, GraphManager >::_tn;
     }
     }
 
 
     void observation(std::ostream& file) const
     void observation(std::ostream& file) const
@@ -224,7 +251,7 @@ public:
         }
         }
     }
     }
 
 
-    void add_models_with_inputs(common::Models& receivers)
+    void add_models_with_inputs(common::Models < Time >& receivers)
     {
     {
         for (auto & model : _graph_manager.children()) {
         for (auto & model : _graph_manager.children()) {
             if (model->event_number() > 0) {
             if (model->event_number() > 0) {
@@ -236,7 +263,7 @@ public:
         }
         }
     }
     }
 
 
-    void update_event_table(common::Time t)
+    void update_event_table(typename Time::type t)
     {
     {
         for (auto & model : _graph_manager.children()) {
         for (auto & model : _graph_manager.children()) {
             if (model->event_number() > 0) {
             if (model->event_number() > 0) {
@@ -245,8 +272,9 @@ public:
         }
         }
     }
     }
 
 
-    GraphManager       _graph_manager;
-    common::EventTable _event_table;
+private:
+    GraphManager                _graph_manager;
+    common::EventTable < Time > _event_table;
 };
 };
 
 
 } } // namespace paradevs pdevs
 } } // namespace paradevs pdevs

+ 0 - 9
src/pdevs/Dynamics.cpp

@@ -28,14 +28,5 @@
 
 
 namespace paradevs { namespace pdevs {
 namespace paradevs { namespace pdevs {
 
 
-Dynamics::Dynamics(const std::string& name) : _name(name)
-{ }
-
-Dynamics::~Dynamics()
-{ }
-
-common::Bag Dynamics::lambda(common::Time /* time */) const
-{ return common::Bag(); }
-
 } } // namespace paradevs pdevs
 } } // namespace paradevs pdevs
 
 

+ 25 - 14
src/pdevs/Dynamics.hpp

@@ -29,33 +29,44 @@
 
 
 #include <common/Bag.hpp>
 #include <common/Bag.hpp>
 #include <common/ExternalEvent.hpp>
 #include <common/ExternalEvent.hpp>
-#include <common/Time.hpp>
 
 
-#include <limits>
 #include <string>
 #include <string>
 #include <vector>
 #include <vector>
 
 
 namespace paradevs { namespace pdevs {
 namespace paradevs { namespace pdevs {
 
 
+template < class Time >
 class Dynamics
 class Dynamics
 {
 {
 public:
 public:
-    Dynamics(const std::string& name);
-    virtual ~Dynamics();
+    Dynamics(const std::string& name) : _name(name)
+    { }
 
 
-    virtual void dconf(common::Time /* t */, common::Time /* e */,
-                       const common::Bag& /* bag */)
+    virtual ~Dynamics()
     { }
     { }
-    virtual void dint(common::Time /* t */)
+
+    virtual void dconf(typename Time::type /* t */,
+                       typename Time::type /* e */,
+                       const common::Bag < Time >& /* bag */)
     { }
     { }
-    virtual void dext(common::Time /* t */, common::Time /* e */,
-                      const common::Bag& /* bag */)
+
+    virtual void dint(typename Time::type /* t */)
+    { }
+
+    virtual void dext(typename Time::type /* t */,
+                      typename Time::type /* e */,
+                      const common::Bag < Time >& /* bag */)
     { }
     { }
-    virtual common::Time start(common::Time /* time */)
-    { return std::numeric_limits < double >::max(); }
-    virtual common::Time ta(common::Time /* time */) const
-    { return std::numeric_limits < double >::max(); }
-    virtual common::Bag lambda(common::Time /* time */) const;
+
+    virtual typename Time::type start(typename Time::type /* time */)
+    { return Time::infinity; }
+
+    virtual typename Time::type ta(typename Time::type /* time */) const
+    { return Time::infinity; }
+
+    virtual common::Bag < Time > lambda(typename Time::type /* time */) const
+    { return common::Bag < Time >(); }
+
     virtual void observation(std::ostream& /* file */) const
     virtual void observation(std::ostream& /* file */) const
     { }
     { }
 
 

+ 0 - 65
src/pdevs/GraphManager.cpp

@@ -28,69 +28,4 @@
 
 
 namespace paradevs { namespace pdevs {
 namespace paradevs { namespace pdevs {
 
 
-GraphManager::GraphManager(common::Coordinator* coordinator) :
-    _coordinator(coordinator)
-{ }
-
-GraphManager::~GraphManager()
-{
-    for (auto & child : _child_list) {
-        delete child;
-    }
-}
-
-void GraphManager::add_child(common::Model* child)
-{
-    _child_list.push_back(child);
-    child->set_parent(_coordinator);
-}
-
-void GraphManager::add_link(common::Model* out_model,
-                            const std::string& out_port_name,
-                            common::Model* in_model,
-                            const std::string& in_port_name)
-{
-    _link_list.add(out_model, out_port_name, in_model, in_port_name);
-}
-
-void GraphManager::dispatch_events(common::Bag bag, common::Time t)
-{
-    for (auto & ymsg : bag) {
-        common::Links::Result result_model =
-            _link_list.find(ymsg.get_model(),
-                            ymsg.get_port_name());
-
-        for (common::Links::const_iterator it = result_model.first;
-             it != result_model.second; ++it) {
-            // event on output port of coupled model
-            if (it->second.get_model() == _coordinator) {
-                common::Bag ymessages;
-
-                ymessages.push_back(
-                    common::ExternalEvent(it->second, ymsg.get_content()));
-                dynamic_cast < common::Coordinator* >(
-                    _coordinator->get_parent())->dispatch_events(ymessages, t);
-            } else { // event on input port of internal model
-                it->second.get_model()->post_event(
-                    t, common::ExternalEvent(it->second,
-                                             ymsg.get_content()));
-            }
-        }
-    }
-}
-
-void GraphManager::post_event(common::Time t,
-                              const common::ExternalEvent& event)
-{
-    common::Links::Result result =
-        _link_list.find(_coordinator, event.get_port_name());
-
-    for (common::Links::const_iterator it_r = result.first;
-         it_r != result.second; ++it_r) {
-        it_r->second.get_model()->post_event(
-            t, common::ExternalEvent(it_r->second,
-                                     event.get_content()));
-    }
-}
-
 } } // namespace paradevs pdevs
 } } // namespace paradevs pdevs

+ 70 - 14
src/pdevs/GraphManager.hpp

@@ -33,28 +33,84 @@
 
 
 namespace paradevs { namespace pdevs {
 namespace paradevs { namespace pdevs {
 
 
+template < class Time >
 class GraphManager
 class GraphManager
 {
 {
 public:
 public:
-    GraphManager(common::Coordinator* coordinator);
-    virtual ~GraphManager();
-
-    virtual void add_child(common::Model* child);
-    virtual void add_link(common::Model* out_model,
-                          const std::string& out_port_name,
-                          common::Model* in_model,
-                          const std::string& in_port_name);
-    const common::Models& children() const
+    GraphManager(common::Coordinator < Time >* coordinator) :
+        _coordinator(coordinator)
+    { }
+
+    virtual ~GraphManager()
+    {
+        for (auto & child : _child_list) {
+            delete child;
+        }
+    }
+
+    void add_child(common::Model < Time >* child)
+    {
+        _child_list.push_back(child);
+        child->set_parent(_coordinator);
+    }
+
+    void add_link(common::Model < Time >* out_model,
+                  const std::string& out_port_name,
+                  common::Model < Time >* in_model,
+                  const std::string& in_port_name)
+    {
+        _link_list.add(out_model, out_port_name, in_model, in_port_name);
+    }
+
+    const common::Models < Time >& children() const
     { return _child_list; }
     { return _child_list; }
 
 
-    void dispatch_events(common::Bag bag, common::Time t);
+    void dispatch_events(common::Bag < Time > bag, typename Time::type t)
+    {
+        for (auto & ymsg : bag) {
+            typename common::Links < Time >::Result result_model =
+                _link_list.find(ymsg.get_model(),
+                                ymsg.get_port_name());
+
+            for (typename common::Links < Time >::const_iterator it =
+                     result_model.first; it != result_model.second; ++it) {
+                // event on output port of coupled model
+                if (it->second.get_model() == _coordinator) {
+                    common::Bag < Time > ymessages;
+
+                    ymessages.push_back(
+                        common::ExternalEvent < Time >(it->second,
+                                                       ymsg.get_content()));
+                    dynamic_cast < common::Coordinator < Time >* >(
+                        _coordinator->get_parent())->dispatch_events(ymessages,
+                                                                     t);
+                } else { // event on input port of internal model
+                    it->second.get_model()->post_event(
+                        t, common::ExternalEvent < Time >(it->second,
+                                                 ymsg.get_content()));
+                }
+            }
+        }
+    }
+
+    void post_event(typename Time::type t,
+                    const common::ExternalEvent < Time >& event)
+    {
+        typename common::Links < Time >::Result result =
+            _link_list.find(_coordinator, event.get_port_name());
 
 
-    void post_event(common::Time t, const common::ExternalEvent& event);
+        for (typename common::Links < Time >::const_iterator it_r =
+                 result.first; it_r != result.second; ++it_r) {
+            it_r->second.get_model()->post_event(
+                t, common::ExternalEvent < Time >(it_r->second,
+                                         event.get_content()));
+        }
+    }
 
 
 private:
 private:
-    common::Links        _link_list;
-    common::Models       _child_list;
-    common::Coordinator* _coordinator;
+    common::Links < Time >        _link_list;
+    common::Models < Time >       _child_list;
+    common::Coordinator < Time >* _coordinator;
 };
 };
 
 
 } } // namespace paradevs pdevs
 } } // namespace paradevs pdevs

+ 89 - 65
src/pdevs/Simulator.hpp

@@ -35,12 +35,12 @@
 
 
 namespace paradevs { namespace pdevs {
 namespace paradevs { namespace pdevs {
 
 
-template < class Dynamics >
-class Simulator : public common::Simulator
+template < class Time, class Dynamics >
+class Simulator : public common::Simulator < Time >
 {
 {
 public :
 public :
     Simulator(const std::string& name) :
     Simulator(const std::string& name) :
-        common::Simulator(name), _dynamics(name)
+        common::Simulator < Time >(name), _dynamics(name)
     { }
     { }
 
 
     ~Simulator()
     ~Simulator()
@@ -51,25 +51,32 @@ public :
  *   tl = t - e
  *   tl = t - e
  *   tn = tl + ta(s)
  *   tn = tl + ta(s)
  *************************************************/
  *************************************************/
-    common::Time start(common::Time t)
+    typename Time::type start(typename Time::type t)
     {
     {
 
 
-        common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                       common::I_MESSAGE)
-                               << ": BEFORE => "
-                               << "tl = " << _tl << " ; tn = " << _tn;
-        common::Trace::trace().flush();
-
-        _tl = t;
-        _tn = _tl + _dynamics.start(t);
-
-        common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                       common::I_MESSAGE)
-                               << ": AFTER => "
-                               << "tl = " << _tl << " ; tn = " << _tn;
-        common::Trace::trace().flush();
-
-        return _tn;
+        common::Trace < Time >::trace()
+            << common::TraceElement < Time >(
+                Simulator < Time, Dynamics >::get_name(), t,
+                common::I_MESSAGE)
+            << ": BEFORE => "
+            << "tl = " << Simulator < Time, Dynamics >::_tl
+            << " ; tn = " << Simulator < Time, Dynamics >::_tn;
+        common::Trace < Time >::trace().flush();
+
+        Simulator < Time, Dynamics >::_tl = t;
+        Simulator < Time, Dynamics >::_tn =
+            Simulator < Time, Dynamics >::_tl + _dynamics.start(t);
+
+        common::Trace < Time >::trace()
+            << common::TraceElement < Time >(
+                Simulator < Time, Dynamics >::get_name(), t,
+                common::I_MESSAGE)
+            << ": AFTER => "
+            << "tl = " << Simulator < Time, Dynamics >::_tl
+            << " ; tn = " << Simulator < Time, Dynamics >::_tn;
+        common::Trace < Time >::trace().flush();
+
+        return Simulator < Time, Dynamics >::_tn;
     }
     }
 
 
     void observation(std::ostream &file) const
     void observation(std::ostream &file) const
@@ -83,48 +90,57 @@ public :
  *     y = lambda(s)
  *     y = lambda(s)
  *     send y-message(y,t) to parent
  *     send y-message(y,t) to parent
  *************************************************/
  *************************************************/
-    void output(common::Time t)
+    void output(typename Time::type t)
     {
     {
 
 
-        common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                       common::OUTPUT)
-                               << ": BEFORE";
-        common::Trace::trace().flush();
+        common::Trace < Time >::trace()
+            << common::TraceElement < Time >(
+                Simulator < Time, Dynamics >::get_name(), t,
+                common::OUTPUT)
+            << ": BEFORE";
+        common::Trace < Time >::trace().flush();
 
 
-        if(t == _tn) {
-            common::Bag bag = _dynamics.lambda(t);
+        if(t == Simulator < Time, Dynamics >::_tn) {
+            common::Bag < Time > bag = _dynamics.lambda(t);
 
 
             if (not bag.empty()) {
             if (not bag.empty()) {
                 for (auto & event : bag) {
                 for (auto & event : bag) {
                     event.set_model(this);
                     event.set_model(this);
                 }
                 }
-                dynamic_cast < common::Coordinator* >(get_parent())
+                dynamic_cast < common::Coordinator < Time >* >(
+                    Simulator < Time, Dynamics >::get_parent())
                     ->dispatch_events(bag, t);
                     ->dispatch_events(bag, t);
             }
             }
         }
         }
 
 
-        common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                       common::OUTPUT)
-                               << ": AFTER";
-        common::Trace::trace().flush();
+        common::Trace < Time >::trace()
+            << common::TraceElement < Time >(
+                Simulator < Time, Dynamics >::get_name(), t,
+                common::OUTPUT)
+            << ": AFTER";
+        common::Trace < Time >::trace().flush();
 
 
     }
     }
 
 
-    void post_event(common::Time t,
-                    const common::ExternalEvent& event)
+    void post_event(typename Time::type t,
+                    const common::ExternalEvent < Time >& event)
     {
     {
 
 
-        common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                       common::POST_EVENT)
-                               << ": BEFORE => " << event.to_string();
-        common::Trace::trace().flush();
+        common::Trace < Time >::trace()
+            << common::TraceElement < Time >(
+                Simulator < Time, Dynamics >::get_name(), t,
+                common::POST_EVENT)
+            << ": BEFORE => " << event.to_string();
+        common::Trace < Time >::trace().flush();
 
 
-        add_event(event);
+        Simulator < Time, Dynamics >::add_event(event);
 
 
-        common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                       common::POST_EVENT)
-                               << ": AFTER => " << event.to_string();
-        common::Trace::trace().flush();
+        common::Trace < Time >::trace()
+            << common::TraceElement < Time >(
+                Simulator < Time, Dynamics >::get_name(), t,
+                common::POST_EVENT)
+            << ": AFTER => " << event.to_string();
+        common::Trace < Time >::trace().flush();
 
 
     }
     }
 
 
@@ -140,37 +156,45 @@ public :
  *  tn = t + ta(s)
  *  tn = t + ta(s)
  *  tl = t
  *  tl = t
  *************************************************/
  *************************************************/
-    common::Time transition(common::Time t)
+    typename Time::type transition(typename Time::type t)
     {
     {
 
 
-        common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                       common::S_MESSAGE)
-                               << ": BEFORE => "
-                               << "tl = " << _tl << " ; tn = " << _tn;
-        common::Trace::trace().flush();
+        common::Trace < Time >::trace()
+            << common::TraceElement < Time >(
+                Simulator < Time, Dynamics >::get_name(), t,
+                common::S_MESSAGE)
+            << ": BEFORE => "
+            << "tl = " << Simulator < Time, Dynamics >::_tl
+            << " ; tn = " << Simulator < Time, Dynamics >::_tn;
+        common::Trace < Time >::trace().flush();
 
 
-        assert(_tl <= t and t <= _tn);
+        // assert(Simulator < Time, Dynamics >::_tl <= t and t <= Simulator < Time, Dynamics >::_tn);
 
 
-        if(t == _tn) {
-            if (event_number() == 0) {
+        if(t == Simulator < Time, Dynamics >::_tn) {
+            if (Simulator < Time, Dynamics >::event_number() == 0) {
                 _dynamics.dint(t);
                 _dynamics.dint(t);
             } else {
             } else {
-                _dynamics.dconf(t, t - _tl, get_bag());
+                _dynamics.dconf(t, t - Simulator < Time, Dynamics >::_tl,
+                                Simulator < Time, Dynamics >::get_bag());
             }
             }
         } else {
         } else {
-            _dynamics.dext(t, t - _tl, get_bag());
+            _dynamics.dext(t, t - Simulator < Time, Dynamics >::_tl,
+                           Simulator < Time, Dynamics >::get_bag());
         }
         }
-        _tn = t + _dynamics.ta(t);
-        _tl = t;
-        clear_bag();
-
-        common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                       common::S_MESSAGE)
-                               << ": AFTER => "
-                               << "tl = " << _tl << " ; tn = " << _tn;
-        common::Trace::trace().flush();
-
-        return _tn;
+        Simulator < Time, Dynamics >::_tn = t + _dynamics.ta(t);
+        Simulator < Time, Dynamics >::_tl = t;
+        Simulator < Time, Dynamics >::clear_bag();
+
+        common::Trace < Time >::trace()
+            << common::TraceElement < Time >(
+                Simulator < Time, Dynamics >::get_name(), t,
+                common::S_MESSAGE)
+            << ": AFTER => "
+            << "tl = " << Simulator < Time, Dynamics >::_tl
+            << " ; tn = " << Simulator < Time, Dynamics >::_tn;
+        common::Trace < Time >::trace().flush();
+
+        return Simulator < Time, Dynamics >::_tn;
     }
     }
 
 
 private :
 private :

+ 86 - 64
src/tests/dtss_tests.cpp

@@ -38,93 +38,100 @@
 
 
 namespace paradevs { namespace dtss {
 namespace paradevs { namespace dtss {
 
 
-void A::transition(const common::Bag& /* x */, common::Time t)
+void A::transition(const common::Bag < MyTime >& /* x */, MyTime::type t)
 {
 {
-    common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                   common::DELTA_INT);
-    common::Trace::trace().flush();
+    common::Trace < MyTime >::trace()
+        << common::TraceElement < MyTime >(get_name(), t,
+                                           common::DELTA_INT);
+    common::Trace < MyTime >::trace().flush();
 }
 }
 
 
-common::Time A::start(common::Time t)
+MyTime::type A::start(MyTime::type t)
 {
 {
-    common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                   common::START);
-    common::Trace::trace().flush();
+    common::Trace < MyTime >::trace()
+        << common::TraceElement < MyTime >(get_name(), t,
+                                           common::START);
+    common::Trace < MyTime >::trace().flush();
 
 
     return 0;
     return 0;
 }
 }
 
 
-common::Bag A::lambda(common::Time t) const
+common::Bag < MyTime > A::lambda(MyTime::type t) const
 {
 {
-    common::Bag msgs;
+    common::Bag < MyTime > msgs;
 
 
-    msgs.push_back(common::ExternalEvent("out", 0.));
+    msgs.push_back(common::ExternalEvent < MyTime >("out", 0.));
 
 
-    common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                   common::LAMBDA)
-                           << "messages = " << msgs.to_string();
-    common::Trace::trace().flush();
+    common::Trace < MyTime >::trace()
+        << common::TraceElement < MyTime >(get_name(), t,
+                                           common::LAMBDA)
+        << "messages = " << msgs.to_string();
+    common::Trace < MyTime >::trace().flush();
 
 
     return msgs;
     return msgs;
 }
 }
 
 
-void B::transition(const common::Bag& x, common::Time t)
+void B::transition(const common::Bag < MyTime >& x, MyTime::type t)
 {
 {
-    common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                   common::DELTA_INT)
-                           << "x = " << x.to_string();
-    common::Trace::trace().flush();
+    common::Trace < MyTime >::trace()
+        << common::TraceElement < MyTime >(get_name(), t,
+                                           common::DELTA_INT)
+        << "x = " << x.to_string();
+    common::Trace < MyTime >::trace().flush();
 }
 }
 
 
-common::Time B::start(common::Time t)
+MyTime::type B::start(MyTime::type t)
 {
 {
 
 
-    common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                   common::START);
-    common::Trace::trace().flush();
+    common::Trace < MyTime >::trace()
+        << common::TraceElement < MyTime >(get_name(), t,
+                                           common::START);
+    common::Trace < MyTime >::trace().flush();
 
 
     return 0;
     return 0;
 }
 }
 
 
-common::Bag B::lambda(common::Time t) const
+common::Bag < MyTime > B::lambda(MyTime::type t) const
 {
 {
-    common::Bag msgs;
+    common::Bag < MyTime > msgs;
 
 
-    msgs.push_back(common::ExternalEvent("out", 0.));
+    msgs.push_back(common::ExternalEvent < MyTime >("out", 0.));
 
 
-    common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                   common::LAMBDA)
-                           << "messages = " << msgs.to_string();
-    common::Trace::trace().flush();
+    common::Trace < MyTime >::trace()
+        << common::TraceElement < MyTime >(get_name(), t,
+                                           common::LAMBDA)
+        << "messages = " << msgs.to_string();
+    common::Trace < MyTime >::trace().flush();
 
 
     return msgs;
     return msgs;
 }
 }
 
 
 struct Policy
 struct Policy
 {
 {
-    const common::Bag& bag() const
+    const common::Bag < MyTime >& bag() const
     { return _bag; }
     { return _bag; }
 
 
-    virtual void operator()(common::Time /* t */,
-                            const common::ExternalEvent& event,
-                            common::Time /* tl */,
-                            common::Time /* tn */)
+    virtual void operator()(MyTime::type /* t */,
+                            const common::ExternalEvent < MyTime >& event,
+                            MyTime::type /* tl */,
+                            MyTime::type /* tn */)
     {
     {
         _bag.clear();
         _bag.clear();
         _bag.push_back(event);
         _bag.push_back(event);
     }
     }
 
 
 private:
 private:
-    common::Bag _bag;
+    common::Bag < MyTime > _bag;
 };
 };
 
 
-class OnlyOneGraphManager : public dtss::GraphManager
+class OnlyOneGraphManager : public dtss::GraphManager < MyTime >
 {
 {
 public:
 public:
-    OnlyOneGraphManager(common::Coordinator* coordinator) :
-        dtss::GraphManager(coordinator)
+    OnlyOneGraphManager(common::Coordinator < MyTime >* coordinator) :
+        dtss::GraphManager < MyTime >(coordinator)
     {
     {
-        dtss::Simulator < A >* a = new dtss::Simulator < A >("a", 1);
+        dtss::Simulator < MyTime, A >* a =
+            new dtss::Simulator < MyTime, A >("a", 1);
 
 
         add_child(a);
         add_child(a);
     }
     }
@@ -133,14 +140,16 @@ public:
     { }
     { }
 };
 };
 
 
-class TwoGraphManager : public dtss::GraphManager
+class TwoGraphManager : public dtss::GraphManager < MyTime >
 {
 {
 public:
 public:
-    TwoGraphManager(common::Coordinator* coordinator) :
-        dtss::GraphManager(coordinator)
+    TwoGraphManager(common::Coordinator < MyTime >* coordinator) :
+        dtss::GraphManager < MyTime >(coordinator)
     {
     {
-        dtss::Simulator < A >* a = new dtss::Simulator < A >("a", 1);
-        dtss::Simulator < B >* b = new dtss::Simulator < B >("b", 1);
+        dtss::Simulator < MyTime, A >* a =
+            new dtss::Simulator < MyTime, A >("a", 1);
+        dtss::Simulator < MyTime, B >* b =
+            new dtss::Simulator < MyTime, B >("b", 1);
 
 
         add_child(a);
         add_child(a);
         add_child(b);
         add_child(b);
@@ -157,21 +166,26 @@ TEST_CASE("dtss/only_one", "run")
 {
 {
 
 
     paradevs::common::RootCoordinator <
     paradevs::common::RootCoordinator <
-        paradevs::dtss::Coordinator < paradevs::dtss::Policy,
-                                      paradevs::dtss::OnlyOneGraphManager >
-        > rc(0, 10, "root", paradevs::dtss::Parameters(1));
+        paradevs::dtss::MyTime, paradevs::dtss::Coordinator <
+            paradevs::dtss::MyTime, paradevs::dtss::Policy,
+            paradevs::dtss::OnlyOneGraphManager >
+        > rc(0, 10, "root",
+             paradevs::dtss::Parameters < paradevs::dtss::MyTime >(1));
 
 
-    paradevs::common::Trace::trace().clear();
+    paradevs::common::Trace < paradevs::dtss::MyTime >::trace().clear();
     rc.run();
     rc.run();
 
 
-    REQUIRE(paradevs::common::Trace::trace().elements().
+    REQUIRE(paradevs::common::Trace <
+                paradevs::dtss::MyTime >::trace().elements().
             filter_model_name("a").
             filter_model_name("a").
             filter_type(paradevs::common::START).size() == 1);
             filter_type(paradevs::common::START).size() == 1);
-    for (unsigned int t = 0; t <= 10; ++t) {
-        REQUIRE(paradevs::common::Trace::trace().elements().
+    for (double t = 0; t <= 10; ++t) {
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::dtss::MyTime >::trace().elements().
                 filter_model_name("a").filter_time(t).
                 filter_model_name("a").filter_time(t).
                 filter_type(paradevs::common::DELTA_INT).size() == 1);
                 filter_type(paradevs::common::DELTA_INT).size() == 1);
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::dtss::MyTime >::trace().elements().
                 filter_model_name("a").filter_time(t).
                 filter_model_name("a").filter_time(t).
                 filter_type(paradevs::common::LAMBDA).size() == 1);
                 filter_type(paradevs::common::LAMBDA).size() == 1);
     }
     }
@@ -180,33 +194,41 @@ TEST_CASE("dtss/only_one", "run")
 TEST_CASE("dtss/two", "run")
 TEST_CASE("dtss/two", "run")
 {
 {
     paradevs::common::RootCoordinator <
     paradevs::common::RootCoordinator <
-        paradevs::dtss::Coordinator < paradevs::dtss::Policy,
-                                      paradevs::dtss::TwoGraphManager >
-        > rc(0, 10, "root", paradevs::dtss::Parameters(1));
+        paradevs::dtss::MyTime, paradevs::dtss::Coordinator <
+            paradevs::dtss::MyTime, paradevs::dtss::Policy,
+            paradevs::dtss::TwoGraphManager >
+        > rc(0, 10, "root",
+             paradevs::dtss::Parameters < paradevs::dtss::MyTime >(1));
 
 
-    paradevs::common::Trace::trace().clear();
+    paradevs::common::Trace < paradevs::dtss::MyTime >::trace().clear();
     rc.run();
     rc.run();
 
 
-    REQUIRE(paradevs::common::Trace::trace().elements().
+    REQUIRE(paradevs::common::Trace <
+                paradevs::dtss::MyTime >::trace().elements().
             filter_model_name("a").
             filter_model_name("a").
             filter_type(paradevs::common::START).size() == 1);
             filter_type(paradevs::common::START).size() == 1);
     for (unsigned int t = 0; t <= 10; ++t) {
     for (unsigned int t = 0; t <= 10; ++t) {
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::dtss::MyTime >::trace().elements().
                 filter_model_name("a").filter_time(t).
                 filter_model_name("a").filter_time(t).
                 filter_type(paradevs::common::DELTA_INT).size() == 1);
                 filter_type(paradevs::common::DELTA_INT).size() == 1);
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::dtss::MyTime >::trace().elements().
                 filter_model_name("a").filter_time(t).
                 filter_model_name("a").filter_time(t).
                 filter_type(paradevs::common::LAMBDA).size() == 1);
                 filter_type(paradevs::common::LAMBDA).size() == 1);
     }
     }
 
 
-    REQUIRE(paradevs::common::Trace::trace().elements().
+    REQUIRE(paradevs::common::Trace <
+                paradevs::dtss::MyTime >::trace().elements().
             filter_model_name("b").
             filter_model_name("b").
             filter_type(paradevs::common::START).size() == 1);
             filter_type(paradevs::common::START).size() == 1);
     for (unsigned int t = 0; t <= 10; ++t) {
     for (unsigned int t = 0; t <= 10; ++t) {
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::dtss::MyTime >::trace().elements().
                 filter_model_name("b").filter_time(t).
                 filter_model_name("b").filter_time(t).
                 filter_type(paradevs::common::DELTA_INT).size() == 1);
                 filter_type(paradevs::common::DELTA_INT).size() == 1);
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::dtss::MyTime >::trace().elements().
                 filter_model_name("b").filter_time(t).
                 filter_model_name("b").filter_time(t).
                 filter_type(paradevs::common::LAMBDA).size() == 1);
                 filter_type(paradevs::common::LAMBDA).size() == 1);
     }
     }

+ 23 - 8
src/tests/dtss_tests.hpp

@@ -25,10 +25,23 @@
  */
  */
 
 
 #include <dtss/Dynamics.hpp>
 #include <dtss/Dynamics.hpp>
+#include <common/Time.hpp>
 
 
 namespace paradevs { namespace dtss {
 namespace paradevs { namespace dtss {
 
 
-class A : public Dynamics
+template < typename T >
+struct Limits
+{
+    static constexpr T negative_infinity =
+        -std::numeric_limits < T >::infinity();
+    static constexpr T positive_infinity =
+        std::numeric_limits < T >::infinity();
+    static constexpr T null = 0;
+};
+
+typedef paradevs::common::Time < double, Limits < double > > MyTime;
+
+class A : public Dynamics < MyTime >
 {
 {
 public:
 public:
     A(const std::string& name) : Dynamics(name)
     A(const std::string& name) : Dynamics(name)
@@ -36,12 +49,13 @@ public:
     virtual ~A()
     virtual ~A()
     { }
     { }
 
 
-    virtual void transition(const common::Bag& /* x */, common::Time /* t */);
-    virtual common::Time start(common::Time /* t */);
-    virtual common::Bag lambda(common::Time /* t */) const;
+    virtual void transition(const common::Bag < MyTime >& /* x */,
+                            MyTime::type /* t */);
+    virtual MyTime::type start(MyTime::type /* t */);
+    virtual common::Bag < MyTime > lambda(MyTime::type /* t */) const;
 };
 };
 
 
-class B : public Dynamics
+class B : public Dynamics < MyTime >
 {
 {
 public:
 public:
     B(const std::string& name) : Dynamics(name)
     B(const std::string& name) : Dynamics(name)
@@ -49,9 +63,10 @@ public:
     virtual ~B()
     virtual ~B()
     { }
     { }
 
 
-    virtual void transition(const common::Bag& /* x */, common::Time /* t */);
-    virtual common::Time start(common::Time /* t */);
-    virtual common::Bag lambda(common::Time /* t */) const;
+    virtual void transition(const common::Bag < MyTime >& /* x */,
+                            MyTime::type /* t */);
+    virtual MyTime::type start(MyTime::type /* t */);
+    virtual common::Bag < MyTime > lambda(MyTime::type /* t */) const;
 };
 };
 
 
 } } // namespace paradevs dtss
 } } // namespace paradevs dtss

+ 174 - 136
src/tests/mixed_tests.cpp

@@ -42,55 +42,61 @@
 
 
 namespace paradevs {
 namespace paradevs {
 
 
-void A1::dint(common::Time t)
+void A1::dint(typename MyTime::type t)
 {
 {
 
 
-    common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                   common::DELTA_INT);
-    common::Trace::trace().flush();
+    common::Trace < MyTime >::trace() <<
+        common::TraceElement < MyTime >(get_name(), t,
+                                        common::DELTA_INT);
+    common::Trace < MyTime >::trace().flush();
 
 
     if (_phase == SEND) {
     if (_phase == SEND) {
         _phase = WAIT;
         _phase = WAIT;
     }
     }
 }
 }
 
 
-void A1::dext(common::Time t, common::Time /* e */, const common::Bag& msgs)
+void A1::dext(typename MyTime::type t, typename MyTime::type /* e */,
+              const common::Bag < MyTime >& msgs)
 {
 {
 
 
-    common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                   common::DELTA_EXT)
-                           << "messages = " << msgs.to_string();
-    common::Trace::trace().flush();
+    common::Trace < MyTime >::trace()
+        << common::TraceElement < MyTime >(get_name(), t,
+                                           common::DELTA_EXT)
+        << "messages = " << msgs.to_string();
+    common::Trace < MyTime >::trace().flush();
 
 
     _phase = SEND;
     _phase = SEND;
 }
 }
 
 
-void A1::dconf(common::Time t, common::Time /* e */,
-              const common::Bag& msgs)
+void A1::dconf(typename MyTime::type t, typename MyTime::type /* e */,
+               const common::Bag < MyTime >& msgs)
 {
 {
 
 
-    common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                   common::DELTA_CONF)
-                           << "messages = " << msgs.to_string();
-    common::Trace::trace().flush();
+    common::Trace < MyTime >::trace()
+        << common::TraceElement < MyTime >(get_name(), t,
+                                           common::DELTA_CONF)
+        << "messages = " << msgs.to_string();
+    common::Trace < MyTime >::trace().flush();
 
 
 }
 }
 
 
-common::Time A1::start(common::Time t)
+typename MyTime::type A1::start(typename MyTime::type t)
 {
 {
-    common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                   common::START);
-    common::Trace::trace().flush();
+    common::Trace < MyTime >::trace()
+        << common::TraceElement < MyTime >(get_name(), t,
+                                           common::START);
+    common::Trace < MyTime >::trace().flush();
 
 
     _phase = WAIT;
     _phase = WAIT;
     return 0;
     return 0;
 }
 }
 
 
-common::Time A1::ta(common::Time t) const
+typename MyTime::type A1::ta(typename MyTime::type t) const
 {
 {
-    common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                   common::TA);
-    common::Trace::trace().flush();
+    common::Trace < MyTime >::trace()
+        << common::TraceElement < MyTime >(get_name(), t,
+                                           common::TA);
+    common::Trace < MyTime >::trace().flush();
 
 
     if (_phase == WAIT) {
     if (_phase == WAIT) {
         return 1;
         return 1;
@@ -99,70 +105,77 @@ common::Time A1::ta(common::Time t) const
     }
     }
 }
 }
 
 
-common::Bag A1::lambda(common::Time t) const
+common::Bag < MyTime > A1::lambda(typename MyTime::type t) const
 {
 {
-    common::Bag msgs;
+    common::Bag < MyTime > msgs;
 
 
-    msgs.push_back(common::ExternalEvent("out", 0.));
+    msgs.push_back(common::ExternalEvent < MyTime >("out", 0.));
 
 
-    common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                   common::LAMBDA)
-                           << "messages = " << msgs.to_string();
-    common::Trace::trace().flush();
+    common::Trace < MyTime >::trace()
+        << common::TraceElement < MyTime >(get_name(), t,
+                                           common::LAMBDA)
+        << "messages = " << msgs.to_string();
+    common::Trace < MyTime >::trace().flush();
 
 
     return msgs;
     return msgs;
 }
 }
 
 
-void B1::dint(common::Time t)
+void B1::dint(typename MyTime::type t)
 {
 {
 
 
-    common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                   common::DELTA_INT);
-    common::Trace::trace().flush();
+    common::Trace < MyTime >::trace()
+        << common::TraceElement < MyTime >(get_name(), t,
+                                           common::DELTA_INT);
+    common::Trace < MyTime >::trace().flush();
 
 
     if (_phase == SEND) {
     if (_phase == SEND) {
         _phase = WAIT;
         _phase = WAIT;
     }
     }
 }
 }
 
 
-void B1::dext(common::Time t, common::Time /* e */, const common::Bag& msgs)
+void B1::dext(typename MyTime::type t, typename MyTime::type /* e */,
+              const common::Bag < MyTime >& msgs)
 {
 {
 
 
-    common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                   common::DELTA_EXT)
-                           << "messages = " << msgs.to_string();
-    common::Trace::trace().flush();
+    common::Trace < MyTime >::trace()
+        << common::TraceElement < MyTime >(get_name(), t,
+                                           common::DELTA_EXT)
+        << "messages = " << msgs.to_string();
+    common::Trace < MyTime >::trace().flush();
 
 
     _phase = SEND;
     _phase = SEND;
 }
 }
 
 
-void B1::dconf(common::Time t, common::Time /* e */,
-              const common::Bag& msgs)
+void B1::dconf(typename MyTime::type t, typename MyTime::type /* e */,
+               const common::Bag < MyTime >& msgs)
 {
 {
 
 
-    common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                   common::DELTA_CONF)
-                           << "messages = " << msgs.to_string();
-    common::Trace::trace().flush();
+    common::Trace < MyTime >::trace()
+        << common::TraceElement < MyTime >(get_name(), t,
+                                           common::DELTA_CONF)
+        << "messages = " << msgs.to_string();
+    common::Trace < MyTime >::trace().flush();
 
 
 }
 }
 
 
-common::Time B1::start(common::Time t)
+typename MyTime::type B1::start(typename MyTime::type t)
 {
 {
 
 
-    common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                   common::START);
-    common::Trace::trace().flush();
+    common::Trace < MyTime >::trace()
+        << common::TraceElement < MyTime >(get_name(), t,
+                                           common::START);
+    common::Trace < MyTime >::trace().flush();
 
 
     _phase = WAIT;
     _phase = WAIT;
     return std::numeric_limits < double >::max();
     return std::numeric_limits < double >::max();
 }
 }
 
 
-common::Time B1::ta(common::Time t) const
+typename MyTime::type B1::ta(typename MyTime::type t) const
 {
 {
-    common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                   common::TA);
-    common::Trace::trace().flush();
+    common::Trace < MyTime >::trace()
+        << common::TraceElement < MyTime >(get_name(), t,
+                                           common::TA);
+    common::Trace < MyTime >::trace().flush();
 
 
     if (_phase == WAIT) {
     if (_phase == WAIT) {
         return std::numeric_limits < double >::max();
         return std::numeric_limits < double >::max();
@@ -171,122 +184,133 @@ common::Time B1::ta(common::Time t) const
     }
     }
 }
 }
 
 
-common::Bag B1::lambda(common::Time t) const
+common::Bag < MyTime > B1::lambda(typename MyTime::type t) const
 {
 {
-    common::Bag msgs;
+    common::Bag < MyTime > msgs;
 
 
-    msgs.push_back(common::ExternalEvent("out", t));
+    msgs.push_back(common::ExternalEvent < MyTime >("out", t));
 
 
-    common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                   common::LAMBDA)
-                           << "messages = " << msgs.to_string();
-    common::Trace::trace().flush();
+    common::Trace < MyTime >::trace()
+        << common::TraceElement < MyTime >(get_name(), t,
+                                           common::LAMBDA)
+        << "messages = " << msgs.to_string();
+    common::Trace < MyTime >::trace().flush();
 
 
     return msgs;
     return msgs;
 }
 }
 
 
-void A2::transition(const common::Bag& x, common::Time t)
+void A2::transition(const common::Bag < MyTime >& x, typename MyTime::type t)
 {
 {
-    common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                   common::DELTA_INT)
-                           << "x = " << x.to_string();
-    common::Trace::trace().flush();
+    common::Trace < MyTime >::trace()
+        << common::TraceElement < MyTime >(get_name(), t,
+                                           common::DELTA_INT)
+        << "x = " << x.to_string();
+    common::Trace < MyTime >::trace().flush();
 }
 }
 
 
-common::Time A2::start(common::Time t)
+typename MyTime::type A2::start(typename MyTime::type t)
 {
 {
-    common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                   common::START);
-    common::Trace::trace().flush();
+    common::Trace < MyTime >::trace()
+        << common::TraceElement < MyTime >(get_name(), t,
+                                           common::START);
+    common::Trace < MyTime >::trace().flush();
 
 
     return 0;
     return 0;
 }
 }
 
 
-common::Bag A2::lambda(common::Time t) const
+common::Bag < MyTime > A2::lambda(typename MyTime::type t) const
 {
 {
-    common::Bag msgs;
+    common::Bag < MyTime > msgs;
 
 
-    msgs.push_back(common::ExternalEvent("out", 0.));
+    msgs.push_back(common::ExternalEvent < MyTime >("out", 0.));
 
 
-    common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                   common::LAMBDA)
-                           << "messages = " << msgs.to_string();
-    common::Trace::trace().flush();
+    common::Trace < MyTime >::trace()
+        << common::TraceElement < MyTime >(get_name(), t,
+                                           common::LAMBDA)
+        << "messages = " << msgs.to_string();
+    common::Trace < MyTime >::trace().flush();
 
 
     return msgs;
     return msgs;
 }
 }
 
 
-void B2::transition(const common::Bag& x, common::Time t)
+void B2::transition(const common::Bag < MyTime >& x, typename MyTime::type t)
 {
 {
-    common::Trace::trace() << common::TraceElement(get_name(), t,
+    common::Trace < MyTime >::trace()
+        << common::TraceElement < MyTime >(get_name(), t,
                                                    common::DELTA_INT)
                                                    common::DELTA_INT)
                            << "x = " << x.to_string();
                            << "x = " << x.to_string();
-    common::Trace::trace().flush();
+    common::Trace < MyTime >::trace().flush();
 }
 }
 
 
-common::Time B2::start(common::Time t)
+typename MyTime::type B2::start(typename MyTime::type t)
 {
 {
 
 
-    common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                   common::START);
-    common::Trace::trace().flush();
+    common::Trace < MyTime >::trace()
+        << common::TraceElement < MyTime >(get_name(), t,
+                                           common::START);
+    common::Trace < MyTime >::trace().flush();
 
 
     return 0;
     return 0;
 }
 }
 
 
-common::Bag B2::lambda(common::Time t) const
+common::Bag < MyTime > B2::lambda(typename MyTime::type t) const
 {
 {
-    common::Bag msgs;
+    common::Bag < MyTime > msgs;
 
 
-    msgs.push_back(common::ExternalEvent("out", 0.));
+    msgs.push_back(common::ExternalEvent < MyTime >("out", 0.));
 
 
-    common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                   common::LAMBDA)
-                           << "messages = " << msgs.to_string();
-    common::Trace::trace().flush();
+    common::Trace < MyTime >::trace()
+        << common::TraceElement < MyTime >(get_name(), t,
+                                           common::LAMBDA)
+        << "messages = " << msgs.to_string();
+    common::Trace < MyTime >::trace().flush();
 
 
     return msgs;
     return msgs;
 }
 }
 
 
 struct LastBagPolicy
 struct LastBagPolicy
 {
 {
-    const common::Bag& bag() const
+    const common::Bag < MyTime >& bag() const
     { return _bag; }
     { return _bag; }
 
 
-    virtual void operator()(common::Time /* t */,
-                            const common::ExternalEvent& event,
-                            common::Time /* tl */, common::Time /* tn */)
+    virtual void operator()(typename MyTime::type /* t */,
+                            const common::ExternalEvent < MyTime >& event,
+                            typename MyTime::type /* tl */,
+                            typename MyTime::type /* tn */)
     {
     {
         _bag.clear();
         _bag.clear();
         _bag.push_back(event);
         _bag.push_back(event);
     }
     }
 
 
 private:
 private:
-    common::Bag _bag;
+    common::Bag < MyTime > _bag;
 };
 };
 
 
 struct IgnorePolicy
 struct IgnorePolicy
 {
 {
-    const common::Bag& bag() const
+    const common::Bag < MyTime >& bag() const
     { return _bag; }
     { return _bag; }
 
 
-    virtual void operator()(common::Time /* t */,
-                            const common::ExternalEvent& /* event */,
-                            common::Time /* tl */, common::Time /* tn */)
+    virtual void operator()(typename MyTime::type /* t */,
+                            const common::ExternalEvent < MyTime >& /* event */,
+                            typename MyTime::type /* tl */,
+                            typename MyTime::type /* tn */)
     { }
     { }
 
 
 private:
 private:
-    common::Bag _bag;
+    common::Bag < MyTime > _bag;
 };
 };
 
 
-class S1GraphManager : public pdevs::GraphManager
+class S1GraphManager : public pdevs::GraphManager < MyTime >
 {
 {
 public:
 public:
-    S1GraphManager(common::Coordinator* coordinator) :
-        pdevs::GraphManager(coordinator)
+    S1GraphManager(common::Coordinator < MyTime >* coordinator) :
+        pdevs::GraphManager < MyTime >(coordinator)
     {
     {
-        pdevs::Simulator < A1 >* a = new pdevs::Simulator < A1 >("a1");
-        pdevs::Simulator < B1 >* b = new pdevs::Simulator < B1 >("b1");
+        pdevs::Simulator < MyTime, A1 >* a =
+            new pdevs::Simulator < MyTime, A1 >("a1");
+        pdevs::Simulator < MyTime, B1 >* b =
+            new pdevs::Simulator < MyTime, B1 >("b1");
 
 
         add_child(a);
         add_child(a);
         add_child(b);
         add_child(b);
@@ -298,14 +322,16 @@ public:
     { }
     { }
 };
 };
 
 
-class S2GraphManager : public dtss::GraphManager
+class S2GraphManager : public dtss::GraphManager < MyTime >
 {
 {
 public:
 public:
-    S2GraphManager(common::Coordinator* coordinator) :
-        dtss::GraphManager(coordinator)
+    S2GraphManager(common::Coordinator < MyTime >* coordinator) :
+        dtss::GraphManager < MyTime >(coordinator)
     {
     {
-        dtss::Simulator < A2 >* a = new dtss::Simulator < A2 >("a2", 20);
-        dtss::Simulator < B2 >* b = new dtss::Simulator < B2 >("b2", 20);
+        dtss::Simulator < MyTime, A2 >* a =
+            new dtss::Simulator < MyTime, A2 >("a2", 20);
+        dtss::Simulator < MyTime, B2 >* b =
+            new dtss::Simulator < MyTime, B2 >("b2", 20);
 
 
         add_child(a);
         add_child(a);
         add_child(b);
         add_child(b);
@@ -317,18 +343,18 @@ public:
     { }
     { }
 };
 };
 
 
-class RootGraphManager : public pdevs::GraphManager
+class RootGraphManager : public pdevs::GraphManager < MyTime >
 {
 {
 public:
 public:
-    RootGraphManager(common::Coordinator* coordinator) :
-        pdevs::GraphManager(coordinator)
+    RootGraphManager(common::Coordinator < MyTime >* coordinator) :
+        pdevs::GraphManager < MyTime >(coordinator)
     {
     {
-        pdevs::Coordinator < S1GraphManager >* S1 =
-            new pdevs::Coordinator < S1GraphManager >(
+        pdevs::Coordinator < MyTime, S1GraphManager >* S1 =
+            new pdevs::Coordinator < MyTime, S1GraphManager >(
                 "S1", paradevs::pdevs::Parameters());
                 "S1", paradevs::pdevs::Parameters());
-        dtss::Coordinator < LastBagPolicy, S2GraphManager >* S2 =
-            new dtss::Coordinator < LastBagPolicy, S2GraphManager >(
-                "S2", paradevs::dtss::Parameters(20));
+        dtss::Coordinator < MyTime, LastBagPolicy, S2GraphManager >* S2 =
+            new dtss::Coordinator < MyTime, LastBagPolicy, S2GraphManager >(
+                "S2", paradevs::dtss::Parameters < MyTime >(20));
 
 
         add_child(S1);
         add_child(S1);
         add_child(S2);
         add_child(S2);
@@ -344,69 +370,81 @@ public:
 TEST_CASE("mixed/hierachical", "run")
 TEST_CASE("mixed/hierachical", "run")
 {
 {
     paradevs::common::RootCoordinator <
     paradevs::common::RootCoordinator <
-        paradevs::pdevs::Coordinator < paradevs::RootGraphManager >
+        paradevs::MyTime,  paradevs::pdevs::Coordinator <
+            paradevs::MyTime, paradevs::RootGraphManager >
         > rc(0, 100, "root", paradevs::pdevs::Parameters());
         > rc(0, 100, "root", paradevs::pdevs::Parameters());
 
 
-    paradevs::common::Trace::trace().clear();
+    paradevs::common::Trace < paradevs::MyTime >::trace().clear();
     rc.run();
     rc.run();
 
 
-    REQUIRE(paradevs::common::Trace::trace().elements().
+    REQUIRE(paradevs::common::Trace < paradevs::MyTime >::trace().elements().
             filter_model_name("a1").
             filter_model_name("a1").
             filter_type(paradevs::common::START).size() == 1);
             filter_type(paradevs::common::START).size() == 1);
-    REQUIRE(paradevs::common::Trace::trace().elements().
+    REQUIRE(paradevs::common::Trace < paradevs::MyTime >::trace().elements().
             filter_model_name("b1").
             filter_model_name("b1").
             filter_type(paradevs::common::START).size() == 1);
             filter_type(paradevs::common::START).size() == 1);
-    REQUIRE(paradevs::common::Trace::trace().elements().
+    REQUIRE(paradevs::common::Trace < paradevs::MyTime >::trace().elements().
             filter_model_name("a2").
             filter_model_name("a2").
             filter_type(paradevs::common::START).size() == 1);
             filter_type(paradevs::common::START).size() == 1);
-    REQUIRE(paradevs::common::Trace::trace().elements().
+    REQUIRE(paradevs::common::Trace < paradevs::MyTime >::trace().elements().
             filter_model_name("b2").
             filter_model_name("b2").
             filter_type(paradevs::common::START).size() == 1);
             filter_type(paradevs::common::START).size() == 1);
 
 
-    REQUIRE(paradevs::common::Trace::trace().elements().
+    REQUIRE(paradevs::common::Trace < paradevs::MyTime >::trace().elements().
             filter_model_name("a1").
             filter_model_name("a1").
             filter_type(paradevs::common::DELTA_EXT).size() == 0);
             filter_type(paradevs::common::DELTA_EXT).size() == 0);
     for (double t = 0; t <= 100; ++t) {
     for (double t = 0; t <= 100; ++t) {
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::MyTime >::trace().elements().
                 filter_model_name("a1").filter_time(t).
                 filter_model_name("a1").filter_time(t).
                 filter_type(paradevs::common::LAMBDA).size() == 1);
                 filter_type(paradevs::common::LAMBDA).size() == 1);
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::MyTime >::trace().elements().
                 filter_model_name("a1").filter_time(t).
                 filter_model_name("a1").filter_time(t).
                 filter_type(paradevs::common::DELTA_INT).size() == 1);
                 filter_type(paradevs::common::DELTA_INT).size() == 1);
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::MyTime >::trace().elements().
                 filter_model_name("a1").filter_time(t).
                 filter_model_name("a1").filter_time(t).
                 filter_type(paradevs::common::TA).size() == 1);
                 filter_type(paradevs::common::TA).size() == 1);
     }
     }
 
 
     for (double t = 0; t <= 100; ++t) {
     for (double t = 0; t <= 100; ++t) {
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::MyTime >::trace().elements().
                 filter_model_name("b1").filter_time(t).
                 filter_model_name("b1").filter_time(t).
                 filter_type(paradevs::common::LAMBDA).size() == 1);
                 filter_type(paradevs::common::LAMBDA).size() == 1);
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::MyTime >::trace().elements().
                 filter_model_name("b1").filter_time(t).
                 filter_model_name("b1").filter_time(t).
                 filter_type(paradevs::common::DELTA_INT).size() == 1);
                 filter_type(paradevs::common::DELTA_INT).size() == 1);
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::MyTime >::trace().elements().
                 filter_model_name("b1").filter_time(t).
                 filter_model_name("b1").filter_time(t).
                 filter_type(paradevs::common::TA).size() == 2);
                 filter_type(paradevs::common::TA).size() == 2);
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::MyTime >::trace().elements().
                 filter_model_name("b1").filter_time(t).
                 filter_model_name("b1").filter_time(t).
                 filter_type(paradevs::common::DELTA_EXT).size() == 1);
                 filter_type(paradevs::common::DELTA_EXT).size() == 1);
     }
     }
 
 
     for (unsigned int t = 0; t <= 100; t += 20) {
     for (unsigned int t = 0; t <= 100; t += 20) {
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::MyTime >::trace().elements().
                 filter_model_name("a2").filter_time(t).
                 filter_model_name("a2").filter_time(t).
                 filter_type(paradevs::common::LAMBDA).size() == 1);
                 filter_type(paradevs::common::LAMBDA).size() == 1);
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::MyTime >::trace().elements().
                 filter_model_name("a2").filter_time(t).
                 filter_model_name("a2").filter_time(t).
                 filter_type(paradevs::common::DELTA_INT).size() == 1);
                 filter_type(paradevs::common::DELTA_INT).size() == 1);
     }
     }
 
 
     for (unsigned int t = 0; t <= 100; t += 20) {
     for (unsigned int t = 0; t <= 100; t += 20) {
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::MyTime >::trace().elements().
                 filter_model_name("b2").filter_time(t).
                 filter_model_name("b2").filter_time(t).
                 filter_type(paradevs::common::LAMBDA).size() == 1);
                 filter_type(paradevs::common::LAMBDA).size() == 1);
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::MyTime >::trace().elements().
                 filter_model_name("b2").filter_time(t).
                 filter_model_name("b2").filter_time(t).
                 filter_type(paradevs::common::DELTA_INT).size() == 1);
                 filter_type(paradevs::common::DELTA_INT).size() == 1);
     }
     }

+ 51 - 30
src/tests/mixed_tests.hpp

@@ -24,27 +24,44 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
  */
 
 
+#include <common/Time.hpp>
+
 #include <dtss/Dynamics.hpp>
 #include <dtss/Dynamics.hpp>
+
 #include <pdevs/Dynamics.hpp>
 #include <pdevs/Dynamics.hpp>
 
 
 namespace paradevs {
 namespace paradevs {
 
 
-class A1 : public paradevs::pdevs::Dynamics
+template < typename T >
+struct Limits
+{
+    static constexpr T negative_infinity =
+        -std::numeric_limits < T >::infinity();
+    static constexpr T positive_infinity =
+        std::numeric_limits < T >::infinity();
+    static constexpr T null = 0;
+};
+
+typedef paradevs::common::Time < double, Limits < double > > MyTime;
+
+class A1 : public paradevs::pdevs::Dynamics < MyTime >
 {
 {
 public:
 public:
-    A1(const std::string& name) : paradevs::pdevs::Dynamics(name)
+    A1(const std::string& name) : paradevs::pdevs::Dynamics < MyTime >(name)
     { }
     { }
     virtual ~A1()
     virtual ~A1()
     { }
     { }
 
 
-    virtual void dint(common::Time /* t */);
-    virtual void dext(common::Time /* t */, common::Time /* e */,
-                      const common::Bag& /* msgs */);
-    virtual void dconf(common::Time /* t */, common::Time /* e */,
-                       const common::Bag& /* msgs */);
-    virtual common::Time start(common::Time /* t */);
-    virtual common::Time ta(common::Time /* t */) const;
-    virtual common::Bag lambda(common::Time /* t */) const;
+    virtual void dint(typename MyTime::type /* t */);
+    virtual void dext(typename MyTime::type /* t */,
+                      typename MyTime::type /* e */,
+                      const common::Bag < MyTime >& /* msgs */);
+    virtual void dconf(typename MyTime::type /* t */,
+                       typename MyTime::type /* e */,
+                       const common::Bag < MyTime >& /* msgs */);
+    virtual typename MyTime::type start(typename MyTime::type /* t */);
+    virtual typename MyTime::type ta(typename MyTime::type /* t */) const;
+    virtual common::Bag < MyTime > lambda(typename MyTime::type /* t */) const;
 
 
 private:
 private:
     enum Phase { WAIT, SEND };
     enum Phase { WAIT, SEND };
@@ -52,22 +69,24 @@ private:
     Phase _phase;
     Phase _phase;
 };
 };
 
 
-class B1 : public paradevs::pdevs::Dynamics
+class B1 : public paradevs::pdevs::Dynamics < MyTime >
 {
 {
 public:
 public:
-    B1(const std::string& name) : paradevs::pdevs::Dynamics(name)
+    B1(const std::string& name) : paradevs::pdevs::Dynamics < MyTime >(name)
     { }
     { }
     virtual ~B1()
     virtual ~B1()
     { }
     { }
 
 
-    virtual void dint(common::Time /* t */);
-    virtual void dext(common::Time /* t */, common::Time /* e */,
-                      const common::Bag& /* msgs */);
-    virtual void dconf(common::Time /* t */, common::Time /* e */,
-                       const common::Bag& /* msgs */);
-    virtual common::Time start(common::Time /* t */);
-    virtual common::Time ta(common::Time /* t */) const;
-    virtual common::Bag lambda(common::Time /* t */) const;
+    virtual void dint(typename MyTime::type /* t */);
+    virtual void dext(typename MyTime::type /* t */,
+                      typename MyTime::type /* e */,
+                      const common::Bag < MyTime >& /* msgs */);
+    virtual void dconf(typename MyTime::type /* t */,
+                       typename MyTime::type /* e */,
+                       const common::Bag < MyTime >& /* msgs */);
+    virtual typename MyTime::type start(typename MyTime::type /* t */);
+    virtual typename MyTime::type ta(typename MyTime::type /* t */) const;
+    virtual common::Bag < MyTime > lambda(typename MyTime::type /* t */) const;
 
 
 private:
 private:
     enum Phase { WAIT, SEND };
     enum Phase { WAIT, SEND };
@@ -75,30 +94,32 @@ private:
     Phase _phase;
     Phase _phase;
 };
 };
 
 
-class A2 : public paradevs::dtss::Dynamics
+class A2 : public paradevs::dtss::Dynamics < MyTime >
 {
 {
 public:
 public:
-    A2(const std::string& name) : paradevs::dtss::Dynamics(name)
+    A2(const std::string& name) : paradevs::dtss::Dynamics < MyTime >(name)
     { }
     { }
     virtual ~A2()
     virtual ~A2()
     { }
     { }
 
 
-    virtual void transition(const common::Bag& /* x */, common::Time /* t */);
-    virtual common::Time start(common::Time /* t */);
-    virtual common::Bag lambda(common::Time /* t */) const;
+    virtual void transition(const common::Bag < MyTime >& /* x */,
+                            typename MyTime::type /* t */);
+    virtual typename MyTime::type start(typename MyTime::type /* t */);
+    virtual common::Bag < MyTime > lambda(typename MyTime::type /* t */) const;
 };
 };
 
 
-class B2 : public paradevs::dtss::Dynamics
+class B2 : public paradevs::dtss::Dynamics < MyTime >
 {
 {
 public:
 public:
-    B2(const std::string& name) : paradevs::dtss::Dynamics(name)
+    B2(const std::string& name) : paradevs::dtss::Dynamics < MyTime >(name)
     { }
     { }
     virtual ~B2()
     virtual ~B2()
     { }
     { }
 
 
-    virtual void transition(const common::Bag& /* x */, common::Time /* t */);
-    virtual common::Time start(common::Time /* t */);
-    virtual common::Bag lambda(common::Time /* t */) const;
+    virtual void transition(const common::Bag < MyTime >& /* x */,
+                            typename MyTime::type /* t */);
+    virtual typename MyTime::type start(typename MyTime::type /* t */);
+    virtual common::Bag < MyTime > lambda(typename MyTime::type /* t */) const;
 };
 };
 
 
 } // namespace paradevs
 } // namespace paradevs

+ 215 - 142
src/tests/pdevs_tests.cpp

@@ -38,55 +38,61 @@
 
 
 namespace paradevs { namespace pdevs {
 namespace paradevs { namespace pdevs {
 
 
-void A::dint(common::Time t)
+void A::dint(typename MyTime::type t)
 {
 {
 
 
-    common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                   common::DELTA_INT);
-    common::Trace::trace().flush();
+    common::Trace < MyTime >::trace()
+        << common::TraceElement < MyTime >(get_name(), t,
+                                           common::DELTA_INT);
+    common::Trace < MyTime >::trace().flush();
 
 
     if (_phase == SEND) {
     if (_phase == SEND) {
         _phase = WAIT;
         _phase = WAIT;
     }
     }
 }
 }
 
 
-void A::dext(common::Time t, common::Time /* e */, const common::Bag& msgs)
+void A::dext(typename MyTime::type t, typename MyTime::type /* e */,
+             const common::Bag < MyTime >& msgs)
 {
 {
 
 
-    common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                   common::DELTA_EXT)
-                           << "messages = " << msgs.to_string();
-    common::Trace::trace().flush();
+    common::Trace < MyTime >::trace()
+        << common::TraceElement < MyTime >(get_name(), t,
+                                           common::DELTA_EXT)
+        << "messages = " << msgs.to_string();
+    common::Trace < MyTime >::trace().flush();
 
 
     _phase = SEND;
     _phase = SEND;
 }
 }
 
 
-void A::dconf(common::Time t, common::Time /* e */,
-              const common::Bag& msgs)
+void A::dconf(typename MyTime::type t, typename MyTime::type /* e */,
+              const common::Bag < MyTime >& msgs)
 {
 {
 
 
-    common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                   common::DELTA_CONF)
-                           << "messages = " << msgs.to_string();
-    common::Trace::trace().flush();
+    common::Trace < MyTime >::trace()
+        << common::TraceElement < MyTime >(get_name(), t,
+                                           common::DELTA_CONF)
+        << "messages = " << msgs.to_string();
+    common::Trace < MyTime >::trace().flush();
 
 
 }
 }
 
 
-common::Time A::start(common::Time t)
+typename MyTime::type A::start(typename MyTime::type t)
 {
 {
-    common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                   common::START);
-    common::Trace::trace().flush();
+    common::Trace < MyTime >::trace()
+        << common::TraceElement < MyTime >(get_name(), t,
+                                           common::START);
+    common::Trace < MyTime >::trace().flush();
 
 
     _phase = WAIT;
     _phase = WAIT;
     return 0;
     return 0;
 }
 }
 
 
-common::Time A::ta(common::Time t) const
+typename MyTime::type A::ta(typename MyTime::type t) const
 {
 {
-    common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                   common::TA);
-    common::Trace::trace().flush();
+    common::Trace < MyTime >::trace()
+        << common::TraceElement < MyTime >(get_name(), t,
+                                           common::TA);
+    common::Trace < MyTime >::trace().flush();
 
 
     if (_phase == WAIT) {
     if (_phase == WAIT) {
         return 1;
         return 1;
@@ -95,16 +101,17 @@ common::Time A::ta(common::Time t) const
     }
     }
 }
 }
 
 
-common::Bag A::lambda(common::Time t) const
+common::Bag < MyTime > A::lambda(typename MyTime::type t) const
 {
 {
-    common::Bag msgs;
+    common::Bag < MyTime > msgs;
 
 
-    msgs.push_back(common::ExternalEvent("out", 0.));
+    msgs.push_back(common::ExternalEvent < MyTime >("out", 0.));
 
 
-    common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                   common::LAMBDA)
-                           << "messages = " << msgs.to_string();
-    common::Trace::trace().flush();
+    common::Trace < MyTime >::trace()
+        << common::TraceElement < MyTime >(get_name(), t,
+                                           common::LAMBDA)
+        << "messages = " << msgs.to_string();
+    common::Trace < MyTime >::trace().flush();
 
 
     return msgs;
     return msgs;
 }
 }
@@ -112,56 +119,62 @@ common::Bag A::lambda(common::Time t) const
 void A::observation(std::ostream& /* file */) const
 void A::observation(std::ostream& /* file */) const
 { }
 { }
 
 
-void B::dint(common::Time t)
+void B::dint(typename MyTime::type t)
 {
 {
 
 
-    common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                   common::DELTA_INT);
-    common::Trace::trace().flush();
+    common::Trace < MyTime >::trace()
+        << common::TraceElement < MyTime >(get_name(), t,
+                                           common::DELTA_INT);
+    common::Trace < MyTime >::trace().flush();
 
 
     if (_phase == SEND) {
     if (_phase == SEND) {
         _phase = WAIT;
         _phase = WAIT;
     }
     }
 }
 }
 
 
-void B::dext(common::Time t, common::Time /* e */, const common::Bag& msgs)
+void B::dext(typename MyTime::type t, typename MyTime::type /* e */,
+             const common::Bag < MyTime >& msgs)
 {
 {
 
 
-    common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                   common::DELTA_EXT)
-                           << "messages = " << msgs.to_string();
-    common::Trace::trace().flush();
+    common::Trace < MyTime >::trace()
+        << common::TraceElement < MyTime >(get_name(), t,
+                                           common::DELTA_EXT)
+        << "messages = " << msgs.to_string();
+    common::Trace < MyTime >::trace().flush();
 
 
     _phase = SEND;
     _phase = SEND;
 }
 }
 
 
-void B::dconf(common::Time t, common::Time /* e */,
-              const common::Bag& msgs)
+void B::dconf(typename MyTime::type t, typename MyTime::type /* e */,
+              const common::Bag < MyTime >& msgs)
 {
 {
 
 
-    common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                   common::DELTA_CONF)
-                           << "messages = " << msgs.to_string();
-    common::Trace::trace().flush();
+    common::Trace < MyTime >::trace()
+        << common::TraceElement < MyTime >(get_name(), t,
+                                           common::DELTA_CONF)
+        << "messages = " << msgs.to_string();
+    common::Trace < MyTime >::trace().flush();
 
 
 }
 }
 
 
-common::Time B::start(common::Time t)
+typename MyTime::type B::start(typename MyTime::type t)
 {
 {
 
 
-    common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                   common::START);
-    common::Trace::trace().flush();
+    common::Trace < MyTime >::trace()
+        << common::TraceElement < MyTime >(get_name(), t,
+                                           common::START);
+    common::Trace < MyTime >::trace().flush();
 
 
     _phase = WAIT;
     _phase = WAIT;
     return std::numeric_limits < double >::max();
     return std::numeric_limits < double >::max();
 }
 }
 
 
-common::Time B::ta(common::Time t) const
+typename MyTime::type B::ta(typename MyTime::type t) const
 {
 {
-    common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                   common::TA);
-    common::Trace::trace().flush();
+    common::Trace < MyTime >::trace()
+        << common::TraceElement < MyTime >(get_name(), t,
+                                           common::TA);
+    common::Trace < MyTime >::trace().flush();
 
 
     if (_phase == WAIT) {
     if (_phase == WAIT) {
         return std::numeric_limits < double >::max();
         return std::numeric_limits < double >::max();
@@ -170,16 +183,17 @@ common::Time B::ta(common::Time t) const
     }
     }
 }
 }
 
 
-common::Bag B::lambda(common::Time t) const
+common::Bag < MyTime > B::lambda(typename MyTime::type t) const
 {
 {
-    common::Bag msgs;
+    common::Bag < MyTime > msgs;
 
 
-    msgs.push_back(common::ExternalEvent("out", 0.));
+    msgs.push_back(common::ExternalEvent < MyTime >("out", 0.));
 
 
-    common::Trace::trace() << common::TraceElement(get_name(), t,
-                                                   common::LAMBDA)
-                           << "messages = " << msgs.to_string();
-    common::Trace::trace().flush();
+    common::Trace < MyTime >::trace()
+        << common::TraceElement < MyTime >(get_name(), t,
+                                           common::LAMBDA)
+        << "messages = " << msgs.to_string();
+    common::Trace < MyTime >::trace().flush();
 
 
     return msgs;
     return msgs;
 }
 }
@@ -187,14 +201,16 @@ common::Bag B::lambda(common::Time t) const
 void B::observation(std::ostream& /* file */) const
 void B::observation(std::ostream& /* file */) const
 { }
 { }
 
 
-class S1GraphManager : public pdevs::GraphManager
+class S1GraphManager : public pdevs::GraphManager < MyTime >
 {
 {
 public:
 public:
-    S1GraphManager(common::Coordinator* coordinator) :
-        pdevs::GraphManager(coordinator)
+    S1GraphManager(common::Coordinator < MyTime >* coordinator) :
+        pdevs::GraphManager < MyTime >(coordinator)
     {
     {
-        pdevs::Simulator < A >* a = new pdevs::Simulator < A >("a1");
-        pdevs::Simulator < B >* b = new pdevs::Simulator < B >("b1");
+        pdevs::Simulator < MyTime, A >* a =
+            new pdevs::Simulator < MyTime, A >("a1");
+        pdevs::Simulator < MyTime, B >* b =
+            new pdevs::Simulator < MyTime, B >("b1");
 
 
         add_child(a);
         add_child(a);
         add_child(b);
         add_child(b);
@@ -206,14 +222,16 @@ public:
     { }
     { }
 };
 };
 
 
-class S2GraphManager : public pdevs::GraphManager
+class S2GraphManager : public pdevs::GraphManager < MyTime >
 {
 {
 public:
 public:
-    S2GraphManager(common::Coordinator* coordinator) :
-        pdevs::GraphManager(coordinator)
+    S2GraphManager(common::Coordinator < MyTime >* coordinator) :
+        pdevs::GraphManager < MyTime >(coordinator)
     {
     {
-        pdevs::Simulator < A >* a = new pdevs::Simulator < A >("a2");
-        pdevs::Simulator < B >* b = new pdevs::Simulator < B >("b2");
+        pdevs::Simulator < MyTime, A >* a =
+            new pdevs::Simulator < MyTime, A >("a2");
+        pdevs::Simulator < MyTime, B >* b =
+            new pdevs::Simulator < MyTime, B >("b2");
 
 
         add_child(a);
         add_child(a);
         add_child(b);
         add_child(b);
@@ -225,16 +243,16 @@ public:
     { }
     { }
 };
 };
 
 
-class RootGraphManager : public pdevs::GraphManager
+class RootGraphManager : public pdevs::GraphManager < MyTime >
 {
 {
 public:
 public:
-    RootGraphManager(common::Coordinator* coordinator) :
-        pdevs::GraphManager(coordinator)
+    RootGraphManager(common::Coordinator < MyTime >* coordinator) :
+        pdevs::GraphManager < MyTime >(coordinator)
     {
     {
-        Coordinator < S1GraphManager >* S1 =
-            new Coordinator < S1GraphManager >("S1", Parameters());
-        Coordinator < S2GraphManager >* S2 =
-            new Coordinator < S2GraphManager >("S2", Parameters());
+        Coordinator < MyTime, S1GraphManager >* S1 =
+            new Coordinator < MyTime, S1GraphManager >("S1", Parameters());
+        Coordinator < MyTime, S2GraphManager >* S2 =
+            new Coordinator < MyTime, S2GraphManager >("S2", Parameters());
 
 
         add_child(S1);
         add_child(S1);
         add_child(S2);
         add_child(S2);
@@ -245,13 +263,14 @@ public:
     { }
     { }
 };
 };
 
 
-class OnlyOneGraphManager : public pdevs::GraphManager
+class OnlyOneGraphManager : public pdevs::GraphManager < MyTime >
 {
 {
 public:
 public:
-    OnlyOneGraphManager(common::Coordinator* coordinator) :
-        pdevs::GraphManager(coordinator)
+    OnlyOneGraphManager(common::Coordinator < MyTime >* coordinator) :
+        pdevs::GraphManager < MyTime >(coordinator)
     {
     {
-        pdevs::Simulator < A >* a = new pdevs::Simulator < A >("a");
+        pdevs::Simulator < MyTime, A >* a =
+            new pdevs::Simulator < MyTime, A >("a");
 
 
         add_child(a);
         add_child(a);
     }
     }
@@ -260,16 +279,20 @@ public:
     { }
     { }
 };
 };
 
 
-class FlatGraphManager : public pdevs::GraphManager
+class FlatGraphManager : public pdevs::GraphManager < MyTime >
 {
 {
 public:
 public:
-    FlatGraphManager(common::Coordinator* coordinator) :
-        pdevs::GraphManager(coordinator)
+    FlatGraphManager(common::Coordinator < MyTime >* coordinator) :
+        pdevs::GraphManager < MyTime >(coordinator)
     {
     {
-        pdevs::Simulator < A >* a1 = new pdevs::Simulator < A >("a1");
-        pdevs::Simulator < B >* b1 = new pdevs::Simulator < B >("b1");
-        pdevs::Simulator < A >* a2 = new pdevs::Simulator < A >("a2");
-        pdevs::Simulator < B >* b2 = new pdevs::Simulator < B >("b2");
+        pdevs::Simulator < MyTime, A >* a1 =
+            new pdevs::Simulator < MyTime, A >("a1");
+        pdevs::Simulator < MyTime, B >* b1 =
+            new pdevs::Simulator < MyTime, B >("b1");
+        pdevs::Simulator < MyTime, A >* a2 =
+            new pdevs::Simulator < MyTime, A >("a2");
+        pdevs::Simulator < MyTime, B >* b2 =
+            new pdevs::Simulator < MyTime, B >("b2");
 
 
         add_child(a1);
         add_child(a1);
         add_child(b1);
         add_child(b1);
@@ -289,29 +312,36 @@ public:
 TEST_CASE("pdevs/only_one", "run")
 TEST_CASE("pdevs/only_one", "run")
 {
 {
     paradevs::common::RootCoordinator <
     paradevs::common::RootCoordinator <
-        paradevs::pdevs::Coordinator < paradevs::pdevs::OnlyOneGraphManager >
+        paradevs::pdevs::MyTime, paradevs::pdevs::Coordinator <
+            paradevs::pdevs::MyTime, paradevs::pdevs::OnlyOneGraphManager >
         > rc(0, 10, "root", paradevs::pdevs::Parameters());
         > rc(0, 10, "root", paradevs::pdevs::Parameters());
 
 
-    paradevs::common::Trace::trace().clear();
+    paradevs::common::Trace < paradevs::pdevs::MyTime >::trace().clear();
     rc.run();
     rc.run();
 
 
-    REQUIRE(paradevs::common::Trace::trace().elements().
+    REQUIRE(paradevs::common::Trace <
+                paradevs::pdevs::MyTime >::trace().elements().
             filter_model_name("a").
             filter_model_name("a").
             filter_type(paradevs::common::START).size() == 1);
             filter_type(paradevs::common::START).size() == 1);
-    REQUIRE(paradevs::common::Trace::trace().elements().
+    REQUIRE(paradevs::common::Trace <
+                paradevs::pdevs::MyTime >::trace().elements().
             filter_model_name("a").
             filter_model_name("a").
             filter_type(paradevs::common::DELTA_EXT).size() == 0);
             filter_type(paradevs::common::DELTA_EXT).size() == 0);
-    REQUIRE(paradevs::common::Trace::trace().elements().
+    REQUIRE(paradevs::common::Trace <
+                paradevs::pdevs::MyTime >::trace().elements().
             filter_model_name("a").
             filter_model_name("a").
             filter_type(paradevs::common::DELTA_CONF).size() == 0);
             filter_type(paradevs::common::DELTA_CONF).size() == 0);
     for (unsigned int t = 0; t <= 10; ++t) {
     for (unsigned int t = 0; t <= 10; ++t) {
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::pdevs::MyTime >::trace().elements().
                 filter_model_name("a").filter_time(t).
                 filter_model_name("a").filter_time(t).
                 filter_type(paradevs::common::DELTA_INT).size() == 1);
                 filter_type(paradevs::common::DELTA_INT).size() == 1);
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::pdevs::MyTime >::trace().elements().
                 filter_model_name("a").filter_time(t).
                 filter_model_name("a").filter_time(t).
                 filter_type(paradevs::common::TA).size() == 1);
                 filter_type(paradevs::common::TA).size() == 1);
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::pdevs::MyTime >::trace().elements().
                 filter_model_name("a").filter_time(t).
                 filter_model_name("a").filter_time(t).
                 filter_type(paradevs::common::LAMBDA).size() == 1);
                 filter_type(paradevs::common::LAMBDA).size() == 1);
     }
     }
@@ -320,84 +350,105 @@ TEST_CASE("pdevs/only_one", "run")
 TEST_CASE("pdevs/flat", "run")
 TEST_CASE("pdevs/flat", "run")
 {
 {
     paradevs::common::RootCoordinator <
     paradevs::common::RootCoordinator <
-        paradevs::pdevs::Coordinator < paradevs::pdevs::FlatGraphManager >
+        paradevs::pdevs::MyTime, paradevs::pdevs::Coordinator <
+            paradevs::pdevs::MyTime, paradevs::pdevs::FlatGraphManager >
         > rc(0, 10, "root", paradevs::pdevs::Parameters());
         > rc(0, 10, "root", paradevs::pdevs::Parameters());
 
 
-    paradevs::common::Trace::trace().clear();
+    paradevs::common::Trace < paradevs::pdevs::MyTime >::trace().clear();
     rc.run();
     rc.run();
 
 
-    REQUIRE(paradevs::common::Trace::trace().elements().
+    REQUIRE(paradevs::common::Trace <
+                paradevs::pdevs::MyTime >::trace().elements().
             filter_model_name("a1").
             filter_model_name("a1").
             filter_type(paradevs::common::START).size() == 1);
             filter_type(paradevs::common::START).size() == 1);
-    REQUIRE(paradevs::common::Trace::trace().elements().
+    REQUIRE(paradevs::common::Trace <
+                paradevs::pdevs::MyTime >::trace().elements().
             filter_model_name("b1").
             filter_model_name("b1").
             filter_type(paradevs::common::START).size() == 1);
             filter_type(paradevs::common::START).size() == 1);
-    REQUIRE(paradevs::common::Trace::trace().elements().
+    REQUIRE(paradevs::common::Trace <
+                paradevs::pdevs::MyTime >::trace().elements().
             filter_model_name("a2").
             filter_model_name("a2").
             filter_type(paradevs::common::START).size() == 1);
             filter_type(paradevs::common::START).size() == 1);
-    REQUIRE(paradevs::common::Trace::trace().elements().
+    REQUIRE(paradevs::common::Trace <
+                paradevs::pdevs::MyTime >::trace().elements().
             filter_model_name("b2").
             filter_model_name("b2").
             filter_type(paradevs::common::START).size() == 1);
             filter_type(paradevs::common::START).size() == 1);
 
 
-    REQUIRE(paradevs::common::Trace::trace().elements().
+    REQUIRE(paradevs::common::Trace <
+                paradevs::pdevs::MyTime >::trace().elements().
             filter_model_name("a1").
             filter_model_name("a1").
             filter_type(paradevs::common::DELTA_EXT).size() == 0);
             filter_type(paradevs::common::DELTA_EXT).size() == 0);
     for (unsigned int t = 0; t <= 10; ++t) {
     for (unsigned int t = 0; t <= 10; ++t) {
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::pdevs::MyTime >::trace().elements().
                 filter_model_name("a1").filter_time(t).
                 filter_model_name("a1").filter_time(t).
                 filter_type(paradevs::common::LAMBDA).size() == 1);
                 filter_type(paradevs::common::LAMBDA).size() == 1);
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::pdevs::MyTime >::trace().elements().
                 filter_model_name("a1").filter_time(t).
                 filter_model_name("a1").filter_time(t).
                 filter_type(paradevs::common::DELTA_INT).size() == 1);
                 filter_type(paradevs::common::DELTA_INT).size() == 1);
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::pdevs::MyTime >::trace().elements().
                 filter_model_name("a1").filter_time(t).
                 filter_model_name("a1").filter_time(t).
                 filter_type(paradevs::common::TA).size() == 1);
                 filter_type(paradevs::common::TA).size() == 1);
     }
     }
 
 
     for (unsigned int t = 0; t <= 10; ++t) {
     for (unsigned int t = 0; t <= 10; ++t) {
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace < paradevs::pdevs::MyTime >::trace().elements().
                 filter_model_name("b1").filter_time(t).
                 filter_model_name("b1").filter_time(t).
                 filter_type(paradevs::common::LAMBDA).size() == 1);
                 filter_type(paradevs::common::LAMBDA).size() == 1);
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::pdevs::MyTime >::trace().elements().
                 filter_model_name("b1").filter_time(t).
                 filter_model_name("b1").filter_time(t).
                 filter_type(paradevs::common::DELTA_INT).size() == 1);
                 filter_type(paradevs::common::DELTA_INT).size() == 1);
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::pdevs::MyTime >::trace().elements().
                 filter_model_name("b1").filter_time(t).
                 filter_model_name("b1").filter_time(t).
                 filter_type(paradevs::common::TA).size() == 2);
                 filter_type(paradevs::common::TA).size() == 2);
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::pdevs::MyTime >::trace().elements().
                 filter_model_name("b1").filter_time(t).
                 filter_model_name("b1").filter_time(t).
                 filter_type(paradevs::common::DELTA_EXT).size() == 1);
                 filter_type(paradevs::common::DELTA_EXT).size() == 1);
     }
     }
 
 
     for (unsigned int t = 0; t <= 10; ++t) {
     for (unsigned int t = 0; t <= 10; ++t) {
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::pdevs::MyTime >::trace().elements().
                 filter_model_name("a2").filter_time(t).
                 filter_model_name("a2").filter_time(t).
                 filter_type(paradevs::common::LAMBDA).size() == 2);
                 filter_type(paradevs::common::LAMBDA).size() == 2);
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::pdevs::MyTime >::trace().elements().
                 filter_model_name("a2").filter_time(t).
                 filter_model_name("a2").filter_time(t).
                 filter_type(paradevs::common::DELTA_INT).size() == 2);
                 filter_type(paradevs::common::DELTA_INT).size() == 2);
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::pdevs::MyTime >::trace().elements().
                 filter_model_name("a2").filter_time(t).
                 filter_model_name("a2").filter_time(t).
                 filter_type(paradevs::common::TA).size() == 3);
                 filter_type(paradevs::common::TA).size() == 3);
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::pdevs::MyTime >::trace().elements().
                 filter_model_name("a2").filter_time(t).
                 filter_model_name("a2").filter_time(t).
                 filter_type(paradevs::common::DELTA_EXT).size() == 1);
                 filter_type(paradevs::common::DELTA_EXT).size() == 1);
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::pdevs::MyTime >::trace().elements().
                 filter_model_name("a2").filter_time(t).
                 filter_model_name("a2").filter_time(t).
                 filter_type(paradevs::common::DELTA_CONF).size() == 0);
                 filter_type(paradevs::common::DELTA_CONF).size() == 0);
     }
     }
 
 
     for (unsigned int t = 0; t <= 10; ++t) {
     for (unsigned int t = 0; t <= 10; ++t) {
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::pdevs::MyTime >::trace().elements().
                 filter_model_name("b2").filter_time(t).
                 filter_model_name("b2").filter_time(t).
                 filter_type(paradevs::common::LAMBDA).size() == 2);
                 filter_type(paradevs::common::LAMBDA).size() == 2);
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::pdevs::MyTime >::trace().elements().
                 filter_model_name("b2").filter_time(t).
                 filter_model_name("b2").filter_time(t).
                 filter_type(paradevs::common::DELTA_INT).size() == 2);
                 filter_type(paradevs::common::DELTA_INT).size() == 2);
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::pdevs::MyTime >::trace().elements().
                 filter_model_name("b2").filter_time(t).
                 filter_model_name("b2").filter_time(t).
                 filter_type(paradevs::common::TA).size() == 4);
                 filter_type(paradevs::common::TA).size() == 4);
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::pdevs::MyTime >::trace().elements().
                 filter_model_name("b2").filter_time(t).
                 filter_model_name("b2").filter_time(t).
                 filter_type(paradevs::common::DELTA_EXT).size() == 2);
                 filter_type(paradevs::common::DELTA_EXT).size() == 2);
     }
     }
@@ -406,84 +457,106 @@ TEST_CASE("pdevs/flat", "run")
 TEST_CASE("pdevs/hierachical", "run")
 TEST_CASE("pdevs/hierachical", "run")
 {
 {
     paradevs::common::RootCoordinator <
     paradevs::common::RootCoordinator <
-        paradevs::pdevs::Coordinator < paradevs::pdevs::RootGraphManager >
+        paradevs::pdevs::MyTime, paradevs::pdevs::Coordinator <
+            paradevs::pdevs::MyTime, paradevs::pdevs::RootGraphManager >
         > rc(0, 10, "root", paradevs::pdevs::Parameters());
         > rc(0, 10, "root", paradevs::pdevs::Parameters());
 
 
-    paradevs::common::Trace::trace().clear();
+    paradevs::common::Trace < paradevs::pdevs::MyTime >::trace().clear();
     rc.run();
     rc.run();
 
 
-    REQUIRE(paradevs::common::Trace::trace().elements().
+    REQUIRE(paradevs::common::Trace <
+                paradevs::pdevs::MyTime >::trace().elements().
             filter_model_name("a1").
             filter_model_name("a1").
             filter_type(paradevs::common::START).size() == 1);
             filter_type(paradevs::common::START).size() == 1);
-    REQUIRE(paradevs::common::Trace::trace().elements().
+    REQUIRE(paradevs::common::Trace <
+                paradevs::pdevs::MyTime >::trace().elements().
             filter_model_name("b1").
             filter_model_name("b1").
             filter_type(paradevs::common::START).size() == 1);
             filter_type(paradevs::common::START).size() == 1);
-    REQUIRE(paradevs::common::Trace::trace().elements().
+    REQUIRE(paradevs::common::Trace <
+                paradevs::pdevs::MyTime >::trace().elements().
             filter_model_name("a2").
             filter_model_name("a2").
             filter_type(paradevs::common::START).size() == 1);
             filter_type(paradevs::common::START).size() == 1);
-    REQUIRE(paradevs::common::Trace::trace().elements().
+    REQUIRE(paradevs::common::Trace <
+                paradevs::pdevs::MyTime >::trace().elements().
             filter_model_name("b2").
             filter_model_name("b2").
             filter_type(paradevs::common::START).size() == 1);
             filter_type(paradevs::common::START).size() == 1);
 
 
-    REQUIRE(paradevs::common::Trace::trace().elements().
+    REQUIRE(paradevs::common::Trace <
+                paradevs::pdevs::MyTime >::trace().elements().
             filter_model_name("a1").
             filter_model_name("a1").
             filter_type(paradevs::common::DELTA_EXT).size() == 0);
             filter_type(paradevs::common::DELTA_EXT).size() == 0);
     for (unsigned int t = 0; t <= 10; ++t) {
     for (unsigned int t = 0; t <= 10; ++t) {
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::pdevs::MyTime >::trace().elements().
                 filter_model_name("a1").filter_time(t).
                 filter_model_name("a1").filter_time(t).
                 filter_type(paradevs::common::LAMBDA).size() == 1);
                 filter_type(paradevs::common::LAMBDA).size() == 1);
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::pdevs::MyTime >::trace().elements().
                 filter_model_name("a1").filter_time(t).
                 filter_model_name("a1").filter_time(t).
                 filter_type(paradevs::common::DELTA_INT).size() == 1);
                 filter_type(paradevs::common::DELTA_INT).size() == 1);
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::pdevs::MyTime >::trace().elements().
                 filter_model_name("a1").filter_time(t).
                 filter_model_name("a1").filter_time(t).
                 filter_type(paradevs::common::TA).size() == 1);
                 filter_type(paradevs::common::TA).size() == 1);
     }
     }
 
 
     for (unsigned int t = 0; t <= 10; ++t) {
     for (unsigned int t = 0; t <= 10; ++t) {
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::pdevs::MyTime >::trace().elements().
                 filter_model_name("b1").filter_time(t).
                 filter_model_name("b1").filter_time(t).
                 filter_type(paradevs::common::LAMBDA).size() == 1);
                 filter_type(paradevs::common::LAMBDA).size() == 1);
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::pdevs::MyTime >::trace().elements().
                 filter_model_name("b1").filter_time(t).
                 filter_model_name("b1").filter_time(t).
                 filter_type(paradevs::common::DELTA_INT).size() == 1);
                 filter_type(paradevs::common::DELTA_INT).size() == 1);
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::pdevs::MyTime >::trace().elements().
                 filter_model_name("b1").filter_time(t).
                 filter_model_name("b1").filter_time(t).
                 filter_type(paradevs::common::TA).size() == 2);
                 filter_type(paradevs::common::TA).size() == 2);
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::pdevs::MyTime >::trace().elements().
                 filter_model_name("b1").filter_time(t).
                 filter_model_name("b1").filter_time(t).
                 filter_type(paradevs::common::DELTA_EXT).size() == 1);
                 filter_type(paradevs::common::DELTA_EXT).size() == 1);
     }
     }
 
 
     for (unsigned int t = 0; t <= 10; ++t) {
     for (unsigned int t = 0; t <= 10; ++t) {
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::pdevs::MyTime >::trace().elements().
                 filter_model_name("a2").filter_time(t).
                 filter_model_name("a2").filter_time(t).
                 filter_type(paradevs::common::LAMBDA).size() == 2);
                 filter_type(paradevs::common::LAMBDA).size() == 2);
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::pdevs::MyTime >::trace().elements().
                 filter_model_name("a2").filter_time(t).
                 filter_model_name("a2").filter_time(t).
                 filter_type(paradevs::common::DELTA_INT).size() == 2);
                 filter_type(paradevs::common::DELTA_INT).size() == 2);
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::pdevs::MyTime >::trace().elements().
                 filter_model_name("a2").filter_time(t).
                 filter_model_name("a2").filter_time(t).
                 filter_type(paradevs::common::TA).size() == 3);
                 filter_type(paradevs::common::TA).size() == 3);
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::pdevs::MyTime >::trace().elements().
                 filter_model_name("a2").filter_time(t).
                 filter_model_name("a2").filter_time(t).
                 filter_type(paradevs::common::DELTA_EXT).size() == 1);
                 filter_type(paradevs::common::DELTA_EXT).size() == 1);
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::pdevs::MyTime >::trace().elements().
                 filter_model_name("a2").filter_time(t).
                 filter_model_name("a2").filter_time(t).
                 filter_type(paradevs::common::DELTA_CONF).size() == 0);
                 filter_type(paradevs::common::DELTA_CONF).size() == 0);
     }
     }
 
 
     for (unsigned int t = 0; t <= 10; ++t) {
     for (unsigned int t = 0; t <= 10; ++t) {
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::pdevs::MyTime >::trace().elements().
                 filter_model_name("b2").filter_time(t).
                 filter_model_name("b2").filter_time(t).
                 filter_type(paradevs::common::LAMBDA).size() == 2);
                 filter_type(paradevs::common::LAMBDA).size() == 2);
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::pdevs::MyTime >::trace().elements().
                 filter_model_name("b2").filter_time(t).
                 filter_model_name("b2").filter_time(t).
                 filter_type(paradevs::common::DELTA_INT).size() == 2);
                 filter_type(paradevs::common::DELTA_INT).size() == 2);
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::pdevs::MyTime >::trace().elements().
                 filter_model_name("b2").filter_time(t).
                 filter_model_name("b2").filter_time(t).
                 filter_type(paradevs::common::TA).size() == 4);
                 filter_type(paradevs::common::TA).size() == 4);
-        REQUIRE(paradevs::common::Trace::trace().elements().
+        REQUIRE(paradevs::common::Trace <
+                    paradevs::pdevs::MyTime >::trace().elements().
                 filter_model_name("b2").filter_time(t).
                 filter_model_name("b2").filter_time(t).
                 filter_type(paradevs::common::DELTA_EXT).size() == 2);
                 filter_type(paradevs::common::DELTA_EXT).size() == 2);
     }
     }

+ 40 - 20
src/tests/pdevs_tests.hpp

@@ -24,26 +24,44 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
  */
 
 
+#include <common/Time.hpp>
+
 #include <pdevs/Dynamics.hpp>
 #include <pdevs/Dynamics.hpp>
 
 
+#include <limits>
+
 namespace paradevs { namespace pdevs {
 namespace paradevs { namespace pdevs {
 
 
-class A : public Dynamics
+template < typename T >
+struct Limits
+{
+    static constexpr T negative_infinity =
+        -std::numeric_limits < T >::infinity();
+    static constexpr T positive_infinity =
+        std::numeric_limits < T >::infinity();
+    static constexpr T null = 0;
+};
+
+typedef paradevs::common::Time < double, Limits < double > > MyTime;
+
+class A : public Dynamics < MyTime >
 {
 {
 public:
 public:
-    A(const std::string& name) : Dynamics(name)
+    A(const std::string& name) : Dynamics < MyTime >(name)
     { }
     { }
     virtual ~A()
     virtual ~A()
     { }
     { }
 
 
-    virtual void dint(common::Time /* t */);
-    virtual void dext(common::Time /* t */, common::Time /* e */,
-                      const common::Bag& /* msgs */);
-    virtual void dconf(common::Time /* t */, common::Time /* e */,
-                       const common::Bag& /* msgs */);
-    virtual common::Time start(common::Time /* t */);
-    virtual common::Time ta(common::Time /* t */) const;
-    virtual common::Bag lambda(common::Time /* t */) const;
+    virtual void dint(typename MyTime::type /* t */);
+    virtual void dext(typename MyTime::type /* t */,
+                      typename MyTime::type /* e */,
+                      const common::Bag < MyTime >& /* msgs */);
+    virtual void dconf(typename MyTime::type /* t */,
+                       typename MyTime::type /* e */,
+                       const common::Bag < MyTime >& /* msgs */);
+    virtual typename MyTime::type start(typename MyTime::type /* t */);
+    virtual typename MyTime::type ta(typename MyTime::type /* t */) const;
+    virtual common::Bag < MyTime > lambda(typename MyTime::type /* t */) const;
     virtual void observation(std::ostream& /* file */) const;
     virtual void observation(std::ostream& /* file */) const;
 
 
 private:
 private:
@@ -52,22 +70,24 @@ private:
     Phase _phase;
     Phase _phase;
 };
 };
 
 
-class B : public Dynamics
+class B : public Dynamics < MyTime >
 {
 {
 public:
 public:
-    B(const std::string& name) : Dynamics(name)
+    B(const std::string& name) : Dynamics < MyTime >(name)
     { }
     { }
     virtual ~B()
     virtual ~B()
     { }
     { }
 
 
-    virtual void dint(common::Time /* t */);
-    virtual void dext(common::Time /* t */, common::Time /* e */,
-                      const common::Bag& /* msgs */);
-    virtual void dconf(common::Time /* t */, common::Time /* e */,
-                       const common::Bag& /* msgs */);
-    virtual common::Time start(common::Time /* t */);
-    virtual common::Time ta(common::Time /* t */) const;
-    virtual common::Bag lambda(common::Time /* t */) const;
+    virtual void dint(typename MyTime::type /* t */);
+    virtual void dext(typename MyTime::type /* t */,
+                      typename MyTime::type /* e */,
+                      const common::Bag < MyTime >& /* msgs */);
+    virtual void dconf(typename MyTime::type /* t */,
+                       typename MyTime::type /* e */,
+                       const common::Bag < MyTime >& /* msgs */);
+    virtual typename MyTime::type start(typename MyTime::type /* t */);
+    virtual typename MyTime::type ta(typename MyTime::type /* t */) const;
+    virtual common::Bag < MyTime > lambda(typename MyTime::type /* t */) const;
     virtual void observation(std::ostream& /* file */) const;
     virtual void observation(std::ostream& /* file */) const;
 
 
 private:
 private: