Parcourir la source

Remove dependency of HeapScheduler in Model class

Eric Ramat il y a 11 ans
Parent
commit
9cea6af5a1

+ 14 - 15
src/apps/main.cpp

@@ -1,5 +1,5 @@
 /**
 /**
- * @file main.cpp
+ * @file app/main.cpp
  * @author The PARADEVS Development Team
  * @author The PARADEVS Development Team
  * See the AUTHORS or Authors.txt file
  * See the AUTHORS or Authors.txt file
  */
  */
@@ -47,10 +47,10 @@ void run_flat_with_heap()
     paradevs::common::RootCoordinator <
     paradevs::common::RootCoordinator <
         MyTime, paradevs::pdevs::Coordinator <
         MyTime, paradevs::pdevs::Coordinator <
             MyTime,
             MyTime,
-            paradevs::common::scheduler::HeapScheduler < MyTime >,
-            LinearGraphManager < size >,
-            paradevs::common::NoParameters,
-            paradevs::common::NoParameters >
+            paradevs::common::scheduler::HeapScheduler < MyTime,
+                                                         SchedulerHandle >,
+            SchedulerHandle,
+            LinearGraphManager < size, SchedulerHandle > >
         > rc(0, 100, "root", paradevs::common::NoParameters(),
         > rc(0, 100, "root", paradevs::common::NoParameters(),
              paradevs::common::NoParameters());
              paradevs::common::NoParameters());
 
 
@@ -71,9 +71,9 @@ void run_flat_with_vector()
         MyTime, paradevs::pdevs::Coordinator <
         MyTime, paradevs::pdevs::Coordinator <
             MyTime,
             MyTime,
             paradevs::common::scheduler::VectorScheduler < MyTime >,
             paradevs::common::scheduler::VectorScheduler < MyTime >,
-            LinearGraphManager < size >,
-            paradevs::common::NoParameters,
-            paradevs::common::NoParameters >
+            paradevs::common::scheduler::NoSchedulerHandle,
+            LinearGraphManager <
+                size, paradevs::common::scheduler::NoSchedulerHandle > >
         > rc(0, 100, "root", paradevs::common::NoParameters(),
         > rc(0, 100, "root", paradevs::common::NoParameters(),
              paradevs::common::NoParameters());
              paradevs::common::NoParameters());
 
 
@@ -88,10 +88,10 @@ void run_hierarchic_with_heap()
     paradevs::common::RootCoordinator <
     paradevs::common::RootCoordinator <
         MyTime, paradevs::pdevs::Coordinator <
         MyTime, paradevs::pdevs::Coordinator <
             MyTime,
             MyTime,
-            paradevs::common::scheduler::HeapScheduler < MyTime >,
-            Root2GraphManager,
-            paradevs::common::NoParameters,
-            paradevs::common::NoParameters >
+            paradevs::common::scheduler::HeapScheduler < MyTime,
+                                                         SchedulerHandle >,
+            SchedulerHandle,
+            Root2GraphManager >
         > rc(0, 100, "root", paradevs::common::NoParameters(),
         > rc(0, 100, "root", paradevs::common::NoParameters(),
              paradevs::common::NoParameters());
              paradevs::common::NoParameters());
 
 
@@ -105,9 +105,8 @@ void run_hierarchic_with_vector()
         MyTime, paradevs::pdevs::Coordinator <
         MyTime, paradevs::pdevs::Coordinator <
             MyTime,
             MyTime,
             paradevs::common::scheduler::VectorScheduler < MyTime >,
             paradevs::common::scheduler::VectorScheduler < MyTime >,
-            Root3GraphManager,
-            paradevs::common::NoParameters,
-            paradevs::common::NoParameters >
+            paradevs::common::scheduler::NoSchedulerHandle,
+            Root3GraphManager >
         > rc(0, 100, "root", paradevs::common::NoParameters(),
         > rc(0, 100, "root", paradevs::common::NoParameters(),
              paradevs::common::NoParameters());
              paradevs::common::NoParameters());
 
 

+ 6 - 5
src/common/Bag.hpp

@@ -35,11 +35,11 @@
 
 
 namespace paradevs { namespace common {
 namespace paradevs { namespace common {
 
 
-template < class Time >
+template < class Time, class SchedulerHandle >
 class ExternalEvent;
 class ExternalEvent;
 
 
-template < class Time >
-class Bag : public std::vector < ExternalEvent < Time > >
+template < class Time, class SchedulerHandle >
+class Bag : public std::vector < ExternalEvent < Time, SchedulerHandle > >
 {
 {
 public:
 public:
     Bag()
     Bag()
@@ -52,8 +52,9 @@ public:
         std::ostringstream ss;
         std::ostringstream ss;
 
 
         ss << "{ ";
         ss << "{ ";
-        for (typename Bag < Time >::const_iterator it = Bag < Time >::begin();
-             it != Bag < Time >::end(); ++it) {
+        for (typename Bag < Time, SchedulerHandle >::const_iterator it =
+                 Bag < Time, SchedulerHandle >::begin();
+             it != Bag < Time, SchedulerHandle >::end(); ++it) {
             ss << it->to_string() << " ";
             ss << it->to_string() << " ";
         }
         }
         ss << "}";
         ss << "}";

+ 10 - 6
src/common/Coordinator.hpp

@@ -37,14 +37,14 @@
 
 
 namespace paradevs { namespace common {
 namespace paradevs { namespace common {
 
 
-template < class Time >
+template < class Time, class SchedulerHandle >
 class Model;
 class Model;
 
 
-template < class Time >
-class Coordinator : public Model < Time >
+template < class Time, class SchedulerHandle >
+class Coordinator : public Model < Time, SchedulerHandle >
 {
 {
 public :
 public :
-    Coordinator(const std::string& name) : Model < Time >(name)
+    Coordinator(const std::string& name) : Model < Time, SchedulerHandle >(name)
     { }
     { }
 
 
     virtual ~Coordinator()
     virtual ~Coordinator()
@@ -54,8 +54,12 @@ public :
     virtual void observation(std::ostream& file) const =0;
     virtual void observation(std::ostream& file) const =0;
     virtual void output(typename Time::type t) =0;
     virtual void output(typename Time::type t) =0;
     virtual void post_event(typename Time::type t,
     virtual void post_event(typename Time::type t,
-                            const common::ExternalEvent < Time >& event) =0;
-    virtual typename Time::type dispatch_events(common::Bag < Time > bag,
+                            const common::ExternalEvent < Time,
+                                                          SchedulerHandle >&
+                            event) =0;
+    virtual typename Time::type dispatch_events(common::Bag < Time,
+                                                              SchedulerHandle >
+                                                bag,
                                                 typename Time::type t) =0;
                                                 typename Time::type t) =0;
     virtual typename Time::type start(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;
     virtual typename Time::type transition(typename Time::type t) =0;

+ 11 - 10
src/common/ExternalEvent.hpp

@@ -36,12 +36,12 @@
 
 
 namespace paradevs { namespace common {
 namespace paradevs { namespace common {
 
 
-template < class Time >
+template < class Time, class SchedulerHandle >
 class Node;
 class Node;
-template < class Time >
+template < class Time, class SchedulerHandle >
 class Model;
 class Model;
 
 
-template < class Time >
+template < class Time, class SchedulerHandle >
 class ExternalEvent
 class ExternalEvent
 {
 {
 public:
 public:
@@ -49,8 +49,9 @@ public:
         _port_name(port_name), _model(0), _content(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()),
+    ExternalEvent(const Node < Time, SchedulerHandle >& node, double content) :
+        _port_name(node.get_port_name()),
+        _model(node.get_model()),
         _content(content)
         _content(content)
     { }
     { }
 
 
@@ -69,13 +70,13 @@ public:
     void set_content(double content)
     void set_content(double content)
     { _content = content; }
     { _content = content; }
 
 
-    Model < Time >* get_model() const
+    Model < Time, SchedulerHandle >* get_model() const
     { return _model; }
     { return _model; }
 
 
     bool on_port(const std::string& port_name) const
     bool on_port(const std::string& port_name) const
     { return _port_name == port_name; }
     { return _port_name == port_name; }
 
 
-    void set_model(Model < Time >* model)
+    void set_model(Model < Time, SchedulerHandle >* model)
     { _model = model; }
     { _model = model; }
 
 
     std::string to_string() const
     std::string to_string() const
@@ -88,9 +89,9 @@ public:
     }
     }
 
 
 private :
 private :
-    std::string     _port_name;
-    Model < Time >* _model;
-    double          _content;
+    std::string                      _port_name;
+    Model < Time, SchedulerHandle >* _model;
+    double                           _content;
 };
 };
 
 
 } } // namespace paradevs common
 } } // namespace paradevs common

+ 8 - 7
src/common/InternalEvent.hpp

@@ -33,21 +33,22 @@
 
 
 namespace paradevs { namespace common {
 namespace paradevs { namespace common {
 
 
-template < class Time >
+template < class Time, class SchedulerHandle >
 class Model;
 class Model;
 
 
-template < class Time >
-struct InternalEvent
+template < class Time, class SchedulerHandle >
+class InternalEvent
 {
 {
 public:
 public:
-    InternalEvent(const typename Time::type& time, Model < Time >* model)
+    InternalEvent(const typename Time::type& time,
+                  Model < Time, SchedulerHandle >* model)
         : _time(time), _model(model)
         : _time(time), _model(model)
     { }
     { }
 
 
     virtual ~InternalEvent()
     virtual ~InternalEvent()
     { }
     { }
 
 
-    Model < Time >* get_model() const
+    Model < Time, SchedulerHandle >* get_model() const
     { return _model; }
     { return _model; }
 
 
     typename Time::type get_time() const
     typename Time::type get_time() const
@@ -77,8 +78,8 @@ public:
     { _time = time; }
     { _time = time; }
 
 
 private:
 private:
-    typename Time::type _time;
-    Model < Time >*     _model;
+    typename Time::type              _time;
+    Model < Time, SchedulerHandle >* _model;
 };
 };
 
 
 template < typename Event >
 template < typename Event >

+ 27 - 16
src/common/Links.hpp

@@ -34,36 +34,46 @@
 
 
 namespace paradevs { namespace common {
 namespace paradevs { namespace common {
 
 
-template < class Time >
+template < class Time, class SchedulerHandle >
 class Node;
 class Node;
 
 
-template < class Time >
-class Links : public std::multimap < Node < Time >, Node < Time > >
+template < class Time, class SchedulerHandle >
+class Links : public std::multimap < Node < Time, SchedulerHandle >,
+                                     Node < Time, SchedulerHandle > >
 {
 {
 public:
 public:
 
 
-    typedef std::pair < typename Links < Time >::const_iterator,
-                        typename Links < Time >::const_iterator > Result;
+    typedef std::pair <
+    typename Links < Time, SchedulerHandle >::const_iterator,
+    typename Links < Time, SchedulerHandle >::const_iterator > Result;
 
 
     Links()
     Links()
     { }
     { }
     virtual ~Links()
     virtual ~Links()
     { }
     { }
 
 
-    void add(Model < Time >* out_model, const std::string& out_port_name,
-             Model < Time >* in_model, const std::string& in_port_name)
+    void add(Model < Time, SchedulerHandle >* out_model,
+             const std::string& out_port_name,
+             Model < Time, SchedulerHandle >* 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)));
+        std::multimap < Node < Time, SchedulerHandle >,
+                        Node < Time, SchedulerHandle > >::insert(
+                            std::pair < Node < Time, SchedulerHandle >,
+                                        Node < Time, SchedulerHandle > >(
+                                            Node < Time, SchedulerHandle >(
+                                                out_model, out_port_name),
+                                            Node < Time, SchedulerHandle >(
+                                                in_model, in_port_name)));
     }
     }
 
 
-    Links::Result find(Model < Time >* out_model,
+    Links::Result find(Model < Time, SchedulerHandle >* out_model,
                        const std::string& out_port_name) const
                        const std::string& out_port_name) const
     {
     {
-        return std::multimap < Node < Time >, Node < Time > >::equal_range(
-            common::Node < Time >(out_model, out_port_name));
+        return std::multimap < Node < Time, SchedulerHandle >,
+                               Node < Time, SchedulerHandle > >::equal_range(
+                                   common::Node < Time, SchedulerHandle >(
+                                       out_model, out_port_name));
     }
     }
 
 
     std::string to_string() const
     std::string to_string() const
@@ -71,8 +81,9 @@ public:
         std::stringstream ss;
         std::stringstream ss;
 
 
         ss << "Graph = { ";
         ss << "Graph = { ";
-        for (typename Node < Time >::const_iterator it = Node < Time >::begin();
-             it != Node < Time >::end(); ++it) {
+        for (typename Node < Time, SchedulerHandle >::const_iterator it =
+                 Node < Time, SchedulerHandle >::begin();
+             it != Node < Time, SchedulerHandle >::end(); ++it) {
             ss << "(" << it->first.get_model()->get_name() << ":"
             ss << "(" << it->first.get_model()->get_name() << ":"
                << it->first.get_port_name()
                << it->first.get_port_name()
                << " -> "
                << " -> "

+ 33 - 43
src/common/Model.hpp

@@ -31,30 +31,27 @@
 #include <common/ExternalEvent.hpp>
 #include <common/ExternalEvent.hpp>
 #include <common/InternalEvent.hpp>
 #include <common/InternalEvent.hpp>
 
 
-#include <boost/heap/fibonacci_heap.hpp>
-
+#include <algorithm>
+#include <cassert>
 #include <iostream>
 #include <iostream>
 #include <sstream>
 #include <sstream>
 #include <vector>
 #include <vector>
 
 
 namespace paradevs { namespace common {
 namespace paradevs { namespace common {
 
 
-template < class Time >
-struct EventCompare;
-
-template < class Time >
+template < class Time, class SchedulerHandle >
 class ExternalEvent;
 class ExternalEvent;
 
 
-template < class Time >
+template < class Time, class SchedulerHandle >
 class InternalEvent;
 class InternalEvent;
 
 
-template < class Time >
+template < class Tim, class SchedulerHandlee >
 class Bag;
 class Bag;
 
 
 typedef std::string Port;
 typedef std::string Port;
 typedef std::vector < Port > Ports;
 typedef std::vector < Port > Ports;
 
 
-template < class Time >
+template < class Time, class SchedulerHandle >
 class Model
 class Model
 {
 {
 public:
 public:
@@ -115,26 +112,27 @@ public:
     const std::string& get_name() const
     const std::string& get_name() const
     { return _name; }
     { return _name; }
 
 
-    Model < Time >* get_parent() const
+    Model < Time, SchedulerHandle >* get_parent() const
     { return _parent; }
     { return _parent; }
 
 
 
 
-    void set_parent(Model < Time >* parent)
+    void set_parent(Model < Time, SchedulerHandle >* parent)
     { _parent = parent; }
     { _parent = parent; }
 
 
     // event
     // event
-    void add_event(const common::ExternalEvent < Time >& message)
+    void add_event(const common::ExternalEvent < Time, SchedulerHandle >&
+                   message)
     {
     {
         if (_inputs == 0) {
         if (_inputs == 0) {
-            _inputs = new Bag < Time >;
+            _inputs = new Bag < Time, SchedulerHandle >;
         }
         }
         _inputs->push_back(message);
         _inputs->push_back(message);
     }
     }
 
 
-    const common::Bag < Time >& get_bag()
+    const common::Bag < Time, SchedulerHandle >& get_bag()
     {
     {
         if (_inputs == 0) {
         if (_inputs == 0) {
-            _inputs = new Bag < Time>;
+            _inputs = new Bag < Time, SchedulerHandle >;
         }
         }
         return *_inputs;
         return *_inputs;
     }
     }
@@ -167,44 +165,35 @@ public:
     virtual void observation(std::ostream& file) const =0;
     virtual void observation(std::ostream& file) const =0;
     virtual void output(typename Time::type t) =0;
     virtual void output(typename Time::type t) =0;
     virtual void post_event(typename Time::type t,
     virtual void post_event(typename Time::type t,
-                            const common::ExternalEvent < Time >& event) = 0;
+                            const common::ExternalEvent < Time,
+                                                          SchedulerHandle >&
+                            event) = 0;
     virtual typename Time::type start(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;
     virtual typename Time::type transition(typename Time::type t) =0;
 
 
-    void heap_id(typename boost::heap::fibonacci_heap <
-                     InternalEvent < Time >,
-                     boost::heap::compare <
-                         EventCompare < InternalEvent <
-                             Time > > > >::handle_type id)
-    { _heap_id = id; }
+    // scheduler
+    void handle(SchedulerHandle handle)
+    { _handle.handle(handle); }
 
 
-    const typename boost::heap::fibonacci_heap <
-        InternalEvent < Time >,
-        boost::heap::compare <
-            EventCompare < InternalEvent <
-                               Time > > > >::handle_type& heap_id() const
-                               { return _heap_id; }
+    const SchedulerHandle& handle() const
+    { return _handle.handle(); }
 
 
 protected:
 protected:
     typename Time::type _tl;
     typename Time::type _tl;
     typename Time::type _tn;
     typename Time::type _tn;
 
 
 private :
 private :
-    Model < Time >*     _parent;
-    std::string         _name;
-    Ports               _in_ports;
-    Ports               _out_ports;
-
-    Bag < Time >*       _inputs;
-    typename boost::heap::fibonacci_heap <
-        InternalEvent < Time >,
-        boost::heap::compare <
-            EventCompare < InternalEvent <
-                               Time > > > >::handle_type _heap_id;
+    Model < Time, SchedulerHandle >* _parent;
+    std::string                      _name;
+    Ports                            _in_ports;
+    Ports                            _out_ports;
+
+    Bag < Time, SchedulerHandle >*   _inputs;
+    SchedulerHandle                  _handle;
 };
 };
 
 
-template < class Time >
-class Models : public std::vector < Model < Time >* >
+template < class Time, class SchedulerHandle >
+class Models : public std::vector < Model < Time, SchedulerHandle >* >
 {
 {
 public:
 public:
     Models()
     Models()
@@ -217,8 +206,9 @@ public:
         std::ostringstream ss;
         std::ostringstream ss;
 
 
         ss << "{ ";
         ss << "{ ";
-        for (typename Models < Time >::const_iterator it =
-                 Models < Time >::begin(); it != Models < Time >::end(); ++it) {
+        for (typename Models < Time, SchedulerHandle >::const_iterator it =
+                 Models < Time, SchedulerHandle >::begin();
+             it != Models < Time, SchedulerHandle >::end(); ++it) {
             ss << (*it)->get_name() << " ";
             ss << (*it)->get_name() << " ";
         }
         }
         ss << "}";
         ss << "}";

+ 8 - 8
src/common/Node.hpp

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

+ 6 - 4
src/common/Simulator.hpp

@@ -31,11 +31,11 @@
 
 
 namespace paradevs { namespace common {
 namespace paradevs { namespace common {
 
 
-template < class Time >
-class Simulator : public Model < Time >
+template < class Time, class SchedulerHandle >
+class Simulator : public Model < Time, SchedulerHandle >
 {
 {
 public :
 public :
-    Simulator(const std::string& name) : Model < Time >(name)
+    Simulator(const std::string& name) : Model < Time, SchedulerHandle >(name)
     { }
     { }
     virtual ~Simulator()
     virtual ~Simulator()
     { }
     { }
@@ -43,7 +43,9 @@ public :
     virtual void observation(std::ostream& file) const =0;
     virtual void observation(std::ostream& file) const =0;
     virtual void output(typename Time::type t) =0;
     virtual void output(typename Time::type t) =0;
     virtual void post_event(typename Time::type t,
     virtual void post_event(typename Time::type t,
-                            const common::ExternalEvent < Time >& event) = 0;
+                            const common::ExternalEvent < Time,
+                                                          SchedulerHandle >&
+                            event) = 0;
     virtual typename Time::type start(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;
     virtual typename Time::type transition(typename Time::type t) =0;
 };
 };

+ 2 - 1
src/common/scheduler/CMakeLists.txt

@@ -10,7 +10,8 @@ LINK_DIRECTORIES(
   ${LIBXML_LIBRARY_DIR}
   ${LIBXML_LIBRARY_DIR}
   ${Boost_LIBRARY_DIRS})
   ${Boost_LIBRARY_DIRS})
 
 
-SET(COMMON_SCHEDULER_HPP HeapScheduler.hpp VectorScheduler.hpp)
+SET(COMMON_SCHEDULER_HPP HeapScheduler.hpp SchedulerHandle.hpp
+  VectorScheduler.hpp)
 
 
 INSTALL(FILES ${COMMON_SCHEDULER_HPP} DESTINATION
 INSTALL(FILES ${COMMON_SCHEDULER_HPP} DESTINATION
   ${PARADEVS_INCLUDE_DIRS}/common/scheduler)
   ${PARADEVS_INCLUDE_DIRS}/common/scheduler)

+ 28 - 42
src/common/scheduler/HeapScheduler.hpp

@@ -30,52 +30,40 @@
 #include <common/InternalEvent.hpp>
 #include <common/InternalEvent.hpp>
 
 
 #include <boost/heap/fibonacci_heap.hpp>
 #include <boost/heap/fibonacci_heap.hpp>
-#include <boost/heap/binomial_heap.hpp>
 
 
-#include <cmath>
 #include <sstream>
 #include <sstream>
 
 
 namespace paradevs { namespace common { namespace scheduler {
 namespace paradevs { namespace common { namespace scheduler {
 
 
-template < typename Time >
-struct Heap
+template < class Time, class T >
+class HeapScheduler :
+        public boost::heap::fibonacci_heap <
+    InternalEvent < Time, T >,
+    boost::heap::compare <
+        EventCompare < InternalEvent < Time, T > > > >
 {
 {
-    typedef boost::heap::fibonacci_heap <
-        InternalEvent < Time >, boost::heap::compare <
-                       EventCompare < InternalEvent < Time > > > > Type;
-
-    typedef typename boost::heap::fibonacci_heap <
-        InternalEvent < Time >, boost::heap::compare <
-                       EventCompare < InternalEvent <
-                                          Time > > > >::handle_type Handle;
-};
-
-template < class Time >
-class HeapScheduler
-{
-    typedef boost::heap::fibonacci_heap < InternalEvent < Time >,
-                                          boost::heap::compare <
-                                              EventCompare <
-                                                  InternalEvent < Time > > >
-                                          > Heap;
-
 public:
 public:
+    typedef HeapScheduler < Time, T > type;
+    typedef Model < Time, T >         model_type;
+    typedef Models < Time, T >        models_type;
+    typedef InternalEvent < Time, T > internal_event_type;
+
     HeapScheduler()
     HeapScheduler()
     { }
     { }
     virtual ~HeapScheduler()
     virtual ~HeapScheduler()
     { }
     { }
 
 
-    Model < Time >* get_current_model()
+    model_type* get_current_model()
     {
     {
-        return _heap.top().get_model();
+        return type::top().get_model();
     }
     }
 
 
-    Models < Time > get_current_models(typename Time::type time) const
+    models_type get_current_models(typename Time::type time) const
     {
     {
-        Models < Time > models;
+        models_type models;
 
 
-        for (typename Heap::ordered_iterator it = _heap.ordered_begin();
-             it != _heap.ordered_end() and it->get_time() == time; ++it) {
+        for (typename type::ordered_iterator it = type::ordered_begin();
+             it != type::ordered_end() and it->get_time() == time; ++it) {
             models.push_back(it->get_model());
             models.push_back(it->get_model());
         }
         }
         return models;
         return models;
@@ -83,23 +71,24 @@ public:
 
 
     typename Time::type get_current_time() const
     typename Time::type get_current_time() const
     {
     {
-        return _heap.top().get_time();
+        return type::top().get_time();
     }
     }
 
 
-    void init(typename Time::type time, Model < Time >* model)
+    void init(typename Time::type time, model_type* model)
     {
     {
-        model->heap_id(_heap.push(InternalEvent < Time >(time, model)));
+        model->handle(T(type::push(internal_event_type(time, model))));
     }
     }
 
 
-    void put(typename Time::type time, Model < Time >* model)
+    void put(typename Time::type time, model_type* model)
     {
     {
-        typename Time::type previous_time = (*model->heap_id()).get_time();
+        typename Time::type previous_time =
+            (*model->handle()._handle).get_time();
 
 
-        (*model->heap_id()).set_time(time);
+        (*model->handle()._handle).set_time(time);
         if (previous_time < time) {
         if (previous_time < time) {
-            _heap.decrease(model->heap_id());
+            type::decrease(model->handle()._handle);
         } else if (previous_time > time) {
         } else if (previous_time > time) {
-            _heap.increase(model->heap_id());
+            type::increase(model->handle()._handle);
         }
         }
     }
     }
 
 
@@ -108,17 +97,14 @@ public:
         std::stringstream ss;
         std::stringstream ss;
 
 
         ss << "Scheduler = { ";
         ss << "Scheduler = { ";
-        for (typename Heap::ordered_iterator it = _heap.ordered_begin();
-             it != _heap.ordered_end(); ++it) {
+        for (typename type::ordered_iterator it = type::ordered_begin();
+             it != type::ordered_end(); ++it) {
             ss << "(" << it->get_time() << " -> " << it->get_model()->get_name()
             ss << "(" << it->get_time() << " -> " << it->get_model()->get_name()
                << ") ";
                << ") ";
         }
         }
         ss << "}";
         ss << "}";
         return ss.str();
         return ss.str();
     }
     }
-
-private:
-    Heap _heap;
 };
 };
 
 
 } } } // namespace paradevs common scheduler
 } } } // namespace paradevs common scheduler

+ 46 - 0
src/common/scheduler/SchedulerHandle.hpp

@@ -0,0 +1,46 @@
+/**
+ * @file SchedulerHandle.hpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef COMMON_SCHEDULER_SCHEDULER_HAMDLE_HPP
+#define COMMON_SCHEDULER_SCHEDULER_HANDLE_HPP 1
+
+namespace paradevs { namespace common { namespace scheduler {
+
+struct NoSchedulerHandle
+{
+    NoSchedulerHandle()
+    { }
+
+    const NoSchedulerHandle& handle() const
+    { return *this; }
+
+    void handle(const NoSchedulerHandle& /* handle */)
+    { }
+};
+
+} } } // namespace paradevs common scheduler
+
+#endif

+ 14 - 9
src/common/scheduler/VectorScheduler.hpp

@@ -29,13 +29,16 @@
 
 
 #include <common/InternalEvent.hpp>
 #include <common/InternalEvent.hpp>
 
 
+#include <common/scheduler/SchedulerHandle.hpp>
+
 #include <algorithm>
 #include <algorithm>
 #include <sstream>
 #include <sstream>
 
 
 namespace paradevs { namespace common { namespace scheduler {
 namespace paradevs { namespace common { namespace scheduler {
 
 
 template < class Time >
 template < class Time >
-class VectorScheduler : protected std::vector < InternalEvent < Time > >
+class VectorScheduler :
+        protected std::vector < InternalEvent < Time, NoSchedulerHandle > >
 {
 {
 public:
 public:
     VectorScheduler()
     VectorScheduler()
@@ -43,14 +46,15 @@ public:
     virtual ~VectorScheduler()
     virtual ~VectorScheduler()
     { }
     { }
 
 
-    Model < Time >* get_current_model()
+    Model < Time, NoSchedulerHandle >* get_current_model()
     {
     {
         return VectorScheduler < Time >::front().get_model();
         return VectorScheduler < Time >::front().get_model();
     }
     }
 
 
-    Models < Time > get_current_models(typename Time::type time) const
+    Models < Time, NoSchedulerHandle > get_current_models(
+        typename Time::type time) const
     {
     {
-        Models < Time > models;
+        Models < Time, NoSchedulerHandle > models;
 
 
         for (typename VectorScheduler < Time >::const_iterator it =
         for (typename VectorScheduler < Time >::const_iterator it =
                  VectorScheduler < Time >::begin();
                  VectorScheduler < Time >::begin();
@@ -64,19 +68,20 @@ public:
     typename Time::type get_current_time() const
     typename Time::type get_current_time() const
     { return VectorScheduler < Time >::front().get_time(); }
     { return VectorScheduler < Time >::front().get_time(); }
 
 
-    void init(typename Time::type time, Model < Time >* model)
+    void init(typename Time::type time,
+              Model < Time, NoSchedulerHandle >* model)
     {
     {
         VectorScheduler < Time >::push_back(
         VectorScheduler < Time >::push_back(
-            InternalEvent < Time >(time, model));
+            InternalEvent < Time, NoSchedulerHandle >(time, model));
         std::sort(VectorScheduler < Time >::begin(),
         std::sort(VectorScheduler < Time >::begin(),
                   VectorScheduler < Time >::end());
                   VectorScheduler < Time >::end());
     }
     }
 
 
-    void put(typename Time::type time, Model < Time >* model)
+    void put(typename Time::type time, Model < Time, NoSchedulerHandle >* model)
     {
     {
         remove(model);
         remove(model);
         VectorScheduler < Time >::push_back(
         VectorScheduler < Time >::push_back(
-            InternalEvent < Time >(time, model));
+            InternalEvent < Time, NoSchedulerHandle >(time, model));
         std::sort(VectorScheduler < Time >::begin(),
         std::sort(VectorScheduler < Time >::begin(),
                   VectorScheduler < Time >::end());
                   VectorScheduler < Time >::end());
     }
     }
@@ -97,7 +102,7 @@ public:
     }
     }
 
 
 private:
 private:
-    void remove(Model < Time >* model)
+    void remove(Model < Time, NoSchedulerHandle >* model)
     {
     {
         typename VectorScheduler < Time >::iterator jt =
         typename VectorScheduler < Time >::iterator jt =
             VectorScheduler < Time >::begin();
             VectorScheduler < Time >::begin();

+ 9 - 7
src/dtss/Coordinator.hpp

@@ -47,12 +47,12 @@ public:
 };
 };
 
 
 template < class Time, class Policy, class GraphManager,
 template < class Time, class Policy, class GraphManager,
-           class Parameters = Parameters < Time >,
+           class SchedulerHandle, class Parameters = Parameters < Time >,
            class GraphParameters = common::NoParameters >
            class GraphParameters = common::NoParameters >
-class Coordinator : public common::Coordinator < Time >
+class Coordinator : public common::Coordinator < Time, SchedulerHandle >
 {
 {
-    typedef Coordinator < Time, Policy, GraphManager, Parameters,
-                          GraphParameters > type;
+    typedef Coordinator < Time, Policy, GraphManager, SchedulerHandle,
+                          Parameters, GraphParameters > type;
 
 
 public:
 public:
     typedef Parameters parameters_type;
     typedef Parameters parameters_type;
@@ -61,7 +61,7 @@ public:
     Coordinator(const std::string& name,
     Coordinator(const std::string& name,
                 const Parameters& parameters,
                 const Parameters& parameters,
                 const GraphParameters& graph_paramaters) :
                 const GraphParameters& graph_paramaters) :
-        common::Coordinator < Time >(name),
+        common::Coordinator < Time, SchedulerHandle >(name),
         _graph_manager(this, graph_paramaters),
         _graph_manager(this, graph_paramaters),
         _time_step(parameters._time_step)
         _time_step(parameters._time_step)
     { }
     { }
@@ -101,7 +101,8 @@ public:
         return type::_tn;
         return type::_tn;
     }
     }
 
 
-    typename Time::type dispatch_events(common::Bag < Time > bag,
+    typename Time::type dispatch_events(common::Bag < Time,
+                                                      SchedulerHandle > bag,
                                         typename Time::type t)
                                         typename Time::type t)
     {
     {
 
 
@@ -164,7 +165,8 @@ public:
     }
     }
 
 
     void post_event(typename Time::type t,
     void post_event(typename Time::type t,
-                    const common::ExternalEvent < Time >& event)
+                    const common::ExternalEvent < Time,
+                                                  SchedulerHandle >& event)
     {
     {
 
 
 #ifdef WITH_TRACE
 #ifdef WITH_TRACE

+ 8 - 8
src/dtss/Dynamics.hpp

@@ -31,13 +31,11 @@
 #include <common/ExternalEvent.hpp>
 #include <common/ExternalEvent.hpp>
 #include <common/Parameters.hpp>
 #include <common/Parameters.hpp>
 
 
-#include <limits>
-#include <string>
-#include <vector>
-
 namespace paradevs { namespace dtss {
 namespace paradevs { namespace dtss {
 
 
-template < class Time, class Parameters = common::NoParameters >
+template < class Time,
+           class SchedulerHandle = common::scheduler::NoSchedulerHandle,
+           class Parameters = common::NoParameters >
 class Dynamics
 class Dynamics
 {
 {
 public:
 public:
@@ -48,15 +46,17 @@ public:
     virtual ~Dynamics()
     virtual ~Dynamics()
     { }
     { }
 
 
-    virtual void transition(const common::Bag < Time >& /* x */,
+    virtual void transition(const common::Bag < Time,
+                                                SchedulerHandle >& /* x */,
                             typename Time::type /* t */)
                             typename Time::type /* t */)
     { }
     { }
 
 
     virtual typename Time::type start(typename Time::type/* time */)
     virtual typename Time::type start(typename Time::type/* time */)
     { return Time::infinity; }
     { return Time::infinity; }
 
 
-    common::Bag < Time > lambda(typename Time::type /* time */) const
-    { return common::Bag < Time >(); }
+    common::Bag < Time, SchedulerHandle > lambda(
+        typename Time::type /* time */) const
+    { return common::Bag < Time, SchedulerHandle >(); }
 
 
     virtual void observation(std::ostream& /* file */) const
     virtual void observation(std::ostream& /* file */) const
     { }
     { }

+ 36 - 24
src/dtss/GraphManager.hpp

@@ -34,11 +34,14 @@
 
 
 namespace paradevs { namespace dtss {
 namespace paradevs { namespace dtss {
 
 
-template < class Time, class GraphParameters = common::NoParameters >
+template < class Time,
+           class SchedulerHandle =
+               paradevs::common::scheduler::NoSchedulerHandle,
+           class GraphParameters = common::NoParameters >
 class GraphManager
 class GraphManager
 {
 {
 public:
 public:
-    GraphManager(common::Coordinator < Time >* coordinator,
+    GraphManager(common::Coordinator < Time, SchedulerHandle >* coordinator,
                  const GraphParameters& /* parameters */) :
                  const GraphParameters& /* parameters */) :
         _coordinator(coordinator)
         _coordinator(coordinator)
     { }
     { }
@@ -46,15 +49,15 @@ public:
     virtual ~GraphManager()
     virtual ~GraphManager()
     { }
     { }
 
 
-    void add_child(common::Model < Time >* child)
+    void add_child(common::Model < Time, SchedulerHandle >* child)
     {
     {
         _child_list.push_back(child);
         _child_list.push_back(child);
         child->set_parent(_coordinator);
         child->set_parent(_coordinator);
     }
     }
 
 
-    void add_link(common::Model < Time >* src_model,
+    void add_link(common::Model < Time, SchedulerHandle >* src_model,
                   const std::string& src_port_name,
                   const std::string& src_port_name,
-                  common::Model < Time >* dst_model,
+                  common::Model < Time, SchedulerHandle >* dst_model,
                   const std::string& dst_port_name)
                   const std::string& dst_port_name)
     {
     {
         assert((src_model != _coordinator and
         assert((src_model != _coordinator and
@@ -73,55 +76,64 @@ public:
         _link_list.add(src_model, src_port_name, dst_model, dst_port_name);
         _link_list.add(src_model, src_port_name, dst_model, dst_port_name);
     }
     }
 
 
-    const common::Models < Time >& children() const
+    const common::Models < Time, SchedulerHandle >& children() const
     { return _child_list; }
     { return _child_list; }
 
 
-    void dispatch_events(common::Bag < Time > bag, typename Time::type t)
+    void dispatch_events(common::Bag < Time, SchedulerHandle > bag,
+                         typename Time::type t)
     {
     {
         for (auto & ymsg : bag) {
         for (auto & ymsg : bag) {
-            typename common::Links < Time >::Result result_model =
+            typename common::Links < Time,
+                                     SchedulerHandle >::Result result_model =
                 _link_list.find(ymsg.get_model(),
                 _link_list.find(ymsg.get_model(),
                                 ymsg.get_port_name());
                                 ymsg.get_port_name());
 
 
-            for (typename common::Links < Time >::const_iterator it =
+            for (typename common::Links < Time,
+                                          SchedulerHandle >::const_iterator it =
                      result_model.first; it != result_model.second; ++it) {
                      result_model.first; it != result_model.second; ++it) {
                 // event on output port of coupled model
                 // event on output port of coupled model
                 if (it->second.get_model() == _coordinator) {
                 if (it->second.get_model() == _coordinator) {
-                    common::Bag < Time > ymessages;
+                    common::Bag < Time, SchedulerHandle > ymessages;
 
 
                     ymessages.push_back(
                     ymessages.push_back(
-                        common::ExternalEvent < Time >(it->second,
-                                                       ymsg.get_content()));
-                    dynamic_cast < common::Coordinator < Time >* >(
-                        _coordinator->get_parent())->dispatch_events(ymessages,
-                                                                     t);
+                        common::ExternalEvent < Time,
+                                                SchedulerHandle >(
+                                                    it->second,
+                                                    ymsg.get_content()));
+                    dynamic_cast < common::Coordinator <
+                        Time, SchedulerHandle >* >(_coordinator->get_parent())
+                        ->dispatch_events(ymessages, t);
                 } else { // event on input port of internal model
                 } else { // event on input port of internal model
                     it->second.get_model()->post_event(
                     it->second.get_model()->post_event(
-                        t, common::ExternalEvent < Time >(it->second,
-                                                 ymsg.get_content()));
+                        t, common::ExternalEvent < Time,
+                                                   SchedulerHandle >(
+                                                       it->second,
+                                                       ymsg.get_content()));
                 }
                 }
             }
             }
         }
         }
     }
     }
 
 
     void post_event(typename Time::type t,
     void post_event(typename Time::type t,
-                    const common::ExternalEvent < Time >& event)
+                    const common::ExternalEvent < Time,
+                                                  SchedulerHandle >& event)
     {
     {
-        typename common::Links < Time >::Result result =
+        typename common::Links < Time, SchedulerHandle >::Result result =
             _link_list.find(_coordinator, event.get_port_name());
             _link_list.find(_coordinator, event.get_port_name());
 
 
-        for (typename common::Links < Time >::const_iterator it_r =
+        for (typename common::Links < Time,
+                                      SchedulerHandle >::const_iterator it_r =
                  result.first; it_r != result.second; ++it_r) {
                  result.first; it_r != result.second; ++it_r) {
             it_r->second.get_model()->post_event(
             it_r->second.get_model()->post_event(
-                t, common::ExternalEvent < Time >(it_r->second,
+                t, common::ExternalEvent < Time, SchedulerHandle >(it_r->second,
                                          event.get_content()));
                                          event.get_content()));
         }
         }
     }
     }
 
 
 private:
 private:
-    common::Links < Time >        _link_list;
-    common::Models < Time >       _child_list;
-    common::Coordinator < Time >* _coordinator;
+    common::Links < Time, SchedulerHandle >        _link_list;
+    common::Models < Time, SchedulerHandle >       _child_list;
+    common::Coordinator < Time, SchedulerHandle >* _coordinator;
 };
 };
 
 
 } } // namespace paradevs dtss
 } } // namespace paradevs dtss

+ 12 - 7
src/dtss/Simulator.hpp

@@ -36,15 +36,19 @@
 
 
 namespace paradevs { namespace dtss {
 namespace paradevs { namespace dtss {
 
 
-template < class Time, class Dynamics, class Parameters = common::NoParameters >
-class Simulator : public common::Simulator < Time >
+template < class Time, class Dynamics,
+           class SchedulerHandle =
+               paradevs::common::scheduler::NoSchedulerHandle,
+           class Parameters = common::NoParameters >
+class Simulator : public common::Simulator < Time, SchedulerHandle >
 {
 {
-    typedef Simulator < Time, Dynamics, Parameters > type;
+    typedef Simulator < Time, Dynamics, SchedulerHandle, Parameters > type;
 
 
 public:
 public:
     Simulator(const std::string& name, typename Time::type time_step,
     Simulator(const std::string& name, typename Time::type time_step,
         const Parameters& parameters) :
         const Parameters& parameters) :
-        common::Simulator < Time >(name), _dynamics(name, parameters),
+        common::Simulator < Time, SchedulerHandle >(name),
+        _dynamics(name, parameters),
         _time_step(time_step)
         _time_step(time_step)
     { }
     { }
 
 
@@ -95,13 +99,13 @@ public:
 #endif
 #endif
 
 
         if (t == type::_tn) {
         if (t == type::_tn) {
-            common::Bag < Time > bag = _dynamics.lambda(t);
+            common::Bag < Time, SchedulerHandle > 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 < Time >* >(
+                dynamic_cast < common::Coordinator < Time, SchedulerHandle >* >(
                     type::get_parent())->dispatch_events(bag, t);
                     type::get_parent())->dispatch_events(bag, t);
             }
             }
         }
         }
@@ -116,7 +120,8 @@ public:
     }
     }
 
 
     void post_event(typename Time::type t,
     void post_event(typename Time::type t,
-                    const common::ExternalEvent < Time >& event)
+                    const common::ExternalEvent < Time,
+                                                  SchedulerHandle >& event)
     {
     {
 
 
 #ifndef WITH_TRACE
 #ifndef WITH_TRACE

+ 18 - 11
src/pdevs/Coordinator.hpp

@@ -36,12 +36,15 @@
 
 
 namespace paradevs { namespace pdevs {
 namespace paradevs { namespace pdevs {
 
 
-template < class Time, class Scheduler, class GraphManager,
+template < class Time,
+           class Scheduler,
+           class SchedulerHandle,
+           class GraphManager,
            class Parameters = common::NoParameters,
            class Parameters = common::NoParameters,
            class GraphParameters = common::NoParameters >
            class GraphParameters = common::NoParameters >
-class Coordinator : public common::Coordinator < Time >
+class Coordinator : public common::Coordinator < Time, SchedulerHandle >
 {
 {
-    typedef Coordinator < Time, Scheduler, GraphManager,
+    typedef Coordinator < Time, Scheduler, SchedulerHandle, GraphManager,
                           Parameters, GraphParameters > type;
                           Parameters, GraphParameters > type;
 
 
 public:
 public:
@@ -51,7 +54,7 @@ public:
     Coordinator(const std::string& name,
     Coordinator(const std::string& name,
                 const Parameters& /* parameters */,
                 const Parameters& /* parameters */,
                 const GraphParameters& graph_parameters) :
                 const GraphParameters& graph_parameters) :
-        common::Coordinator < Time >(name),
+        common::Coordinator < Time, SchedulerHandle >(name),
         _graph_manager(this, graph_parameters)
         _graph_manager(this, graph_parameters)
     { }
     { }
 
 
@@ -75,7 +78,7 @@ public:
         for (auto & child : _graph_manager.children()) {
         for (auto & child : _graph_manager.children()) {
             _event_table.init(child->start(
             _event_table.init(child->start(
                                   Coordinator < Time, Scheduler,
                                   Coordinator < Time, Scheduler,
-                                  GraphManager, Parameters,
+                                  SchedulerHandle, GraphManager, Parameters,
                                   GraphParameters >::_tn), child);
                                   GraphParameters >::_tn), child);
         }
         }
         type::_tl = t;
         type::_tl = t;
@@ -116,7 +119,8 @@ public:
 
 
         assert(t == type::_tn);
         assert(t == type::_tn);
 
 
-        common::Models < Time > IMM = _event_table.get_current_models(t);
+        common::Models < Time, SchedulerHandle > IMM =
+            _event_table.get_current_models(t);
 
 
 #ifdef WITH_TRACE
 #ifdef WITH_TRACE
         common::Trace < Time >::trace()
         common::Trace < Time >::trace()
@@ -166,7 +170,8 @@ public:
 
 
         assert(t >= type::_tl and t <= type::_tn);
         assert(t >= type::_tl and t <= type::_tn);
 
 
-        common::Models < Time > receivers = _event_table.get_current_models(t);
+        common::Models < Time, SchedulerHandle > receivers =
+            _event_table.get_current_models(t);
 
 
         add_models_with_inputs(receivers);
         add_models_with_inputs(receivers);
 
 
@@ -200,7 +205,8 @@ public:
     }
     }
 
 
     void post_event(typename Time::type t,
     void post_event(typename Time::type t,
-                    const common::ExternalEvent < Time >& event)
+                    const common::ExternalEvent < Time,
+                                                  SchedulerHandle >& event)
     {
     {
 
 
 #ifdef WITH_TRACE
 #ifdef WITH_TRACE
@@ -229,8 +235,8 @@ public:
 /*******************************************************************
 /*******************************************************************
  * when y-message(y_d, t) with output y_d from d
  * when y-message(y_d, t) with output y_d from d
  *******************************************************************/
  *******************************************************************/
-    typename Time::type dispatch_events(common::Bag < Time > bag,
-                                        typename Time::type t)
+    typename Time::type dispatch_events(
+        common::Bag < Time, SchedulerHandle > bag, typename Time::type t)
     {
     {
 
 
 #ifdef WITH_TRACE
 #ifdef WITH_TRACE
@@ -266,7 +272,8 @@ public:
         }
         }
     }
     }
 
 
-    void add_models_with_inputs(common::Models < Time >& receivers)
+    void add_models_with_inputs(
+        common::Models < Time, SchedulerHandle >& receivers)
     {
     {
         for (auto & model : _graph_manager.children()) {
         for (auto & model : _graph_manager.children()) {
             if (model->event_number() > 0) {
             if (model->event_number() > 0) {

+ 7 - 5
src/pdevs/Dynamics.hpp

@@ -36,7 +36,8 @@
 
 
 namespace paradevs { namespace pdevs {
 namespace paradevs { namespace pdevs {
 
 
-template < class Time, class Parameters = common::NoParameters >
+template < class Time, class SchedulerHandle,
+           class Parameters = common::NoParameters >
 class Dynamics
 class Dynamics
 {
 {
 public:
 public:
@@ -49,7 +50,7 @@ public:
 
 
     virtual void dconf(typename Time::type /* t */,
     virtual void dconf(typename Time::type /* t */,
                        typename Time::type /* e */,
                        typename Time::type /* e */,
-                       const common::Bag < Time >& /* bag */)
+                       const common::Bag < Time, SchedulerHandle >& /* bag */)
     { }
     { }
 
 
     virtual void dint(typename Time::type /* t */)
     virtual void dint(typename Time::type /* t */)
@@ -57,7 +58,7 @@ public:
 
 
     virtual void dext(typename Time::type /* t */,
     virtual void dext(typename Time::type /* t */,
                       typename Time::type /* e */,
                       typename Time::type /* e */,
-                      const common::Bag < Time >& /* bag */)
+                      const common::Bag < Time, SchedulerHandle >& /* bag */)
     { }
     { }
 
 
     virtual typename Time::type start(typename Time::type /* time */)
     virtual typename Time::type start(typename Time::type /* time */)
@@ -66,8 +67,9 @@ public:
     virtual typename Time::type ta(typename Time::type /* time */) const
     virtual typename Time::type ta(typename Time::type /* time */) const
     { return Time::infinity; }
     { return Time::infinity; }
 
 
-    virtual common::Bag < Time > lambda(typename Time::type /* time */) const
-    { return common::Bag < Time >(); }
+    virtual common::Bag < Time, SchedulerHandle > lambda(
+        typename Time::type /* time */) const
+    { return common::Bag < Time, SchedulerHandle >(); }
 
 
     virtual void observation(std::ostream& /* file */) const
     virtual void observation(std::ostream& /* file */) const
     { }
     { }

+ 38 - 28
src/pdevs/GraphManager.hpp

@@ -34,11 +34,12 @@
 
 
 namespace paradevs { namespace pdevs {
 namespace paradevs { namespace pdevs {
 
 
-template < class Time, class GraphParameters = common::NoParameters >
+template < class Time, class SchedulerHandle,
+           class GraphParameters = common::NoParameters >
 class GraphManager
 class GraphManager
 {
 {
 public:
 public:
-    GraphManager(common::Coordinator < Time >* coordinator,
+    GraphManager(common::Coordinator < Time, SchedulerHandle >* coordinator,
                  const GraphParameters& /* parameters */) :
                  const GraphParameters& /* parameters */) :
         _coordinator(coordinator)
         _coordinator(coordinator)
     { }
     { }
@@ -46,15 +47,15 @@ public:
     virtual ~GraphManager()
     virtual ~GraphManager()
     { }
     { }
 
 
-    void add_child(common::Model < Time >* child)
+    void add_child(common::Model < Time, SchedulerHandle >* child)
     {
     {
         _child_list.push_back(child);
         _child_list.push_back(child);
         child->set_parent(_coordinator);
         child->set_parent(_coordinator);
     }
     }
 
 
-    void add_link(common::Model < Time >* src_model,
+    void add_link(common::Model < Time, SchedulerHandle >* src_model,
                   const std::string& src_port_name,
                   const std::string& src_port_name,
-                  common::Model < Time >* dst_model,
+                  common::Model < Time, SchedulerHandle >* dst_model,
                   const std::string& dst_port_name)
                   const std::string& dst_port_name)
     {
     {
         assert((src_model != _coordinator and
         assert((src_model != _coordinator and
@@ -73,55 +74,64 @@ public:
         _link_list.add(src_model, src_port_name, dst_model, dst_port_name);
         _link_list.add(src_model, src_port_name, dst_model, dst_port_name);
     }
     }
 
 
-    const common::Models < Time >& children() const
+    const common::Models < Time, SchedulerHandle >& children() const
     { return _child_list; }
     { return _child_list; }
 
 
-    void dispatch_events(common::Bag < Time > bag, typename Time::type t)
+    void dispatch_events(common::Bag < Time, SchedulerHandle > bag,
+                         typename Time::type t)
     {
     {
         for (auto & ymsg : bag) {
         for (auto & ymsg : bag) {
-            typename common::Links < Time >::Result result_model =
+            typename common::Links < Time,
+                                     SchedulerHandle >::Result result_model =
                 _link_list.find(ymsg.get_model(),
                 _link_list.find(ymsg.get_model(),
                                 ymsg.get_port_name());
                                 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
+            for (typename common::Links < Time, SchedulerHandle >::
+                     const_iterator it = result_model.first;
+                     it != result_model.second; ++it) {
+                // event on output port of coupled Model
                 if (it->second.get_model() == _coordinator) {
                 if (it->second.get_model() == _coordinator) {
-                    common::Bag < Time > ymessages;
+                    common::Bag < Time, SchedulerHandle > ymessages;
 
 
                     ymessages.push_back(
                     ymessages.push_back(
-                        common::ExternalEvent < Time >(it->second,
-                                                       ymsg.get_content()));
-                    dynamic_cast < common::Coordinator < Time >* >(
-                        _coordinator->get_parent())->dispatch_events(ymessages,
-                                                                     t);
+                        common::ExternalEvent <
+                            Time, SchedulerHandle >(it->second,
+                                                    ymsg.get_content()));
+                    dynamic_cast < common::Coordinator <
+                        Time,  SchedulerHandle >* >(
+                            _coordinator->get_parent())->dispatch_events(
+                                ymessages, t);
                 } else { // event on input port of internal model
                 } else { // event on input port of internal model
                     it->second.get_model()->post_event(
                     it->second.get_model()->post_event(
-                        t, common::ExternalEvent < Time >(it->second,
-                                                 ymsg.get_content()));
+                        t, common::ExternalEvent <
+                            Time,  SchedulerHandle >(
+                                it->second, ymsg.get_content()));
                 }
                 }
             }
             }
         }
         }
     }
     }
 
 
     void post_event(typename Time::type t,
     void post_event(typename Time::type t,
-                    const common::ExternalEvent < Time >& event)
+                    const common::ExternalEvent < Time,
+                                                  SchedulerHandle >& event)
     {
     {
-        typename common::Links < Time >::Result result =
+        typename common::Links < Time, SchedulerHandle >::Result result =
             _link_list.find(_coordinator, event.get_port_name());
             _link_list.find(_coordinator, event.get_port_name());
 
 
-        for (typename common::Links < Time >::const_iterator it_r =
+        for (typename common::Links < Time,
+                                      SchedulerHandle >::const_iterator it_r =
                  result.first; it_r != result.second; ++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()));
+                 it_r->second.get_model()->post_event(
+                     t, common::ExternalEvent <
+                         Time, SchedulerHandle >(it_r->second,
+                                                 event.get_content()));
         }
         }
     }
     }
 
 
 private:
 private:
-    common::Links < Time >        _link_list;
-    common::Models < Time >       _child_list;
-    common::Coordinator < Time >* _coordinator;
+    common::Links < Time, SchedulerHandle >        _link_list;
+    common::Models < Time, SchedulerHandle >       _child_list;
+    common::Coordinator < Time, SchedulerHandle >* _coordinator;
 };
 };
 
 
 } } // namespace paradevs pdevs
 } } // namespace paradevs pdevs

+ 10 - 7
src/pdevs/Simulator.hpp

@@ -36,14 +36,16 @@
 
 
 namespace paradevs { namespace pdevs {
 namespace paradevs { namespace pdevs {
 
 
-template < class Time, class Dynamics, class Parameters = common::NoParameters >
-class Simulator : public common::Simulator < Time >
+template < class Time, class Dynamics, class SchedulerHandle,
+           class Parameters = common::NoParameters >
+class Simulator : public common::Simulator < Time, SchedulerHandle >
 {
 {
-    typedef Simulator < Time, Dynamics, Parameters > type;
+    typedef Simulator < Time, Dynamics, SchedulerHandle, Parameters > type;
 
 
 public :
 public :
     Simulator(const std::string& name, const Parameters& parameters) :
     Simulator(const std::string& name, const Parameters& parameters) :
-        common::Simulator < Time >(name), _dynamics(name, parameters)
+        common::Simulator < Time, SchedulerHandle >(name),
+        _dynamics(name, parameters)
     { }
     { }
 
 
     ~Simulator()
     ~Simulator()
@@ -104,13 +106,13 @@ public :
 #endif
 #endif
 
 
         if(t == type::_tn) {
         if(t == type::_tn) {
-            common::Bag < Time > bag = _dynamics.lambda(t);
+            common::Bag < Time, SchedulerHandle > 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 < Time >* >(
+                dynamic_cast < common::Coordinator < Time, SchedulerHandle >* >(
                     type::get_parent())->dispatch_events(bag, t);
                     type::get_parent())->dispatch_events(bag, t);
             }
             }
         }
         }
@@ -125,7 +127,8 @@ public :
     }
     }
 
 
     void post_event(typename Time::type t,
     void post_event(typename Time::type t,
-                    const common::ExternalEvent < Time >& event)
+                    const common::ExternalEvent < Time,
+                                                  SchedulerHandle >& event)
     {
     {
 
 
 #ifndef WITH_TRACE
 #ifndef WITH_TRACE

+ 97 - 52
src/tests/boost_graph/graph_manager.hpp

@@ -39,6 +39,29 @@
 
 
 namespace paradevs { namespace tests { namespace boost_graph {
 namespace paradevs { namespace tests { namespace boost_graph {
 
 
+struct SchedulerHandle;
+
+typedef typename paradevs::common::scheduler::HeapScheduler <
+    MyTime, SchedulerHandle >::type SchedulerType;
+
+struct SchedulerHandle
+{
+    SchedulerHandle()
+    { }
+
+    SchedulerHandle(const SchedulerType::handle_type& handle)
+        : _handle(handle)
+    { }
+
+    const SchedulerHandle& handle() const
+    { return *this; }
+
+    void handle(const SchedulerHandle& handle)
+    { _handle = handle._handle; }
+
+    SchedulerType::handle_type _handle;
+};
+
 struct GraphParameters
 struct GraphParameters
 {
 {
     Graph       _graph;
     Graph       _graph;
@@ -52,25 +75,29 @@ struct GraphParameters
     { }
     { }
 };
 };
 
 
-template < class Parameters >
+template < class SchedulerHandle, class Parameters >
 class FlatGraphManager :
 class FlatGraphManager :
-    public paradevs::pdevs::GraphManager < MyTime, Parameters >
+        public paradevs::pdevs::GraphManager < MyTime, SchedulerHandle,
+                                               Parameters >
 {
 {
 public:
 public:
-    FlatGraphManager(common::Coordinator < MyTime >* coordinator,
+    FlatGraphManager(common::Coordinator < MyTime,
+                                           SchedulerHandle >* coordinator,
         const Parameters& parameters) :
         const Parameters& parameters) :
-        paradevs::pdevs::GraphManager < MyTime, Parameters >(
+        paradevs::pdevs::GraphManager < MyTime, SchedulerHandle, Parameters >(
             coordinator, parameters)
             coordinator, parameters)
     { }
     { }
 
 
     virtual ~FlatGraphManager()
     virtual ~FlatGraphManager()
     {
     {
-        for (TopSimulators::const_iterator it = _top_simulators.begin();
-             it != _top_simulators.end(); ++it) {
+        for (typename TopSimulators::const_iterator it =
+                 _top_simulators.begin(); it != _top_simulators.end();
+             ++it) {
             delete it->second;
             delete it->second;
         }
         }
-        for (NormalSimulators::const_iterator it = _normal_simulators.begin();
-             it != _normal_simulators.end(); ++it) {
+        for (typename NormalSimulators::const_iterator it =
+                 _normal_simulators.begin(); it != _normal_simulators.end();
+             ++it) {
             delete it->second;
             delete it->second;
         }
         }
     }
     }
@@ -89,10 +116,10 @@ public:
             case TOP_PIXEL:
             case TOP_PIXEL:
                 _top_simulators[g[*vertexIt]._index] =
                 _top_simulators[g[*vertexIt]._index] =
                     new pdevs::Simulator <
                     new pdevs::Simulator <
-                        MyTime, TopPixel, TopPixelParameters >(
-                            ss.str(), TopPixelParameters());
+                        MyTime, TopPixel < SchedulerHandle >, SchedulerHandle,
+                        TopPixelParameters >(ss.str(), TopPixelParameters());
                 _top_simulators[g[*vertexIt]._index]->add_out_port("out");
                 _top_simulators[g[*vertexIt]._index]->add_out_port("out");
-                FlatGraphManager < Parameters >::add_child(
+                FlatGraphManager < SchedulerHandle, Parameters >::add_child(
                     _top_simulators[g[*vertexIt]._index]);
                     _top_simulators[g[*vertexIt]._index]);
                 break;
                 break;
             case NORMAL_PIXEL:
             case NORMAL_PIXEL:
@@ -113,11 +140,12 @@ public:
 
 
                 _normal_simulators[g[*vertexIt]._index] =
                 _normal_simulators[g[*vertexIt]._index] =
                     new pdevs::Simulator <
                     new pdevs::Simulator <
-                        MyTime, NormalPixel, NormalPixelParameters >(
+                        MyTime, NormalPixel < SchedulerHandle >,
+                        SchedulerHandle, NormalPixelParameters >(
                             ss.str(), NormalPixelParameters(n));
                             ss.str(), NormalPixelParameters(n));
                 _normal_simulators[g[*vertexIt]._index]->add_in_port("in");
                 _normal_simulators[g[*vertexIt]._index]->add_in_port("in");
                 _normal_simulators[g[*vertexIt]._index]->add_out_port("out");
                 _normal_simulators[g[*vertexIt]._index]->add_out_port("out");
-                FlatGraphManager < Parameters >::add_child(
+                FlatGraphManager < SchedulerHandle, Parameters >::add_child(
                         _normal_simulators[g[*vertexIt]._index]);
                         _normal_simulators[g[*vertexIt]._index]);
                 break;
                 break;
             };
             };
@@ -131,8 +159,8 @@ public:
             boost::tie(neighbourIt, neighbourEnd) =
             boost::tie(neighbourIt, neighbourEnd) =
                 boost::adjacent_vertices(*vertexIt, g);
                 boost::adjacent_vertices(*vertexIt, g);
             for (; neighbourIt != neighbourEnd; ++neighbourIt) {
             for (; neighbourIt != neighbourEnd; ++neighbourIt) {
-                paradevs::common::Model < MyTime >* a = 0;
-                paradevs::common::Model < MyTime >* b = 0;
+                paradevs::common::Model < MyTime, SchedulerHandle >* a = 0;
+                paradevs::common::Model < MyTime, SchedulerHandle >* b = 0;
 
 
                 if (g[*vertexIt]._type == TOP_PIXEL) {
                 if (g[*vertexIt]._type == TOP_PIXEL) {
                     a = _top_simulators[g[*vertexIt]._index];
                     a = _top_simulators[g[*vertexIt]._index];
@@ -144,33 +172,40 @@ public:
                 } else {
                 } else {
                     b = _normal_simulators[g[*neighbourIt]._index];
                     b = _normal_simulators[g[*neighbourIt]._index];
                 }
                 }
-                FlatGraphManager < Parameters >::add_link(b, "out", a, "in");
+                FlatGraphManager < SchedulerHandle,
+                                   Parameters >::add_link(b, "out",
+                                                               a, "in");
             }
             }
 	}
 	}
     }
     }
 
 
 protected:
 protected:
     typedef std::map < int, pdevs::Simulator <
     typedef std::map < int, pdevs::Simulator <
-                                MyTime, TopPixel,
+                                MyTime, TopPixel < SchedulerHandle >,
+                                SchedulerHandle,
                                 TopPixelParameters >* > TopSimulators;
                                 TopPixelParameters >* > TopSimulators;
     typedef std::map < int, pdevs::Simulator <
     typedef std::map < int, pdevs::Simulator <
-                                MyTime, NormalPixel,
+                                MyTime, NormalPixel < SchedulerHandle >,
+                                SchedulerHandle,
                                 NormalPixelParameters >* > NormalSimulators;
                                 NormalPixelParameters >* > NormalSimulators;
 
 
     TopSimulators    _top_simulators;
     TopSimulators    _top_simulators;
     NormalSimulators _normal_simulators;
     NormalSimulators _normal_simulators;
 };
 };
 
 
+template < class SchedulerHandle >
 class BuiltFlatGraphManager :
 class BuiltFlatGraphManager :
-    public FlatGraphManager < GraphParameters >
+        public FlatGraphManager < SchedulerHandle, GraphParameters >
 {
 {
 public:
 public:
-    BuiltFlatGraphManager(common::Coordinator < MyTime >* coordinator,
-                          const GraphParameters& parameters) :
-        FlatGraphManager < GraphParameters >(
+    BuiltFlatGraphManager(
+        common::Coordinator < MyTime, SchedulerHandle >* coordinator,
+        const GraphParameters& parameters) :
+        FlatGraphManager < SchedulerHandle, GraphParameters >(
             coordinator, parameters)
             coordinator, parameters)
     {
     {
-        build_flat_graph(parameters._graph, parameters._input_edges);
+        BuiltFlatGraphManager < SchedulerHandle >::build_flat_graph(
+            parameters._graph, parameters._input_edges);
         // input
         // input
         for (Edges::const_iterator it = parameters._input_edges.begin();
         for (Edges::const_iterator it = parameters._input_edges.begin();
              it != parameters._input_edges.end(); ++it) {
              it != parameters._input_edges.end(); ++it) {
@@ -180,9 +215,10 @@ public:
             if (not coordinator->exist_in_port(ss_in.str())) {
             if (not coordinator->exist_in_port(ss_in.str())) {
                 coordinator->add_in_port(ss_in.str());
                 coordinator->add_in_port(ss_in.str());
             }
             }
-            BuiltFlatGraphManager::add_link(coordinator, ss_in.str(),
-                                            _normal_simulators[it->second],
-                                            "in");
+            BuiltFlatGraphManager < SchedulerHandle>::add_link(
+                coordinator, ss_in.str(),
+                BuiltFlatGraphManager <
+                    SchedulerHandle >::_normal_simulators[it->second], "in");
         }
         }
         // output
         // output
         for (Edges::const_iterator it = parameters._output_edges.begin();
         for (Edges::const_iterator it = parameters._output_edges.begin();
@@ -193,8 +229,10 @@ public:
             if (not coordinator->exist_out_port(ss_out.str())) {
             if (not coordinator->exist_out_port(ss_out.str())) {
                 coordinator->add_out_port(ss_out.str());
                 coordinator->add_out_port(ss_out.str());
             }
             }
-            BuiltFlatGraphManager::add_link(_normal_simulators[it->first],
-                                            "out", coordinator, ss_out.str());
+            BuiltFlatGraphManager < SchedulerHandle>::add_link(
+                BuiltFlatGraphManager <
+                    SchedulerHandle >::_normal_simulators[it->first], "out",
+                coordinator, ss_out.str());
         }
         }
     }
     }
 
 
@@ -202,14 +240,16 @@ public:
     { }
     { }
 };
 };
 
 
-template < class GraphBuilder >
+template < class SchedulerHandle, class GraphBuilder >
 class InBuildFlatGraphManager :
 class InBuildFlatGraphManager :
-    public FlatGraphManager < paradevs::common::NoParameters >
+        public FlatGraphManager < SchedulerHandle,
+                                  paradevs::common::NoParameters >
 {
 {
 public:
 public:
-    InBuildFlatGraphManager(common::Coordinator < MyTime >* coordinator,
-                            const paradevs::common::NoParameters& parameters) :
-        FlatGraphManager < paradevs::common::NoParameters >(
+    InBuildFlatGraphManager(
+        common::Coordinator < MyTime, SchedulerHandle >* coordinator,
+        const paradevs::common::NoParameters& parameters) :
+        FlatGraphManager < SchedulerHandle, paradevs::common::NoParameters >(
             coordinator, parameters)
             coordinator, parameters)
     {
     {
         GraphBuilder   builder;
         GraphBuilder   builder;
@@ -219,22 +259,25 @@ public:
         Connections    parent_connections;
         Connections    parent_connections;
 
 
         builder.build(graphs, input_edges, output_edges, parent_connections);
         builder.build(graphs, input_edges, output_edges, parent_connections);
-        build_flat_graph(graphs.front(), InputEdges());
+        InBuildFlatGraphManager < SchedulerHandle,
+                                  GraphBuilder >::build_flat_graph(
+                                      graphs.front(), InputEdges());
     }
     }
 
 
     virtual ~InBuildFlatGraphManager()
     virtual ~InBuildFlatGraphManager()
     { }
     { }
 };
 };
 
 
-template < class GraphBuilder >
+template < class SchedulerHandle, class GraphBuilder >
 class HierarchicalGraphManager :
 class HierarchicalGraphManager :
-    public paradevs::pdevs::GraphManager < MyTime,
-                                           paradevs::common::NoParameters >
+        public paradevs::pdevs::GraphManager < MyTime, SchedulerHandle,
+                                               paradevs::common::NoParameters >
 {
 {
 public:
 public:
-    HierarchicalGraphManager(common::Coordinator < MyTime >* coordinator,
-                             const paradevs::common::NoParameters& parameters) :
-        paradevs::pdevs::GraphManager < MyTime,
+    HierarchicalGraphManager(
+        common::Coordinator < MyTime, SchedulerHandle >* coordinator,
+        const paradevs::common::NoParameters& parameters) :
+        paradevs::pdevs::GraphManager < MyTime, SchedulerHandle,
                                         paradevs::common::NoParameters >(
                                         paradevs::common::NoParameters >(
                                             coordinator, parameters)
                                             coordinator, parameters)
     {
     {
@@ -258,8 +301,8 @@ public:
                                 GraphParameters(graphs[i], input_edges[i],
                                 GraphParameters(graphs[i], input_edges[i],
                                                 output_edges[i]));
                                                 output_edges[i]));
             _coordinators.push_back(coordinator);
             _coordinators.push_back(coordinator);
-            HierarchicalGraphManager < GraphBuilder >::add_child(
-                coordinator);
+            HierarchicalGraphManager < SchedulerHandle,
+                                       GraphBuilder >::add_child(coordinator);
 
 
         }
         }
 
 
@@ -272,27 +315,29 @@ public:
 
 
             ss_out << "out_" << connection.first.second;
             ss_out << "out_" << connection.first.second;
             ss_in << "in_" << connection.first.second;
             ss_in << "in_" << connection.first.second;
-            HierarchicalGraphManager < GraphBuilder >::add_link(
-                _coordinators[connection.first.first - 1], ss_out.str(),
-                _coordinators[connection.second.first - 1], ss_in.str());
+            HierarchicalGraphManager <
+                SchedulerHandle, GraphBuilder >::add_link(
+                    _coordinators[connection.first.first - 1], ss_out.str(),
+                    _coordinators[connection.second.first - 1], ss_in.str());
         }
         }
     }
     }
 
 
     virtual ~HierarchicalGraphManager()
     virtual ~HierarchicalGraphManager()
     {
     {
-        for (Coordinators::const_iterator it = _coordinators.begin();
+        for (typename Coordinators::const_iterator it = _coordinators.begin();
              it != _coordinators.end(); ++it) {
              it != _coordinators.end(); ++it) {
             delete *it;
             delete *it;
         }
         }
     }
     }
 
 
 private:
 private:
-    typedef paradevs::pdevs::Coordinator < MyTime,
-                                           common::scheduler::VectorScheduler <
-                                               MyTime >,
-                                           BuiltFlatGraphManager,
-                                           common::NoParameters,
-                                           GraphParameters > Coordinator;
+    typedef paradevs::pdevs::Coordinator <
+        MyTime,
+        SchedulerType,
+        SchedulerHandle,
+        BuiltFlatGraphManager < SchedulerHandle >,
+        common::NoParameters,
+        GraphParameters > Coordinator;
     typedef std::vector < Coordinator* > Coordinators;
     typedef std::vector < Coordinator* > Coordinators;
 
 
     Coordinators _coordinators;
     Coordinators _coordinators;

+ 38 - 21
src/tests/boost_graph/models.hpp

@@ -50,12 +50,15 @@ typedef paradevs::common::Time < double, Limits < double > > MyTime;
 struct TopPixelParameters
 struct TopPixelParameters
 { };
 { };
 
 
-class TopPixel : public paradevs::pdevs::Dynamics < MyTime, TopPixelParameters >
+template < class SchedulerHandle>
+class TopPixel :
+    public paradevs::pdevs::Dynamics < MyTime, SchedulerHandle,
+                                       TopPixelParameters >
 {
 {
 public:
 public:
     TopPixel(const std::string& name,
     TopPixel(const std::string& name,
              const TopPixelParameters& parameters) :
              const TopPixelParameters& parameters) :
-        paradevs::pdevs::Dynamics < MyTime,
+        paradevs::pdevs::Dynamics < MyTime, SchedulerHandle,
                                     TopPixelParameters >(name, parameters)
                                     TopPixelParameters >(name, parameters)
     { }
     { }
 
 
@@ -65,7 +68,8 @@ public:
     virtual void dint(typename MyTime::type t)
     virtual void dint(typename MyTime::type t)
     {
     {
 
 
-        std::cout << get_name() << " at " << t << ": dint" << std::endl;
+        std::cout << TopPixel < SchedulerHandle >::get_name() << " at "
+                  << t << ": dint" << std::endl;
 
 
     }
     }
 
 
@@ -75,14 +79,17 @@ public:
     virtual typename MyTime::type ta(typename MyTime::type /* t */) const
     virtual typename MyTime::type ta(typename MyTime::type /* t */) const
     { return 1; }
     { return 1; }
 
 
-    virtual common::Bag < MyTime > lambda(typename MyTime::type t) const
+    virtual common::Bag < MyTime, SchedulerHandle > lambda(
+        typename MyTime::type t) const
     {
     {
 
 
-        std::cout << get_name() << " at " << t << ": lambda" << std::endl;
+        std::cout << TopPixel < SchedulerHandle >::get_name() << " at "
+                  << t << ": lambda" << std::endl;
 
 
-        common::Bag < MyTime > bag;
+        common::Bag < MyTime, SchedulerHandle > bag;
 
 
-        bag.push_back(common::ExternalEvent < MyTime >("out", 0.));
+        bag.push_back(common::ExternalEvent < MyTime, SchedulerHandle >(
+                          "out", 0.));
         return bag;
         return bag;
     }
     }
 };
 };
@@ -95,13 +102,15 @@ struct NormalPixelParameters
     unsigned int _neighbour_number;
     unsigned int _neighbour_number;
 };
 };
 
 
-class NormalPixel : public paradevs::pdevs::Dynamics < MyTime,
-                                                       NormalPixelParameters >
+template < class SchedulerHandle>
+class NormalPixel :
+    public paradevs::pdevs::Dynamics < MyTime, SchedulerHandle,
+                                       NormalPixelParameters >
 {
 {
 public:
 public:
     NormalPixel(const std::string& name,
     NormalPixel(const std::string& name,
              const NormalPixelParameters& parameters) :
              const NormalPixelParameters& parameters) :
-        paradevs::pdevs::Dynamics < MyTime,
+        paradevs::pdevs::Dynamics < MyTime, SchedulerHandle,
                                     NormalPixelParameters >(name, parameters),
                                     NormalPixelParameters >(name, parameters),
         _neighbour_number(parameters._neighbour_number)
         _neighbour_number(parameters._neighbour_number)
     { }
     { }
@@ -112,7 +121,8 @@ public:
     virtual void dint(typename MyTime::type t)
     virtual void dint(typename MyTime::type t)
     {
     {
 
 
-        std::cout << get_name() << " at " << t << ": dint" << std::endl;
+        std::cout << NormalPixel < SchedulerHandle >::get_name() << " at "
+                  << t << ": dint" << std::endl;
 
 
         if (_phase == SEND) {
         if (_phase == SEND) {
             _phase = WAIT;
             _phase = WAIT;
@@ -122,14 +132,16 @@ public:
 
 
     virtual void dext(typename MyTime::type t,
     virtual void dext(typename MyTime::type t,
                       typename MyTime::type /* e */,
                       typename MyTime::type /* e */,
-                      const common::Bag < MyTime >& bag)
+                      const common::Bag < MyTime, SchedulerHandle >& bag)
     {
     {
 
 
-        std::cout << get_name() << " at " << t << ": dext -> "
+        std::cout << NormalPixel < SchedulerHandle >::get_name() << " at "
+                  << t << ": dext -> "
                   << bag.to_string() << std::endl;
                   << bag.to_string() << std::endl;
 
 
-        for (common::Bag < MyTime >::const_iterator it = bag.begin();
-             it != bag.end(); ++it) {
+        for (typename common::Bag < MyTime,
+                                    SchedulerHandle >::const_iterator it =
+                 bag.begin(); it != bag.end(); ++it) {
             if (it->on_port("in")) {
             if (it->on_port("in")) {
                 ++_received;
                 ++_received;
                 if (_received == _neighbour_number) {
                 if (_received == _neighbour_number) {
@@ -138,7 +150,8 @@ public:
             }
             }
         }
         }
 
 
-        std::cout << get_name() << " at " << t << ": dext -> "
+        std::cout << NormalPixel < SchedulerHandle >::get_name() << " at "
+                  << t << ": dext -> "
                   << _received << "/" << _neighbour_number
                   << _received << "/" << _neighbour_number
                   << std::endl;
                   << std::endl;
 
 
@@ -154,7 +167,8 @@ public:
     virtual typename MyTime::type ta(typename MyTime::type t) const
     virtual typename MyTime::type ta(typename MyTime::type t) const
     {
     {
 
 
-        std::cout << get_name() << " at " << t << ": ta" << std::endl;
+        std::cout << NormalPixel < SchedulerHandle >::get_name() << " at "
+                  << t << ": ta" << std::endl;
 
 
         if (_phase == WAIT) {
         if (_phase == WAIT) {
             return MyTime::infinity;
             return MyTime::infinity;
@@ -163,15 +177,18 @@ public:
         }
         }
     }
     }
 
 
-    virtual common::Bag < MyTime > lambda(typename MyTime::type t) const
+    virtual common::Bag < MyTime, SchedulerHandle > lambda(
+        typename MyTime::type t) const
     {
     {
 
 
-        std::cout << get_name() << " at " << t << ": lambda" << std::endl;
+        std::cout << NormalPixel < SchedulerHandle >::get_name() << " at "
+                  << t << ": lambda" << std::endl;
 
 
-        common::Bag < MyTime > bag;
+        common::Bag < MyTime, SchedulerHandle > bag;
 
 
         if (_phase == SEND) {
         if (_phase == SEND) {
-            bag.push_back(common::ExternalEvent < MyTime >("out", 0.));
+            bag.push_back(common::ExternalEvent < MyTime,
+                                                  SchedulerHandle >("out", 0.));
         }
         }
         return bag;
         return bag;
     }
     }

+ 90 - 81
src/tests/boost_graph/tests.cpp

@@ -36,10 +36,15 @@ using namespace paradevs::tests::boost_graph;
 
 
 void flat_test()
 void flat_test()
 {
 {
-    RootCoordinator < MyTime, paradevs::pdevs::Coordinator <
-        MyTime, VectorScheduler < MyTime >, InBuildFlatGraphManager <
-            FlatGraphBuilder >, paradevs::common::NoParameters,
-        paradevs::common::NoParameters >
+    RootCoordinator <
+        MyTime,
+        paradevs::pdevs::Coordinator <
+            MyTime,
+            SchedulerType,
+            SchedulerHandle,
+            InBuildFlatGraphManager < SchedulerHandle, FlatGraphBuilder >,
+            paradevs::common::NoParameters,
+            paradevs::common::NoParameters >
     > rc(0, 100, "root", NoParameters(), NoParameters());
     > rc(0, 100, "root", NoParameters(), NoParameters());
 
 
     rc.run();
     rc.run();
@@ -47,89 +52,93 @@ void flat_test()
 
 
 void hierarchical_test()
 void hierarchical_test()
 {
 {
-    RootCoordinator < MyTime, paradevs::pdevs::Coordinator <
-        MyTime, VectorScheduler < MyTime >, HierarchicalGraphManager <
-            HierarchicalGraphBuilder >, paradevs::common::NoParameters,
-        paradevs::common::NoParameters > > rc(0, 100, "root",
-                                              NoParameters(), NoParameters());
+    RootCoordinator <
+        MyTime,
+        paradevs::pdevs::Coordinator <
+            MyTime,
+            SchedulerType,
+            SchedulerHandle,
+            HierarchicalGraphManager < SchedulerHandle,
+                                       HierarchicalGraphBuilder >,
+            paradevs::common::NoParameters,
+            paradevs::common::NoParameters >
+        > rc(0, 100, "root", NoParameters(), NoParameters());
 
 
     rc.run();
     rc.run();
 }
 }
 
 
 int main()
 int main()
 {
 {
-    // flat_test();
-    // hierarchical_test();
-
-    class M;
-
-    struct A
-    {
-        double time;
-        M*     model;
-
-        A(double _time, M* _model)
-        {
-            time = _time;
-            model = _model;
-        }
-    };
-
-    struct ACompare
-        : std::binary_function < A, A, bool >
-    {
-        bool operator()(const A &left, const A &right) const
-        { return left.time > right.time; }
-    };
-
-    typedef boost::heap::fibonacci_heap < A, boost::heap::compare <
-        ACompare > > Heap;
-
-    typedef Heap::handle_type HeapHandle;
-
-    class M
-    {
-    public:
-        M(int a)
-        {
-            _a = a;
-        }
-
-        int a() const
-        { return _a; }
-
-        HeapHandle heap_id() const
-        { return _heap_id; }
-
-        void heap_id(HeapHandle id)
-        { _heap_id = id; }
-
-    private:
-        int _a;
-        HeapHandle _heap_id;
-    };
-
-    Heap heap;
-    M* m1 = new M(1);
-    M* m2 = new M(2);
-
-    m1->heap_id(heap.push(A(0, m1)));
-    m2->heap_id(heap.push(A(0, m2)));
-
-    (*m1->heap_id()).time = 1;
-    heap.decrease(m1->heap_id());
-    (*m2->heap_id()).time = 1;
-    heap.decrease(m2->heap_id());
-
-    std::cout << "Scheduler = { ";
-    while (not heap.empty()) {
-        std::cout << "(" << heap.top().time << "," << heap.top().model->a()
-                  << ") ";
-        heap.pop();
-    }
-    std::cout << "}" << std::endl;
-
-
+    flat_test();
+    hierarchical_test();
+
+    // class M;
+
+    // struct A
+    // {
+    //     double time;
+    //     M*     model;
+
+    //     A(double _time, M* _model)
+    //     {
+    //         time = _time;
+    //         model = _model;
+    //     }
+    // };
+
+    // struct ACompare
+    //     : std::binary_function < A, A, bool >
+    // {
+    //     bool operator()(const A &left, const A &right) const
+    //     { return left.time > right.time; }
+    // };
+
+    // typedef boost::heap::fibonacci_heap < A, boost::heap::compare <
+    //     ACompare > > Heap;
+
+    // typedef Heap::handle_type HeapHandle;
+
+    // class M
+    // {
+    // public:
+    //     M(int a)
+    //     {
+    //         _a = a;
+    //     }
+
+    //     int a() const
+    //     { return _a; }
+
+    //     HeapHandle heap_id() const
+    //     { return _heap_id; }
+
+    //     void heap_id(HeapHandle id)
+    //     { _heap_id = id; }
+
+    // private:
+    //     int _a;
+    //     HeapHandle _heap_id;
+    // };
+
+    // Heap heap;
+    // M* m1 = new M(1);
+    // M* m2 = new M(2);
+
+    // m1->heap_id(heap.push(A(0, m1)));
+    // m2->heap_id(heap.push(A(0, m2)));
+
+    // (*m1->heap_id()).time = 1;
+    // heap.decrease(m1->heap_id());
+    // (*m2->heap_id()).time = 1;
+    // heap.decrease(m2->heap_id());
+
+    // std::cout << "Scheduler = { ";
+    // while (not heap.empty()) {
+    //     std::cout << "(" << heap.top().time << "," << heap.top().model->a()
+    //               << ") ";
+    //     heap.pop();
+    // }
+    // std::cout << "}" << std::endl;
 
 
     return 0;
     return 0;
 }
 }

+ 28 - 19
src/tests/dtss/graph_manager.hpp

@@ -35,71 +35,80 @@
 
 
 namespace paradevs { namespace tests { namespace dtss {
 namespace paradevs { namespace tests { namespace dtss {
 
 
+template < class SchedulerHandle >
 struct Policy
 struct Policy
 {
 {
-    const common::Bag < MyTime >& bag() const
+    const common::Bag < MyTime, SchedulerHandle >& bag() const
     { return _bag; }
     { return _bag; }
 
 
-    virtual void operator()(MyTime::type /* t */,
-                            const common::ExternalEvent < MyTime >& event,
-                            MyTime::type /* tl */,
-                            MyTime::type /* tn */)
+    virtual void operator()(
+        MyTime::type /* t */,
+        const common::ExternalEvent < MyTime, SchedulerHandle >& event,
+        MyTime::type /* tl */,
+        MyTime::type /* tn */)
     {
     {
         _bag.clear();
         _bag.clear();
         _bag.push_back(event);
         _bag.push_back(event);
     }
     }
 
 
 private:
 private:
-    common::Bag < MyTime > _bag;
+    common::Bag < MyTime, SchedulerHandle > _bag;
 };
 };
 
 
+template < class SchedulerHandle >
 class OnlyOneGraphManager :
 class OnlyOneGraphManager :
-        public paradevs::dtss::GraphManager < MyTime,
+        public paradevs::dtss::GraphManager < MyTime, SchedulerHandle,
                                               paradevs::common::NoParameters >
                                               paradevs::common::NoParameters >
 {
 {
 public:
 public:
-    OnlyOneGraphManager(common::Coordinator < MyTime >* coordinator,
+    OnlyOneGraphManager(common::Coordinator < MyTime,
+                                              SchedulerHandle >* coordinator,
                         const paradevs::common::NoParameters& parameters) :
                         const paradevs::common::NoParameters& parameters) :
-        paradevs::dtss::GraphManager < MyTime,
+        paradevs::dtss::GraphManager < MyTime, SchedulerHandle,
                                        paradevs::common::NoParameters >(
                                        paradevs::common::NoParameters >(
                                            coordinator, parameters),
                                            coordinator, parameters),
         a("a", 1, common::NoParameters())
         a("a", 1, common::NoParameters())
     {
     {
-        add_child(&a);
+        OnlyOneGraphManager < SchedulerHandle >::add_child(&a);
     }
     }
 
 
     virtual ~OnlyOneGraphManager()
     virtual ~OnlyOneGraphManager()
     { }
     { }
 
 
 private:
 private:
-    paradevs::dtss::Simulator < MyTime, A > a;
+    paradevs::dtss::Simulator < MyTime, A < SchedulerHandle >,
+                                SchedulerHandle > a;
 };
 };
 
 
+template < class SchedulerHandle >
 class TwoGraphManager :
 class TwoGraphManager :
-        public paradevs::dtss::GraphManager < MyTime,
+        public paradevs::dtss::GraphManager < MyTime, SchedulerHandle,
                                               paradevs::common::NoParameters >
                                               paradevs::common::NoParameters >
 {
 {
 public:
 public:
-    TwoGraphManager(common::Coordinator < MyTime >* coordinator,
+    TwoGraphManager(common::Coordinator < MyTime,
+                                          SchedulerHandle >* coordinator,
                     const paradevs::common::NoParameters& parameters) :
                     const paradevs::common::NoParameters& parameters) :
-        paradevs::dtss::GraphManager < MyTime,
+        paradevs::dtss::GraphManager < MyTime, SchedulerHandle,
                                        paradevs::common::NoParameters >(
                                        paradevs::common::NoParameters >(
                                            coordinator, parameters),
                                            coordinator, parameters),
         a("a", 1, common::NoParameters()), b("b", 1, common::NoParameters())
         a("a", 1, common::NoParameters()), b("b", 1, common::NoParameters())
     {
     {
-        add_child(&a);
-        add_child(&b);
+        TwoGraphManager < SchedulerHandle >::add_child(&a);
+        TwoGraphManager < SchedulerHandle >::add_child(&b);
         a.add_out_port("out");
         a.add_out_port("out");
         b.add_in_port("in");
         b.add_in_port("in");
-        add_link(&a, "out", &b, "in");
+        TwoGraphManager < SchedulerHandle >::add_link(&a, "out", &b, "in");
     }
     }
 
 
     virtual ~TwoGraphManager()
     virtual ~TwoGraphManager()
     { }
     { }
 
 
 private:
 private:
-    paradevs::dtss::Simulator < MyTime, A > a;
-    paradevs::dtss::Simulator < MyTime, B > b;
+    paradevs::dtss::Simulator < MyTime, A < SchedulerHandle >,
+                                SchedulerHandle > a;
+    paradevs::dtss::Simulator < MyTime, B < SchedulerHandle >,
+                                SchedulerHandle > b;
 };
 };
 
 
 } } } // namespace paradevs tests dtss
 } } } // namespace paradevs tests dtss

+ 36 - 24
src/tests/dtss/models.hpp

@@ -44,47 +44,53 @@ struct Limits
 
 
 typedef paradevs::common::Time < double, Limits < double > > MyTime;
 typedef paradevs::common::Time < double, Limits < double > > MyTime;
 
 
+template < class SchedulerHandle>
 class A :
 class A :
-        public paradevs::dtss::Dynamics < MyTime,
+        public paradevs::dtss::Dynamics < MyTime, SchedulerHandle,
                                           paradevs::common::NoParameters >
                                           paradevs::common::NoParameters >
 {
 {
 public:
 public:
     A(const std::string& name,
     A(const std::string& name,
       const paradevs::common::NoParameters& parameters) :
       const paradevs::common::NoParameters& parameters) :
-        paradevs::dtss::Dynamics < MyTime,
+        paradevs::dtss::Dynamics < MyTime, SchedulerHandle,
                                    paradevs::common::NoParameters >(name,
                                    paradevs::common::NoParameters >(name,
                                                                     parameters)
                                                                     parameters)
     { }
     { }
     virtual ~A()
     virtual ~A()
     { }
     { }
 
 
-    void transition(const common::Bag < MyTime >& /* x */, MyTime::type t)
+    void transition(const common::Bag < MyTime, SchedulerHandle >& /* x */,
+                    MyTime::type t)
     {
     {
         common::Trace < MyTime >::trace()
         common::Trace < MyTime >::trace()
-            << common::TraceElement < MyTime >(get_name(), t,
-                                               common::DELTA_INT);
+            << common::TraceElement < MyTime >(
+                A < SchedulerHandle >::get_name(), t,
+                common::DELTA_INT);
         common::Trace < MyTime >::trace().flush();
         common::Trace < MyTime >::trace().flush();
     }
     }
 
 
     MyTime::type start(MyTime::type t)
     MyTime::type start(MyTime::type t)
     {
     {
         common::Trace < MyTime >::trace()
         common::Trace < MyTime >::trace()
-            << common::TraceElement < MyTime >(get_name(), t,
-                                               common::START);
+            << common::TraceElement < MyTime >(
+                A < SchedulerHandle >::get_name(), t,
+                common::START);
         common::Trace < MyTime >::trace().flush();
         common::Trace < MyTime >::trace().flush();
 
 
         return 0;
         return 0;
     }
     }
 
 
-    common::Bag < MyTime > lambda(MyTime::type t) const
+    common::Bag < MyTime, SchedulerHandle > lambda(MyTime::type t) const
     {
     {
-        common::Bag < MyTime > msgs;
+        common::Bag < MyTime, SchedulerHandle > msgs;
 
 
-        msgs.push_back(common::ExternalEvent < MyTime >("out", 0.));
+        msgs.push_back(common::ExternalEvent < MyTime, SchedulerHandle >(
+                           "out", 0.));
 
 
         common::Trace < MyTime >::trace()
         common::Trace < MyTime >::trace()
-            << common::TraceElement < MyTime >(get_name(), t,
-                                               common::LAMBDA)
+            << common::TraceElement < MyTime >(
+                A < SchedulerHandle >::get_name(), t,
+                common::LAMBDA)
             << "messages = " << msgs.to_string();
             << "messages = " << msgs.to_string();
         common::Trace < MyTime >::trace().flush();
         common::Trace < MyTime >::trace().flush();
 
 
@@ -92,25 +98,28 @@ public:
     }
     }
 };
 };
 
 
+template < class SchedulerHandle>
 class B :
 class B :
-        public paradevs::dtss::Dynamics < MyTime,
+        public paradevs::dtss::Dynamics < MyTime, SchedulerHandle,
                                           paradevs::common::NoParameters >
                                           paradevs::common::NoParameters >
 {
 {
 public:
 public:
     B(const std::string& name,
     B(const std::string& name,
       const paradevs::common::NoParameters& parameters) :
       const paradevs::common::NoParameters& parameters) :
-        paradevs::dtss::Dynamics < MyTime,
+        paradevs::dtss::Dynamics < MyTime, SchedulerHandle,
                                    paradevs::common::NoParameters >(name,
                                    paradevs::common::NoParameters >(name,
                                                                     parameters)
                                                                     parameters)
     { }
     { }
     virtual ~B()
     virtual ~B()
     { }
     { }
 
 
-    void transition(const common::Bag < MyTime >& x, MyTime::type t)
+    void transition(const common::Bag < MyTime, SchedulerHandle >& x,
+                    MyTime::type t)
     {
     {
         common::Trace < MyTime >::trace()
         common::Trace < MyTime >::trace()
-            << common::TraceElement < MyTime >(get_name(), t,
-                                               common::DELTA_INT)
+            << common::TraceElement < MyTime >(
+                B < SchedulerHandle >::get_name(), t,
+                common::DELTA_INT)
             << "x = " << x.to_string();
             << "x = " << x.to_string();
         common::Trace < MyTime >::trace().flush();
         common::Trace < MyTime >::trace().flush();
     }
     }
@@ -119,22 +128,25 @@ public:
     {
     {
 
 
         common::Trace < MyTime >::trace()
         common::Trace < MyTime >::trace()
-            << common::TraceElement < MyTime >(get_name(), t,
-                                               common::START);
+            << common::TraceElement < MyTime >(
+                B < SchedulerHandle >::get_name(), t,
+                common::START);
         common::Trace < MyTime >::trace().flush();
         common::Trace < MyTime >::trace().flush();
 
 
         return 0;
         return 0;
     }
     }
 
 
-    common::Bag < MyTime > lambda(MyTime::type t) const
+    common::Bag < MyTime, SchedulerHandle > lambda(MyTime::type t) const
     {
     {
-        common::Bag < MyTime > msgs;
+        common::Bag < MyTime, SchedulerHandle > msgs;
 
 
-        msgs.push_back(common::ExternalEvent < MyTime >("out", 0.));
+        msgs.push_back(common::ExternalEvent < MyTime, SchedulerHandle >(
+                           "out", 0.));
 
 
         common::Trace < MyTime >::trace()
         common::Trace < MyTime >::trace()
-            << common::TraceElement < MyTime >(get_name(), t,
-                                               common::LAMBDA)
+            << common::TraceElement < MyTime >(
+                B < SchedulerHandle >::get_name(), t,
+                common::LAMBDA)
             << "messages = " << msgs.to_string();
             << "messages = " << msgs.to_string();
         common::Trace < MyTime >::trace().flush();
         common::Trace < MyTime >::trace().flush();
 
 

+ 14 - 6
src/tests/dtss/tests.cpp

@@ -24,6 +24,8 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
  */
 
 
+#include <common/scheduler/SchedulerHandle.hpp>
+
 #include <tests/dtss/graph_manager.hpp>
 #include <tests/dtss/graph_manager.hpp>
 #include <tests/dtss/models.hpp>
 #include <tests/dtss/models.hpp>
 
 
@@ -39,9 +41,12 @@ TEST_CASE("dtss/only_one", "run")
 
 
     paradevs::common::RootCoordinator <
     paradevs::common::RootCoordinator <
         MyTime, paradevs::dtss::Coordinator <
         MyTime, paradevs::dtss::Coordinator <
-            MyTime, Policy, OnlyOneGraphManager,
-            paradevs::dtss::Parameters < MyTime >,
-            paradevs::common::NoParameters >
+            MyTime,
+            Policy < paradevs::common::scheduler::NoSchedulerHandle >,
+            OnlyOneGraphManager <
+                paradevs::common::scheduler::NoSchedulerHandle >,
+            paradevs::common::scheduler::NoSchedulerHandle,
+            paradevs::dtss::Parameters < MyTime > >
         > rc(0, 10, "root",
         > rc(0, 10, "root",
              paradevs::dtss::Parameters < MyTime >(1),
              paradevs::dtss::Parameters < MyTime >(1),
              paradevs::common::NoParameters());
              paradevs::common::NoParameters());
@@ -69,9 +74,12 @@ TEST_CASE("dtss/two", "run")
 {
 {
     paradevs::common::RootCoordinator <
     paradevs::common::RootCoordinator <
         MyTime, paradevs::dtss::Coordinator <
         MyTime, paradevs::dtss::Coordinator <
-            MyTime, Policy, TwoGraphManager,
-            paradevs::dtss::Parameters < MyTime >,
-            paradevs::common::NoParameters >
+            MyTime,
+            Policy < paradevs::common::scheduler::NoSchedulerHandle >,
+            TwoGraphManager <
+                paradevs::common::scheduler::NoSchedulerHandle >,
+            paradevs::common::scheduler::NoSchedulerHandle,
+            paradevs::dtss::Parameters < MyTime > >
         > rc(0, 10, "root",
         > rc(0, 10, "root",
              paradevs::dtss::Parameters < MyTime >(1),
              paradevs::dtss::Parameters < MyTime >(1),
              paradevs::common::NoParameters());
              paradevs::common::NoParameters());

+ 166 - 98
src/tests/mixed/graph_manager.hpp

@@ -43,108 +43,144 @@
 
 
 namespace paradevs { namespace tests { namespace mixed {
 namespace paradevs { namespace tests { namespace mixed {
 
 
+struct SchedulerHandle;
+
+typedef typename paradevs::common::scheduler::HeapScheduler <
+    MyTime, SchedulerHandle >::type SchedulerType;
+
+struct SchedulerHandle
+{
+    SchedulerHandle()
+    { }
+
+    SchedulerHandle(const SchedulerType::handle_type& handle)
+        : _handle(handle)
+    { }
+
+    const SchedulerHandle& handle() const
+    { return *this; }
+
+    void handle(const SchedulerHandle& handle)
+    { _handle = handle._handle; }
+
+    SchedulerType::handle_type _handle;
+};
+
+template < class SchedulerHandle >
 struct LastBagPolicy
 struct LastBagPolicy
 {
 {
-    const common::Bag < MyTime >& bag() const
+    const common::Bag < MyTime, SchedulerHandle >& bag() const
     { return _bag; }
     { return _bag; }
 
 
-    virtual void operator()(typename MyTime::type /* t */,
-                            const common::ExternalEvent < MyTime >& event,
-                            typename MyTime::type /* tl */,
-                            typename MyTime::type /* tn */)
+    virtual void operator()(
+        typename MyTime::type /* t */,
+        const common::ExternalEvent < MyTime, SchedulerHandle >& 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 < MyTime > _bag;
+    common::Bag < MyTime, SchedulerHandle > _bag;
 };
 };
 
 
+template < class SchedulerHandle >
 struct IgnorePolicy
 struct IgnorePolicy
 {
 {
-    const common::Bag < MyTime >& bag() const
+    const common::Bag < MyTime, SchedulerHandle >& bag() const
     { return _bag; }
     { return _bag; }
 
 
-    virtual void operator()(typename MyTime::type /* t */,
-                            const common::ExternalEvent < MyTime >& /* event */,
-                            typename MyTime::type /* tl */,
-                            typename MyTime::type /* tn */)
+    virtual void operator()(
+        typename MyTime::type /* t */,
+        const common::ExternalEvent < MyTime, SchedulerHandle >& /* event */,
+        typename MyTime::type /* tl */,
+        typename MyTime::type /* tn */)
     { }
     { }
 
 
 private:
 private:
-    common::Bag < MyTime > _bag;
+    common::Bag < MyTime, SchedulerHandle > _bag;
 };
 };
 
 
+template < class SchedulerHandle >
 class S1GraphManager :
 class S1GraphManager :
-        public pdevs::GraphManager < MyTime, paradevs::common::NoParameters >
+        public pdevs::GraphManager < MyTime, SchedulerHandle,
+                                     paradevs::common::NoParameters >
 {
 {
 public:
 public:
-    S1GraphManager(common::Coordinator < MyTime >* coordinator,
+    S1GraphManager(common::Coordinator < MyTime, SchedulerHandle >* coordinator,
                    const paradevs::common::NoParameters& parameters) :
                    const paradevs::common::NoParameters& parameters) :
-        pdevs::GraphManager < MyTime,
+        pdevs::GraphManager < MyTime, SchedulerHandle,
                               paradevs::common::NoParameters >(
                               paradevs::common::NoParameters >(
                                   coordinator, parameters),
                                   coordinator, parameters),
-        a("a1", NoParameters()), b("b1", NoParameters())
+        a("a1", paradevs::common::NoParameters()),
+        b("b1", paradevs::common::NoParameters())
     {
     {
-        add_child(&a);
-        add_child(&b);
+        S1GraphManager < SchedulerHandle >::add_child(&a);
+        S1GraphManager < SchedulerHandle >::add_child(&b);
 
 
         a.add_out_port("out");
         a.add_out_port("out");
         b.add_in_port("in");
         b.add_in_port("in");
         b.add_out_port("out");
         b.add_out_port("out");
         coordinator->add_out_port("out");
         coordinator->add_out_port("out");
 
 
-        add_link(&a, "out", &b, "in");
-        add_link(&b, "out", coordinator, "out");
+        S1GraphManager < SchedulerHandle >::add_link(&a, "out",
+                                                     &b, "in");
+        S1GraphManager < SchedulerHandle >::add_link(&b, "out",
+                                                     coordinator, "out");
     }
     }
 
 
     virtual ~S1GraphManager()
     virtual ~S1GraphManager()
     { }
     { }
 
 
 private:
 private:
-    pdevs::Simulator < MyTime, A1, NoParameters > a;
-    pdevs::Simulator < MyTime, B1, NoParameters > b;
+    pdevs::Simulator < MyTime, A1 < SchedulerHandle >, SchedulerHandle,
+                       paradevs::common::NoParameters > a;
+    pdevs::Simulator < MyTime, B1 < SchedulerHandle >, SchedulerHandle,
+                       paradevs::common::NoParameters > b;
 };
 };
 
 
-class S2GraphManager :
-        public dtss::GraphManager < MyTime, paradevs::common::NoParameters >
+template < class SchedulerHandle >
+class S2GraphManager : public dtss::GraphManager < MyTime, SchedulerHandle >
 {
 {
 public:
 public:
-    S2GraphManager(common::Coordinator < MyTime >* coordinator,
+    S2GraphManager(common::Coordinator < MyTime, SchedulerHandle >* coordinator,
                    const paradevs::common::NoParameters& parameters) :
                    const paradevs::common::NoParameters& parameters) :
-        dtss::GraphManager < MyTime,
-                             paradevs::common::NoParameters >(
-                                 coordinator, parameters),
-        a("a2", 20, NoParameters()), b("b2", 20, NoParameters())
+        dtss::GraphManager < MyTime, SchedulerHandle >(coordinator, parameters),
+        a("a2", 20, paradevs::common::NoParameters()),
+        b("b2", 20, paradevs::common::NoParameters())
     {
     {
-        add_child(&a);
-        add_child(&b);
+        S2GraphManager < SchedulerHandle >::add_child(&a);
+        S2GraphManager < SchedulerHandle >::add_child(&b);
 
 
         a.add_in_port("in");
         a.add_in_port("in");
         a.add_out_port("out");
         a.add_out_port("out");
         b.add_in_port("in");
         b.add_in_port("in");
         coordinator->add_in_port("in");
         coordinator->add_in_port("in");
 
 
-        add_link(&a, "out", &b, "in");
-        add_link(coordinator, "in", &a, "in");
+        S2GraphManager < SchedulerHandle >::add_link(&a, "out", &b, "in");
+        S2GraphManager < SchedulerHandle >::add_link(coordinator, "in",
+                                                     &a, "in");
     }
     }
 
 
     virtual ~S2GraphManager()
     virtual ~S2GraphManager()
     { }
     { }
 
 
 private:
 private:
-    dtss::Simulator < MyTime, A2, NoParameters > a;
-    dtss::Simulator < MyTime, B2, NoParameters > b;
+    dtss::Simulator < MyTime, A2 < SchedulerHandle >, SchedulerHandle > a;
+    dtss::Simulator < MyTime, B2 < SchedulerHandle >, SchedulerHandle > b;
 };
 };
 
 
 class RootGraphManager :
 class RootGraphManager :
-    public pdevs::GraphManager < MyTime, paradevs::common::NoParameters >
+        public pdevs::GraphManager < MyTime, SchedulerHandle,
+                                     paradevs::common::NoParameters >
 {
 {
 public:
 public:
-    RootGraphManager(common::Coordinator < MyTime >* coordinator,
+    RootGraphManager(common::Coordinator < MyTime,
+                                           SchedulerHandle >* coordinator,
                      const paradevs::common::NoParameters& parameters) :
                      const paradevs::common::NoParameters& parameters) :
-        pdevs::GraphManager < MyTime,
+        pdevs::GraphManager < MyTime, SchedulerHandle,
                               paradevs::common::NoParameters >(
                               paradevs::common::NoParameters >(
                                   coordinator, parameters),
                                   coordinator, parameters),
         S1("S1", paradevs::common::NoParameters(),
         S1("S1", paradevs::common::NoParameters(),
@@ -161,27 +197,29 @@ public:
     { }
     { }
 
 
 private:
 private:
-    pdevs::Coordinator < MyTime,
-                         paradevs::common::scheduler::HeapScheduler <
-                             MyTime >,
-                         S1GraphManager,
-                         paradevs::common::NoParameters,
-                         paradevs::common::NoParameters > S1;
-    dtss::Coordinator < MyTime,
-                        LastBagPolicy,
-                        S2GraphManager,
-                        paradevs::dtss::Parameters < MyTime >,
-                        paradevs::common::NoParameters > S2;
+    paradevs::pdevs::Coordinator <
+        MyTime,
+        SchedulerType,
+        SchedulerHandle,
+        S1GraphManager < SchedulerHandle > > S1;
+    paradevs::dtss::Coordinator <
+        MyTime,
+        LastBagPolicy < SchedulerHandle >,
+        S2GraphManager < SchedulerHandle >,
+        SchedulerHandle,
+        paradevs::dtss::Parameters < MyTime > > S2;
 };
 };
 
 
-template < int size >
+template < int size, class SchedulerHandle >
 class LinearGraphManager :
 class LinearGraphManager :
-    public pdevs::GraphManager < MyTime, paradevs::common::NoParameters >
+        public pdevs::GraphManager < MyTime, SchedulerHandle,
+                                     paradevs::common::NoParameters >
 {
 {
 public:
 public:
-    LinearGraphManager(common::Coordinator < MyTime >* coordinator,
+    LinearGraphManager(common::Coordinator < MyTime,
+                                             SchedulerHandle >* coordinator,
                        const paradevs::common::NoParameters& parameters) :
                        const paradevs::common::NoParameters& parameters) :
-        pdevs::GraphManager < MyTime,
+        pdevs::GraphManager < MyTime, SchedulerHandle,
                               paradevs::common::NoParameters >(
                               paradevs::common::NoParameters >(
                                   coordinator, parameters)
                                   coordinator, parameters)
     {
     {
@@ -190,17 +228,24 @@ public:
 
 
             ss << "a" << i;
             ss << "a" << i;
             _models.push_back(
             _models.push_back(
-                new pdevs::Simulator < MyTime, Beep, NoParameters >(
-                    ss.str(), NoParameters()));
+                new pdevs::Simulator < MyTime, Beep < SchedulerHandle >,
+                                       SchedulerHandle,
+                                       paradevs::common::NoParameters >(
+                                           ss.str(),
+                                           paradevs::common::NoParameters()));
         }
         }
         for (unsigned int i = 0; i < size; ++i) {
         for (unsigned int i = 0; i < size; ++i) {
-            add_child(_models[i]);
+            LinearGraphManager < size, SchedulerHandle >::add_child(_models[i]);
 
 
             _models[i]->add_in_port("in");
             _models[i]->add_in_port("in");
             _models[i]->add_out_port("out");
             _models[i]->add_out_port("out");
         }
         }
         for (unsigned int i = 0; i < size - 1; ++i) {
         for (unsigned int i = 0; i < size - 1; ++i) {
-            add_link(_models[i], "out", _models[i + 1], "in");
+            LinearGraphManager < size,
+                                 SchedulerHandle >::add_link(_models[i],
+                                                             "out",
+                                                             _models[i + 1],
+                                                             "in");
         }
         }
     }
     }
 
 
@@ -212,16 +257,21 @@ public:
     }
     }
 
 
 private:
 private:
-    std::vector < pdevs::Simulator < MyTime, Beep, NoParameters >* > _models;
+    std::vector <
+    pdevs::Simulator < MyTime, Beep < SchedulerHandle >, SchedulerHandle,
+                       paradevs::common::NoParameters >* > _models;
 };
 };
 
 
+template < class SchedulerHandle >
 class Linear2GraphManager :
 class Linear2GraphManager :
-    public pdevs::GraphManager < MyTime, paradevs::common::NoParameters >
+        public pdevs::GraphManager < MyTime, SchedulerHandle,
+                                     paradevs::common::NoParameters >
 {
 {
 public:
 public:
-    Linear2GraphManager(common::Coordinator < MyTime >* coordinator,
+    Linear2GraphManager(common::Coordinator < MyTime,
+                                              SchedulerHandle >* coordinator,
                         const paradevs::common::NoParameters& parameters) :
                         const paradevs::common::NoParameters& parameters) :
-        pdevs::GraphManager < MyTime,
+        pdevs::GraphManager < MyTime, SchedulerHandle,
                               paradevs::common::NoParameters >(
                               paradevs::common::NoParameters >(
                                   coordinator, parameters)
                                   coordinator, parameters)
     {
     {
@@ -230,24 +280,32 @@ public:
 
 
             ss << "a" << i;
             ss << "a" << i;
             _models.push_back(
             _models.push_back(
-                new pdevs::Simulator < MyTime, Beep, NoParameters >(
-                    ss.str(), NoParameters()));
+                new pdevs::Simulator < MyTime,
+                                       Beep < SchedulerHandle >,
+                                       SchedulerHandle,
+                                       paradevs::common::NoParameters >(
+                                           ss.str(),
+                                           paradevs::common::NoParameters()));
         }
         }
         for (unsigned int i = 0; i < 100; ++i) {
         for (unsigned int i = 0; i < 100; ++i) {
-            add_child(_models[i]);
+            Linear2GraphManager < SchedulerHandle >::add_child(_models[i]);
 
 
             _models[i]->add_in_port("in");
             _models[i]->add_in_port("in");
             _models[i]->add_out_port("out");
             _models[i]->add_out_port("out");
         }
         }
         for (unsigned int i = 0; i < 99; ++i) {
         for (unsigned int i = 0; i < 99; ++i) {
-            add_link(_models[i], "out", _models[i + 1], "in");
+            Linear2GraphManager < SchedulerHandle >::add_link(_models[i], "out",
+                                                              _models[i + 1],
+                                                              "in");
         }
         }
 
 
         coordinator->add_in_port("in");
         coordinator->add_in_port("in");
         coordinator->add_out_port("out");
         coordinator->add_out_port("out");
 
 
-        add_link(coordinator, "in", _models[0], "in");
-        add_link(_models[49], "out", coordinator, "out");
+        Linear2GraphManager < SchedulerHandle >::add_link(coordinator, "in",
+                                                          _models[0], "in");
+        Linear2GraphManager < SchedulerHandle >::add_link(_models[49], "out",
+                                                          coordinator, "out");
     }
     }
 
 
     virtual ~Linear2GraphManager()
     virtual ~Linear2GraphManager()
@@ -258,16 +316,21 @@ public:
     }
     }
 
 
 private:
 private:
-    std::vector < pdevs::Simulator < MyTime, Beep, NoParameters >* > _models;
+    std::vector <
+        pdevs::Simulator < MyTime, Beep < SchedulerHandle >,
+                           SchedulerHandle,
+                           paradevs::common::NoParameters >* > _models;
 };
 };
 
 
 class Root2GraphManager :
 class Root2GraphManager :
-    public pdevs::GraphManager < MyTime, paradevs::common::NoParameters >
+        public pdevs::GraphManager < MyTime, SchedulerHandle,
+                                     paradevs::common::NoParameters >
 {
 {
 public:
 public:
-    Root2GraphManager(common::Coordinator < MyTime >* coordinator,
+    Root2GraphManager(common::Coordinator < MyTime,
+                                            SchedulerHandle >* coordinator,
                       const paradevs::common::NoParameters& parameters) :
                       const paradevs::common::NoParameters& parameters) :
-        pdevs::GraphManager < MyTime,
+        pdevs::GraphManager < MyTime, SchedulerHandle,
                               paradevs::common::NoParameters >(
                               paradevs::common::NoParameters >(
                                   coordinator, parameters),
                                   coordinator, parameters),
         S1("S1", paradevs::common::NoParameters(),
         S1("S1", paradevs::common::NoParameters(),
@@ -284,27 +347,32 @@ public:
     { }
     { }
 
 
 private:
 private:
-    pdevs::Coordinator < MyTime,
-                         paradevs::common::scheduler::HeapScheduler <
-                             MyTime >,
-                         Linear2GraphManager,
-                         paradevs::common::NoParameters,
-                         paradevs::common::NoParameters > S1;
-    pdevs::Coordinator < MyTime,
-                         paradevs::common::scheduler::HeapScheduler <
-                             MyTime >,
-                         Linear2GraphManager,
-                         paradevs::common::NoParameters,
-                         paradevs::common::NoParameters > S2;
+    paradevs::pdevs::Coordinator <
+        MyTime,
+        SchedulerType,
+        SchedulerHandle,
+        Linear2GraphManager < SchedulerHandle > > S1;
+    paradevs::pdevs::Coordinator <
+        MyTime,
+        SchedulerType,
+        SchedulerHandle,
+        Linear2GraphManager < SchedulerHandle > > S2;
 };
 };
 
 
 class Root3GraphManager :
 class Root3GraphManager :
-    public pdevs::GraphManager < MyTime, paradevs::common::NoParameters >
+        public pdevs::GraphManager <
+            MyTime,
+            paradevs::common::scheduler::NoSchedulerHandle,
+            paradevs::common::NoParameters >
 {
 {
 public:
 public:
-    Root3GraphManager(common::Coordinator < MyTime >* coordinator,
-                      const paradevs::common::NoParameters& parameters) :
+    Root3GraphManager(
+        common::Coordinator <
+            MyTime,
+            paradevs::common::scheduler::NoSchedulerHandle >* coordinator,
+        const paradevs::common::NoParameters& parameters) :
         pdevs::GraphManager < MyTime,
         pdevs::GraphManager < MyTime,
+                              paradevs::common::scheduler::NoSchedulerHandle,
                               paradevs::common::NoParameters >(
                               paradevs::common::NoParameters >(
                                   coordinator, parameters),
                                   coordinator, parameters),
         S1("S1", paradevs::common::NoParameters(),
         S1("S1", paradevs::common::NoParameters(),
@@ -321,18 +389,18 @@ public:
     { }
     { }
 
 
 private:
 private:
-    pdevs::Coordinator < MyTime,
-                         paradevs::common::scheduler::HeapScheduler <
-                             MyTime >,
-                         Linear2GraphManager,
-                         paradevs::common::NoParameters,
-                         paradevs::common::NoParameters > S1;
-    pdevs::Coordinator < MyTime,
-                         paradevs::common::scheduler::HeapScheduler <
-                             MyTime >,
-                         Linear2GraphManager,
-                         paradevs::common::NoParameters,
-                         paradevs::common::NoParameters > S2;
+    pdevs::Coordinator <
+        MyTime,
+        paradevs::common::scheduler::VectorScheduler < MyTime >,
+        paradevs::common::scheduler::NoSchedulerHandle,
+        Linear2GraphManager < paradevs::common::scheduler::NoSchedulerHandle >
+    > S1;
+    pdevs::Coordinator <
+        MyTime,
+        paradevs::common::scheduler::VectorScheduler < MyTime >,
+        paradevs::common::scheduler::NoSchedulerHandle,
+        Linear2GraphManager < paradevs::common::scheduler::NoSchedulerHandle >
+    > S2;
 };
 };
 
 
 } } } // namespace paradevs tests mixed
 } } } // namespace paradevs tests mixed

+ 75 - 44
src/tests/mixed/models.hpp

@@ -48,17 +48,16 @@ struct Limits
 
 
 typedef paradevs::common::Time < double, Limits < double > > MyTime;
 typedef paradevs::common::Time < double, Limits < double > > MyTime;
 
 
-struct NoParameters
-{
-    NoParameters()
-    { }
-};
-
-class A1 : public paradevs::pdevs::Dynamics < MyTime, NoParameters >
+template < class SchedulerHandle>
+class A1 : public paradevs::pdevs::Dynamics < MyTime, SchedulerHandle,
+                                              paradevs::common::NoParameters >
 {
 {
 public:
 public:
-    A1(const std::string& name, const NoParameters& parameters) :
-        paradevs::pdevs::Dynamics < MyTime, NoParameters >(name, parameters)
+    A1(const std::string& name,
+       const paradevs::common::NoParameters& parameters) :
+        paradevs::pdevs::Dynamics < MyTime, SchedulerHandle,
+                                    paradevs::common::NoParameters >(
+                                        name, parameters)
     { }
     { }
     virtual ~A1()
     virtual ~A1()
     { }
     { }
@@ -83,7 +82,7 @@ public:
     }
     }
 
 
     void dext(typename MyTime::type t, typename MyTime::type /* e */,
     void dext(typename MyTime::type t, typename MyTime::type /* e */,
-              const common::Bag < MyTime >& msgs)
+              const common::Bag < MyTime, SchedulerHandle >& msgs)
     {
     {
 
 
 #ifndef WITH_TRACE
 #ifndef WITH_TRACE
@@ -103,7 +102,7 @@ public:
     }
     }
 
 
     void dconf(typename MyTime::type t, typename MyTime::type /* e */,
     void dconf(typename MyTime::type t, typename MyTime::type /* e */,
-               const common::Bag < MyTime >& msgs)
+               const common::Bag < MyTime, SchedulerHandle >& msgs)
     {
     {
 
 
 #ifndef WITH_TRACE
 #ifndef WITH_TRACE
@@ -156,16 +155,18 @@ public:
         }
         }
     }
     }
 
 
-    common::Bag < MyTime > lambda(typename MyTime::type t) const
+    common::Bag < MyTime, SchedulerHandle > lambda(
+        typename MyTime::type t) const
     {
     {
 
 
 #ifndef WITH_TRACE
 #ifndef WITH_TRACE
         (void)t;
         (void)t;
 #endif
 #endif
 
 
-        common::Bag < MyTime > msgs;
+        common::Bag < MyTime, SchedulerHandle > msgs;
 
 
-        msgs.push_back(common::ExternalEvent < MyTime >("out", 0.));
+        msgs.push_back(common::ExternalEvent < MyTime, SchedulerHandle >(
+                           "out", 0.));
 
 
 #ifdef WITH_TRACE
 #ifdef WITH_TRACE
         common::Trace < MyTime >::trace()
         common::Trace < MyTime >::trace()
@@ -184,11 +185,16 @@ private:
     Phase _phase;
     Phase _phase;
 };
 };
 
 
-class B1 : public paradevs::pdevs::Dynamics < MyTime, NoParameters >
+template < class SchedulerHandle>
+class B1 : public paradevs::pdevs::Dynamics < MyTime, SchedulerHandle,
+                                              paradevs::common::NoParameters >
 {
 {
 public:
 public:
-    B1(const std::string& name, const NoParameters& parameters) :
-        paradevs::pdevs::Dynamics < MyTime, NoParameters >(name, parameters)
+    B1(const std::string& name,
+       const paradevs::common::NoParameters& parameters) :
+        paradevs::pdevs::Dynamics < MyTime, SchedulerHandle,
+                                    paradevs::common::NoParameters >(
+                                        name, parameters)
     { }
     { }
     virtual ~B1()
     virtual ~B1()
     { }
     { }
@@ -213,7 +219,7 @@ public:
     }
     }
 
 
     void dext(typename MyTime::type t, typename MyTime::type /* e */,
     void dext(typename MyTime::type t, typename MyTime::type /* e */,
-              const common::Bag < MyTime >& msgs)
+              const common::Bag < MyTime, SchedulerHandle >& msgs)
     {
     {
 
 
 #ifndef WITH_TRACE
 #ifndef WITH_TRACE
@@ -233,7 +239,7 @@ public:
     }
     }
 
 
     void dconf(typename MyTime::type t, typename MyTime::type /* e */,
     void dconf(typename MyTime::type t, typename MyTime::type /* e */,
-               const common::Bag < MyTime >& msgs)
+               const common::Bag < MyTime, SchedulerHandle >& msgs)
     {
     {
 
 
 #ifndef WITH_TRACE
 #ifndef WITH_TRACE
@@ -290,15 +296,17 @@ public:
         }
         }
     }
     }
 
 
-    common::Bag < MyTime > lambda(typename MyTime::type t) const
+    common::Bag < MyTime, SchedulerHandle > lambda(
+        typename MyTime::type t) const
     {
     {
 
 
 #ifndef WITH_TRACE
 #ifndef WITH_TRACE
         (void)t;
         (void)t;
 #endif
 #endif
-        common::Bag < MyTime > msgs;
+        common::Bag < MyTime, SchedulerHandle > msgs;
 
 
-        msgs.push_back(common::ExternalEvent < MyTime >("out", t));
+        msgs.push_back(common::ExternalEvent < MyTime, SchedulerHandle >(
+                           "out", t));
 
 
 #ifdef WITH_TRACE
 #ifdef WITH_TRACE
         common::Trace < MyTime >::trace()
         common::Trace < MyTime >::trace()
@@ -317,16 +325,22 @@ private:
     Phase _phase;
     Phase _phase;
 };
 };
 
 
-class A2 : public paradevs::dtss::Dynamics < MyTime, NoParameters >
+template < class SchedulerHandle >
+class A2 : public paradevs::dtss::Dynamics < MyTime, SchedulerHandle >
 {
 {
 public:
 public:
-    A2(const std::string& name, const NoParameters& parameters) :
-        paradevs::dtss::Dynamics < MyTime, NoParameters >(name, parameters)
+    A2(const std::string& name,
+       const paradevs::common::NoParameters& parameters) :
+        paradevs::dtss::Dynamics <
+           MyTime, SchedulerHandle,
+           paradevs::common::NoParameters >(name, parameters)
     { }
     { }
     virtual ~A2()
     virtual ~A2()
     { }
     { }
 
 
-    void transition(const common::Bag < MyTime >& x, typename MyTime::type t)
+    void transition(
+        const common::Bag < MyTime, SchedulerHandle >& x,
+            typename MyTime::type t)
     {
     {
 
 
 #ifndef WITH_TRACE
 #ifndef WITH_TRACE
@@ -361,15 +375,17 @@ public:
         return 0;
         return 0;
     }
     }
 
 
-    common::Bag < MyTime > lambda(typename MyTime::type t) const
+    common::Bag < MyTime, SchedulerHandle > lambda(
+        typename MyTime::type t) const
     {
     {
 
 
 #ifndef WITH_TRACE
 #ifndef WITH_TRACE
         (void)t;
         (void)t;
 #endif
 #endif
-        common::Bag < MyTime > msgs;
+        common::Bag < MyTime, SchedulerHandle > msgs;
 
 
-        msgs.push_back(common::ExternalEvent < MyTime >("out", 0.));
+        msgs.push_back(
+            common::ExternalEvent < MyTime, SchedulerHandle >( "out", 0.));
 
 
 #ifdef WITH_TRACE
 #ifdef WITH_TRACE
         common::Trace < MyTime >::trace()
         common::Trace < MyTime >::trace()
@@ -383,16 +399,22 @@ public:
     }
     }
 };
 };
 
 
-class B2 : public paradevs::dtss::Dynamics < MyTime, NoParameters >
+template < class SchedulerHandle >
+class B2 : public paradevs::dtss::Dynamics < MyTime, SchedulerHandle >
 {
 {
 public:
 public:
-    B2(const std::string& name, const NoParameters& parameters) :
-        paradevs::dtss::Dynamics < MyTime, NoParameters >(name, parameters)
+    B2(const std::string& name,
+       const paradevs::common::NoParameters& parameters) :
+        paradevs::dtss::Dynamics <
+           MyTime, SchedulerHandle,
+           paradevs::common::NoParameters >(name, parameters)
     { }
     { }
     virtual ~B2()
     virtual ~B2()
     { }
     { }
 
 
-    void transition(const common::Bag < MyTime >& x, typename MyTime::type t)
+    void transition(
+        const common::Bag < MyTime, SchedulerHandle >& x,
+            typename MyTime::type t)
     {
     {
 
 
 #ifndef WITH_TRACE
 #ifndef WITH_TRACE
@@ -427,15 +449,17 @@ public:
         return 0;
         return 0;
     }
     }
 
 
-    common::Bag < MyTime > lambda(typename MyTime::type t) const
+    common::Bag < MyTime, SchedulerHandle > lambda(
+        typename MyTime::type t) const
     {
     {
 
 
 #ifndef WITH_TRACE
 #ifndef WITH_TRACE
         (void)t;
         (void)t;
 #endif
 #endif
-        common::Bag < MyTime > msgs;
+        common::Bag < MyTime, SchedulerHandle > msgs;
 
 
-        msgs.push_back(common::ExternalEvent < MyTime >("out", 0.));
+        msgs.push_back(
+            common::ExternalEvent < MyTime, SchedulerHandle >("out", 0.));
 
 
 #ifdef WITH_TRACE
 #ifdef WITH_TRACE
         common::Trace < MyTime >::trace()
         common::Trace < MyTime >::trace()
@@ -449,11 +473,16 @@ public:
     }
     }
 };
 };
 
 
-class Beep : public paradevs::pdevs::Dynamics < MyTime, NoParameters >
+template < class SchedulerHandle>
+class Beep : public paradevs::pdevs::Dynamics < MyTime, SchedulerHandle,
+                                                paradevs::common::NoParameters >
 {
 {
 public:
 public:
-    Beep(const std::string& name, const NoParameters& parameters) :
-        paradevs::pdevs::Dynamics < MyTime, NoParameters >(name, parameters)
+    Beep(const std::string& name,
+         const paradevs::common::NoParameters& parameters) :
+        paradevs::pdevs::Dynamics < MyTime, SchedulerHandle,
+                                    paradevs::common::NoParameters >(name,
+                                                                     parameters)
     { }
     { }
     virtual ~Beep()
     virtual ~Beep()
     { }
     { }
@@ -478,7 +507,7 @@ public:
     }
     }
 
 
     void dext(typename MyTime::type t, typename MyTime::type /* e */,
     void dext(typename MyTime::type t, typename MyTime::type /* e */,
-              const common::Bag < MyTime >& msgs)
+              const common::Bag < MyTime, SchedulerHandle >& msgs)
     {
     {
 
 
 #ifndef WITH_TRACE
 #ifndef WITH_TRACE
@@ -498,7 +527,7 @@ public:
     }
     }
 
 
     void dconf(typename MyTime::type t, typename MyTime::type /* e */,
     void dconf(typename MyTime::type t, typename MyTime::type /* e */,
-               const common::Bag < MyTime >& msgs)
+               const common::Bag < MyTime, SchedulerHandle >& msgs)
     {
     {
 
 
 #ifndef WITH_TRACE
 #ifndef WITH_TRACE
@@ -555,15 +584,17 @@ public:
         }
         }
     }
     }
 
 
-    common::Bag < MyTime > lambda(typename MyTime::type t) const
+    common::Bag < MyTime, SchedulerHandle > lambda(
+        typename MyTime::type t) const
     {
     {
 
 
 #ifndef WITH_TRACE
 #ifndef WITH_TRACE
         (void)t;
         (void)t;
 #endif
 #endif
-        common::Bag < MyTime > msgs;
+        common::Bag < MyTime, SchedulerHandle > msgs;
 
 
-        msgs.push_back(common::ExternalEvent < MyTime >("out", 0.));
+        msgs.push_back(common::ExternalEvent < MyTime, SchedulerHandle >(
+                           "out", 0.));
 
 
 #ifdef WITH_TRACE
 #ifdef WITH_TRACE
         common::Trace < MyTime >::trace()
         common::Trace < MyTime >::trace()

+ 8 - 3
src/tests/mixed/tests.cpp

@@ -37,9 +37,14 @@ using namespace paradevs::tests::mixed;
 TEST_CASE("mixed/hierachical", "run")
 TEST_CASE("mixed/hierachical", "run")
 {
 {
     paradevs::common::RootCoordinator <
     paradevs::common::RootCoordinator <
-        MyTime, paradevs::pdevs::Coordinator <
-            MyTime, paradevs::common::scheduler::HeapScheduler <
-                MyTime >, RootGraphManager > > rc(0, 100, "root");
+        MyTime,
+        paradevs::pdevs::Coordinator <
+            MyTime,
+            paradevs::common::scheduler::HeapScheduler <
+                MyTime, SchedulerHandle >,
+            SchedulerHandle,
+            RootGraphManager >
+        > rc(0, 100, "root");
 
 
     paradevs::common::Trace < MyTime >::trace().clear();
     paradevs::common::Trace < MyTime >::trace().clear();
     rc.run();
     rc.run();

+ 97 - 46
src/tests/pdevs/graph_manager.hpp

@@ -30,7 +30,6 @@
 #include <tests/pdevs/models.hpp>
 #include <tests/pdevs/models.hpp>
 
 
 #include <common/scheduler/HeapScheduler.hpp>
 #include <common/scheduler/HeapScheduler.hpp>
-#include <common/scheduler/VectorScheduler.hpp>
 #include <common/Trace.hpp>
 #include <common/Trace.hpp>
 
 
 #include <pdevs/Coordinator.hpp>
 #include <pdevs/Coordinator.hpp>
@@ -39,71 +38,106 @@
 
 
 namespace paradevs { namespace tests { namespace pdevs {
 namespace paradevs { namespace tests { namespace pdevs {
 
 
+struct SchedulerHandle;
+
+typedef typename paradevs::common::scheduler::HeapScheduler <
+    MyTime, SchedulerHandle >::type SchedulerType;
+
+struct SchedulerHandle
+{
+    SchedulerHandle()
+    { }
+
+    SchedulerHandle(const SchedulerType::handle_type& handle)
+        : _handle(handle)
+    { }
+
+    const SchedulerHandle& handle() const
+    { return *this; }
+
+    void handle(const SchedulerHandle& handle)
+    { _handle = handle._handle; }
+
+    SchedulerType::handle_type _handle;
+};
+
+template < class SchedulerHandle >
 class S1GraphManager :
 class S1GraphManager :
-        public paradevs::pdevs::GraphManager < MyTime >
+        public paradevs::pdevs::GraphManager < MyTime, SchedulerHandle >
 {
 {
 public:
 public:
-    S1GraphManager(common::Coordinator < MyTime >* coordinator,
+    S1GraphManager(common::Coordinator < MyTime, SchedulerHandle >* coordinator,
                    const paradevs::common::NoParameters& parameters) :
                    const paradevs::common::NoParameters& parameters) :
-        paradevs::pdevs::GraphManager < MyTime >(coordinator, parameters),
+        paradevs::pdevs::GraphManager < MyTime, SchedulerHandle >(coordinator,
+                                                                  parameters),
         a("a1", common::NoParameters()), b("b1", common::NoParameters())
         a("a1", common::NoParameters()), b("b1", common::NoParameters())
     {
     {
-        add_child(&a);
-        add_child(&b);
+        S1GraphManager < SchedulerHandle >::add_child(&a);
+        S1GraphManager < SchedulerHandle >::add_child(&b);
 
 
         a.add_out_port("out");
         a.add_out_port("out");
         b.add_in_port("in");
         b.add_in_port("in");
         b.add_out_port("out");
         b.add_out_port("out");
         coordinator->add_out_port("out");
         coordinator->add_out_port("out");
 
 
-        add_link(&a, "out", &b, "in");
-        add_link(&b, "out", coordinator, "out");
+        S1GraphManager < SchedulerHandle >::add_link(&a, "out", &b, "in");
+        S1GraphManager < SchedulerHandle >::add_link(&b, "out",
+                                                     coordinator, "out");
     }
     }
 
 
     virtual ~S1GraphManager()
     virtual ~S1GraphManager()
     { }
     { }
 
 
 private:
 private:
-    paradevs::pdevs::Simulator < MyTime, A > a;
-    paradevs::pdevs::Simulator < MyTime, B > b;
+    paradevs::pdevs::Simulator < MyTime, A < SchedulerHandle >,
+                                 SchedulerHandle > a;
+    paradevs::pdevs::Simulator < MyTime, B < SchedulerHandle >,
+                                 SchedulerHandle > b;
 };
 };
 
 
+template < class SchedulerHandle >
 class S2GraphManager :
 class S2GraphManager :
-        public paradevs::pdevs::GraphManager < MyTime >
+        public paradevs::pdevs::GraphManager < MyTime, SchedulerHandle >
 {
 {
 public:
 public:
-    S2GraphManager(common::Coordinator < MyTime >* coordinator,
+    S2GraphManager(common::Coordinator < MyTime, SchedulerHandle >* coordinator,
                    const paradevs::common::NoParameters& parameters) :
                    const paradevs::common::NoParameters& parameters) :
-        paradevs::pdevs::GraphManager < MyTime >(coordinator, parameters),
+        paradevs::pdevs::GraphManager < MyTime, SchedulerHandle >(coordinator,
+                                                                  parameters),
         a("a2", common::NoParameters()), b("b2", common::NoParameters())
         a("a2", common::NoParameters()), b("b2", common::NoParameters())
     {
     {
-        add_child(&a);
-        add_child(&b);
+        S2GraphManager < SchedulerHandle >::add_child(&a);
+        S2GraphManager < SchedulerHandle >::add_child(&b);
 
 
         a.add_in_port("in");
         a.add_in_port("in");
         a.add_out_port("out");
         a.add_out_port("out");
         b.add_in_port("in");
         b.add_in_port("in");
         coordinator->add_in_port("in");
         coordinator->add_in_port("in");
 
 
-        add_link(&a, "out", &b, "in");
-        add_link(coordinator, "in", &a, "in");
+        S2GraphManager < SchedulerHandle >::add_link(&a, "out", &b, "in");
+        S2GraphManager < SchedulerHandle >::add_link(coordinator, "in",
+                                                     &a, "in");
     }
     }
 
 
     virtual ~S2GraphManager()
     virtual ~S2GraphManager()
     { }
     { }
 
 
 private:
 private:
-    paradevs::pdevs::Simulator < MyTime, A > a;
-    paradevs::pdevs::Simulator < MyTime, B > b;
+    paradevs::pdevs::Simulator < MyTime, A < SchedulerHandle >,
+                                 SchedulerHandle > a;
+    paradevs::pdevs::Simulator < MyTime, B < SchedulerHandle >,
+                                 SchedulerHandle > b;
 };
 };
 
 
 class RootGraphManager :
 class RootGraphManager :
-        public paradevs::pdevs::GraphManager < MyTime >
+        public paradevs::pdevs::GraphManager < MyTime, SchedulerHandle >
 {
 {
 public:
 public:
-    RootGraphManager(common::Coordinator < MyTime >* coordinator,
-                     const paradevs::common::NoParameters& parameters) :
-        paradevs::pdevs::GraphManager < MyTime >(coordinator, parameters),
+    RootGraphManager(
+        common::Coordinator < MyTime, SchedulerHandle >* coordinator,
+        const paradevs::common::NoParameters& parameters) :
+        paradevs::pdevs::GraphManager < MyTime, SchedulerHandle >(
+                                            coordinator, parameters),
         S1("S1", paradevs::common::NoParameters(),
         S1("S1", paradevs::common::NoParameters(),
            paradevs::common::NoParameters()),
            paradevs::common::NoParameters()),
         S2("S2", paradevs::common::NoParameters(),
         S2("S2", paradevs::common::NoParameters(),
@@ -120,65 +154,82 @@ public:
 
 
 private:
 private:
     paradevs::pdevs::Coordinator <
     paradevs::pdevs::Coordinator <
-    MyTime, paradevs::common::scheduler::HeapScheduler < MyTime >,
-    S1GraphManager > S1;
+        MyTime,
+        SchedulerType,
+        SchedulerHandle,
+        S1GraphManager < SchedulerHandle > > S1;
     paradevs::pdevs::Coordinator <
     paradevs::pdevs::Coordinator <
-        MyTime, paradevs::common::scheduler::HeapScheduler < MyTime >,
-        S2GraphManager > S2;
+        MyTime,
+        SchedulerType,
+        SchedulerHandle,
+        S2GraphManager < SchedulerHandle > > S2;
 };
 };
 
 
+template < class SchedulerHandle >
 class OnlyOneGraphManager :
 class OnlyOneGraphManager :
-        public paradevs::pdevs::GraphManager < MyTime >
+        public paradevs::pdevs::GraphManager < MyTime, SchedulerHandle >
 {
 {
 public:
 public:
-    OnlyOneGraphManager(common::Coordinator < MyTime >* coordinator,
+    OnlyOneGraphManager(common::Coordinator < MyTime,
+                                              SchedulerHandle >* coordinator,
                         const paradevs::common::NoParameters& parameters) :
                         const paradevs::common::NoParameters& parameters) :
-        paradevs::pdevs::GraphManager < MyTime >(coordinator, parameters),
+        paradevs::pdevs::GraphManager < MyTime, SchedulerHandle >(coordinator,
+                                                                  parameters),
         a("a", common::NoParameters())
         a("a", common::NoParameters())
     {
     {
-        add_child(&a);
+        OnlyOneGraphManager < SchedulerHandle >::add_child(&a);
     }
     }
 
 
     virtual ~OnlyOneGraphManager()
     virtual ~OnlyOneGraphManager()
     { }
     { }
 
 
 private:
 private:
-    paradevs::pdevs::Simulator < MyTime, A > a;
+    paradevs::pdevs::Simulator < MyTime, A < SchedulerHandle >,
+                                 SchedulerHandle > a;
 };
 };
 
 
+template < class SchedulerHandle >
 class FlatGraphManager :
 class FlatGraphManager :
-        public paradevs::pdevs::GraphManager < MyTime >
+        public paradevs::pdevs::GraphManager < MyTime, SchedulerHandle >
 {
 {
 public:
 public:
-    FlatGraphManager(common::Coordinator < MyTime >* coordinator,
+    FlatGraphManager(common::Coordinator < MyTime,
+                                           SchedulerHandle >* coordinator,
                      const paradevs::common::NoParameters& parameters) :
                      const paradevs::common::NoParameters& parameters) :
-        paradevs::pdevs::GraphManager < MyTime >(coordinator, parameters),
+        paradevs::pdevs::GraphManager < MyTime, SchedulerHandle >(coordinator,
+                                                                  parameters),
         a1("a1", common::NoParameters()), b1("b1", common::NoParameters()),
         a1("a1", common::NoParameters()), b1("b1", common::NoParameters()),
         a2("a2", common::NoParameters()), b2("b2", common::NoParameters())
         a2("a2", common::NoParameters()), b2("b2", common::NoParameters())
     {
     {
-        add_child(&a1);
-        add_child(&b1);
-        add_child(&a2);
-        add_child(&b2);
+        FlatGraphManager < SchedulerHandle >::add_child(&a1);
+        FlatGraphManager < SchedulerHandle >::add_child(&b1);
+        FlatGraphManager < SchedulerHandle >::add_child(&a2);
+        FlatGraphManager < SchedulerHandle >::add_child(&b2);
+
         a1.add_out_port("out");
         a1.add_out_port("out");
         b1.add_in_port("in");
         b1.add_in_port("in");
         b1.add_out_port("out");
         b1.add_out_port("out");
         a2.add_in_port("in");
         a2.add_in_port("in");
         a2.add_out_port("out");
         a2.add_out_port("out");
         b2.add_in_port("in");
         b2.add_in_port("in");
-        add_link(&a1, "out", &b1, "in");
-        add_link(&b1, "out", &a2, "in");
-        add_link(&a2, "out", &b2, "in");
+
+        FlatGraphManager < SchedulerHandle >::add_link(&a1, "out", &b1, "in");
+        FlatGraphManager < SchedulerHandle >::add_link(&b1, "out", &a2, "in");
+        FlatGraphManager < SchedulerHandle >::add_link(&a2, "out", &b2, "in");
     }
     }
 
 
     virtual ~FlatGraphManager()
     virtual ~FlatGraphManager()
     { }
     { }
 
 
 private:
 private:
-    paradevs::pdevs::Simulator < MyTime, A > a1;
-    paradevs::pdevs::Simulator < MyTime, B > b1;
-    paradevs::pdevs::Simulator < MyTime, A > a2;
-    paradevs::pdevs::Simulator < MyTime, B > b2;
+    paradevs::pdevs::Simulator < MyTime, A < SchedulerHandle >,
+                                 SchedulerHandle > a1;
+    paradevs::pdevs::Simulator < MyTime, B < SchedulerHandle >,
+                                 SchedulerHandle > b1;
+    paradevs::pdevs::Simulator < MyTime, A < SchedulerHandle >,
+                                 SchedulerHandle > a2;
+    paradevs::pdevs::Simulator < MyTime, B < SchedulerHandle >,
+                                 SchedulerHandle > b2;
 };
 };
 
 
 } } } // namespace paradevs tests pdevs
 } } } // namespace paradevs tests pdevs

+ 56 - 38
src/tests/pdevs/models.hpp

@@ -48,11 +48,12 @@ struct Limits
 
 
 typedef paradevs::common::Time < double, Limits < double > > MyTime;
 typedef paradevs::common::Time < double, Limits < double > > MyTime;
 
 
-class A : public paradevs::pdevs::Dynamics < MyTime >
+template < class SchedulerHandle>
+class A : public paradevs::pdevs::Dynamics < MyTime, SchedulerHandle >
 {
 {
 public:
 public:
     A(const std::string& name, const common::NoParameters& parameters) :
     A(const std::string& name, const common::NoParameters& parameters) :
-        paradevs::pdevs::Dynamics < MyTime >(name, parameters)
+        paradevs::pdevs::Dynamics < MyTime, SchedulerHandle >(name, parameters)
     { }
     { }
     virtual ~A()
     virtual ~A()
     { }
     { }
@@ -61,8 +62,9 @@ public:
     {
     {
 
 
         common::Trace < MyTime >::trace()
         common::Trace < MyTime >::trace()
-            << common::TraceElement < MyTime >(get_name(), t,
-                                               common::DELTA_INT);
+            << common::TraceElement < MyTime >(
+                A < SchedulerHandle >::get_name(), t,
+                common::DELTA_INT);
         common::Trace < MyTime >::trace().flush();
         common::Trace < MyTime >::trace().flush();
 
 
         if (_phase == SEND) {
         if (_phase == SEND) {
@@ -71,12 +73,13 @@ public:
     }
     }
 
 
     void dext(typename MyTime::type t, typename MyTime::type /* e */,
     void dext(typename MyTime::type t, typename MyTime::type /* e */,
-              const common::Bag < MyTime >& msgs)
+              const common::Bag < MyTime, SchedulerHandle >& msgs)
     {
     {
 
 
         common::Trace < MyTime >::trace()
         common::Trace < MyTime >::trace()
-            << common::TraceElement < MyTime >(get_name(), t,
-                                               common::DELTA_EXT)
+            << common::TraceElement < MyTime >(
+                A < SchedulerHandle >::get_name(), t,
+                common::DELTA_EXT)
             << "messages = " << msgs.to_string();
             << "messages = " << msgs.to_string();
         common::Trace < MyTime >::trace().flush();
         common::Trace < MyTime >::trace().flush();
 
 
@@ -84,12 +87,13 @@ public:
     }
     }
 
 
     void dconf(typename MyTime::type t, typename MyTime::type /* e */,
     void dconf(typename MyTime::type t, typename MyTime::type /* e */,
-               const common::Bag < MyTime >& msgs)
+               const common::Bag < MyTime, SchedulerHandle >& msgs)
     {
     {
 
 
         common::Trace < MyTime >::trace()
         common::Trace < MyTime >::trace()
-            << common::TraceElement < MyTime >(get_name(), t,
-                                               common::DELTA_CONF)
+            << common::TraceElement < MyTime >(
+                A < SchedulerHandle >::get_name(), t,
+                common::DELTA_CONF)
             << "messages = " << msgs.to_string();
             << "messages = " << msgs.to_string();
         common::Trace < MyTime >::trace().flush();
         common::Trace < MyTime >::trace().flush();
 
 
@@ -98,8 +102,9 @@ public:
     typename MyTime::type start(typename MyTime::type t)
     typename MyTime::type start(typename MyTime::type t)
     {
     {
         common::Trace < MyTime >::trace()
         common::Trace < MyTime >::trace()
-            << common::TraceElement < MyTime >(get_name(), t,
-                                               common::START);
+            << common::TraceElement < MyTime >(
+                A < SchedulerHandle >::get_name(), t,
+                common::START);
         common::Trace < MyTime >::trace().flush();
         common::Trace < MyTime >::trace().flush();
 
 
         _phase = WAIT;
         _phase = WAIT;
@@ -109,8 +114,9 @@ public:
     typename MyTime::type ta(typename MyTime::type t) const
     typename MyTime::type ta(typename MyTime::type t) const
     {
     {
         common::Trace < MyTime >::trace()
         common::Trace < MyTime >::trace()
-            << common::TraceElement < MyTime >(get_name(), t,
-                                               common::TA);
+            << common::TraceElement < MyTime >(
+                A < SchedulerHandle >::get_name(), t,
+                common::TA);
         common::Trace < MyTime >::trace().flush();
         common::Trace < MyTime >::trace().flush();
 
 
         if (_phase == WAIT) {
         if (_phase == WAIT) {
@@ -120,15 +126,18 @@ public:
         }
         }
     }
     }
 
 
-    common::Bag < MyTime > lambda(typename MyTime::type t) const
+    common::Bag < MyTime, SchedulerHandle > lambda(
+        typename MyTime::type t) const
     {
     {
-        common::Bag < MyTime > msgs;
+        common::Bag < MyTime, SchedulerHandle > msgs;
 
 
-        msgs.push_back(common::ExternalEvent < MyTime >("out", 0.));
+        msgs.push_back(common::ExternalEvent < MyTime, SchedulerHandle >(
+                           "out", 0.));
 
 
         common::Trace < MyTime >::trace()
         common::Trace < MyTime >::trace()
-            << common::TraceElement < MyTime >(get_name(), t,
-                                               common::LAMBDA)
+            << common::TraceElement < MyTime >(
+                A < SchedulerHandle >::get_name(), t,
+                common::LAMBDA)
             << "messages = " << msgs.to_string();
             << "messages = " << msgs.to_string();
         common::Trace < MyTime >::trace().flush();
         common::Trace < MyTime >::trace().flush();
 
 
@@ -144,11 +153,12 @@ private:
     Phase _phase;
     Phase _phase;
 };
 };
 
 
-class B : public paradevs::pdevs::Dynamics < MyTime >
+template < class SchedulerHandle >
+class B : public paradevs::pdevs::Dynamics < MyTime, SchedulerHandle >
 {
 {
 public:
 public:
     B(const std::string& name, const common::NoParameters& parameters) :
     B(const std::string& name, const common::NoParameters& parameters) :
-        paradevs::pdevs::Dynamics < MyTime >(name, parameters)
+        paradevs::pdevs::Dynamics < MyTime, SchedulerHandle >(name, parameters)
     { }
     { }
     virtual ~B()
     virtual ~B()
     { }
     { }
@@ -157,8 +167,9 @@ public:
     {
     {
 
 
         common::Trace < MyTime >::trace()
         common::Trace < MyTime >::trace()
-            << common::TraceElement < MyTime >(get_name(), t,
-                                               common::DELTA_INT);
+            << common::TraceElement < MyTime >(
+                B < SchedulerHandle >::get_name(), t,
+                common::DELTA_INT);
         common::Trace < MyTime >::trace().flush();
         common::Trace < MyTime >::trace().flush();
 
 
         if (_phase == SEND) {
         if (_phase == SEND) {
@@ -167,12 +178,13 @@ public:
     }
     }
 
 
     void dext(typename MyTime::type t, typename MyTime::type /* e */,
     void dext(typename MyTime::type t, typename MyTime::type /* e */,
-              const common::Bag < MyTime >& msgs)
+              const common::Bag < MyTime, SchedulerHandle >& msgs)
     {
     {
 
 
         common::Trace < MyTime >::trace()
         common::Trace < MyTime >::trace()
-            << common::TraceElement < MyTime >(get_name(), t,
-                                               common::DELTA_EXT)
+            << common::TraceElement < MyTime >(
+                B < SchedulerHandle >::get_name(), t,
+                common::DELTA_EXT)
             << "messages = " << msgs.to_string();
             << "messages = " << msgs.to_string();
         common::Trace < MyTime >::trace().flush();
         common::Trace < MyTime >::trace().flush();
 
 
@@ -180,12 +192,13 @@ public:
     }
     }
 
 
     void dconf(typename MyTime::type t, typename MyTime::type /* e */,
     void dconf(typename MyTime::type t, typename MyTime::type /* e */,
-               const common::Bag < MyTime >& msgs)
+               const common::Bag < MyTime, SchedulerHandle >& msgs)
     {
     {
 
 
         common::Trace < MyTime >::trace()
         common::Trace < MyTime >::trace()
-            << common::TraceElement < MyTime >(get_name(), t,
-                                               common::DELTA_CONF)
+            << common::TraceElement < MyTime >(
+                B < SchedulerHandle >::get_name(), t,
+                common::DELTA_CONF)
             << "messages = " << msgs.to_string();
             << "messages = " << msgs.to_string();
         common::Trace < MyTime >::trace().flush();
         common::Trace < MyTime >::trace().flush();
 
 
@@ -195,8 +208,9 @@ public:
     {
     {
 
 
         common::Trace < MyTime >::trace()
         common::Trace < MyTime >::trace()
-            << common::TraceElement < MyTime >(get_name(), t,
-                                               common::START);
+            << common::TraceElement < MyTime >(
+                B < SchedulerHandle >::get_name(), t,
+                common::START);
         common::Trace < MyTime >::trace().flush();
         common::Trace < MyTime >::trace().flush();
 
 
         _phase = WAIT;
         _phase = WAIT;
@@ -206,8 +220,9 @@ public:
     typename MyTime::type ta(typename MyTime::type t) const
     typename MyTime::type ta(typename MyTime::type t) const
     {
     {
         common::Trace < MyTime >::trace()
         common::Trace < MyTime >::trace()
-            << common::TraceElement < MyTime >(get_name(), t,
-                                               common::TA);
+            << common::TraceElement < MyTime >(
+                B < SchedulerHandle >::get_name(), t,
+                common::TA);
         common::Trace < MyTime >::trace().flush();
         common::Trace < MyTime >::trace().flush();
 
 
         if (_phase == WAIT) {
         if (_phase == WAIT) {
@@ -217,15 +232,18 @@ public:
         }
         }
     }
     }
 
 
-    common::Bag < MyTime > lambda(typename MyTime::type t) const
+    common::Bag < MyTime, SchedulerHandle > lambda(
+        typename MyTime::type t) const
     {
     {
-        common::Bag < MyTime > msgs;
+        common::Bag < MyTime, SchedulerHandle > msgs;
 
 
-        msgs.push_back(common::ExternalEvent < MyTime >("out", 0.));
+        msgs.push_back(common::ExternalEvent < MyTime, SchedulerHandle >(
+                           "out", 0.));
 
 
         common::Trace < MyTime >::trace()
         common::Trace < MyTime >::trace()
-            << common::TraceElement < MyTime >(get_name(), t,
-                                               common::LAMBDA)
+            << common::TraceElement < MyTime >(
+                B < SchedulerHandle >::get_name(), t,
+                common::LAMBDA)
             << "messages = " << msgs.to_string();
             << "messages = " << msgs.to_string();
         common::Trace < MyTime >::trace().flush();
         common::Trace < MyTime >::trace().flush();
 
 

+ 15 - 6
src/tests/pdevs/tests.cpp

@@ -38,8 +38,11 @@ TEST_CASE("pdevs/only_one", "run")
 {
 {
     paradevs::common::RootCoordinator <
     paradevs::common::RootCoordinator <
         MyTime, paradevs::pdevs::Coordinator <
         MyTime, paradevs::pdevs::Coordinator <
-            MyTime, paradevs::common::scheduler::VectorScheduler <
-                MyTime >, OnlyOneGraphManager >
+            MyTime,
+            paradevs::common::scheduler::HeapScheduler <
+                MyTime, SchedulerHandle >,
+            SchedulerHandle,
+            OnlyOneGraphManager < SchedulerHandle > >
         > rc(0, 10, "root", paradevs::common::NoParameters(),
         > rc(0, 10, "root", paradevs::common::NoParameters(),
              paradevs::common::NoParameters());
              paradevs::common::NoParameters());
 
 
@@ -78,8 +81,11 @@ TEST_CASE("pdevs/flat", "run")
 {
 {
     paradevs::common::RootCoordinator <
     paradevs::common::RootCoordinator <
         MyTime, paradevs::pdevs::Coordinator <
         MyTime, paradevs::pdevs::Coordinator <
-            MyTime, paradevs::common::scheduler::VectorScheduler <
-                MyTime >, FlatGraphManager >
+            MyTime,
+            paradevs::common::scheduler::HeapScheduler <
+                MyTime, SchedulerHandle >,
+            SchedulerHandle,
+            FlatGraphManager < SchedulerHandle> >
         > rc(0, 10, "root", paradevs::common::NoParameters(),
         > rc(0, 10, "root", paradevs::common::NoParameters(),
              paradevs::common::NoParameters());
              paradevs::common::NoParameters());
 
 
@@ -188,8 +194,11 @@ TEST_CASE("pdevs/hierachical", "run")
 {
 {
     paradevs::common::RootCoordinator <
     paradevs::common::RootCoordinator <
         MyTime, paradevs::pdevs::Coordinator <
         MyTime, paradevs::pdevs::Coordinator <
-            MyTime, paradevs::common::scheduler::HeapScheduler <
-                MyTime >, RootGraphManager >
+            MyTime,
+            paradevs::common::scheduler::HeapScheduler <
+                MyTime, SchedulerHandle >,
+            SchedulerHandle,
+            RootGraphManager >
         > rc(0, 10, "root", paradevs::common::NoParameters(),
         > rc(0, 10, "root", paradevs::common::NoParameters(),
              paradevs::common::NoParameters());
              paradevs::common::NoParameters());